hello 404 Not Found
Al-HUWAITI Shell
Al-huwaiti


Server : Apache
System : Linux webm006.cluster103.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User : chryzalihi ( 621211)
PHP Version : 8.3.31
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
Directory :  /home/chryzalihi/www/wp-content/languages/themes/the/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/chryzalihi/www/wp-content/languages/themes/the/OpenCloud.zip
PK(m]��01""Version.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud;

use Guzzle\Common\Version as GuzzleVersion;
use Guzzle\Http\Curl\CurlVersion;

/**
 * Class Version
 *
 * @package OpenCloud
 */
class Version
{
    const VERSION = '1.12.2';

    /**
     * @return string Indicate current SDK version.
     */
    public static function getVersion()
    {
        return self::VERSION;
    }

    /**
     * @return bool|float|string Indicate cURL's version.
     */
    public static function getCurlVersion()
    {
        return CurlVersion::getInstance()->get('version');
    }

    /**
     * @return string Indicate Guzzle's version.
     */
    public static function getGuzzleVersion()
    {
        return GuzzleVersion::VERSION;
    }
}
PK(m]��	��Common/Log/Logger.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Log;

use OpenCloud\Common\Exceptions\LoggingException;
use Psr\Log\AbstractLogger;
use Psr\Log\LogLevel;

/**
 * Basic logger for OpenCloud which extends FIG's PSR-3 standard logger.
 *
 * @link https://github.com/php-fig/log
 */
class Logger extends AbstractLogger
{
    /**
     * Is this debug class enabled or not?
     *
     * @var bool
     */
    private $enabled;

    /**
     * These are the levels which will always be outputted - regardless of
     * user-imposed settings.
     *
     * @var array
     */
    private $urgentLevels = array(
        LogLevel::EMERGENCY,
        LogLevel::ALERT,
        LogLevel::CRITICAL
    );

    /**
     * Logging options.
     *
     * @var array
     */
    private $options = array(
        'outputToFile' => false,
        'logFile'      => null,
        'dateFormat'   => 'd/m/y H:I',
        'delimeter'    => ' - '
    );

    public function __construct($enabled = false)
    {
        $this->enabled = $enabled;
    }

    public static function newInstance()
    {
        return new static();
    }

    /**
     * Determines whether a log level needs to be outputted.
     *
     * @param  string $logLevel
     * @return bool
     */
    private function outputIsUrgent($logLevel)
    {
        return in_array($logLevel, $this->urgentLevels);
    }

    /**
     * Interpolates context values into the message placeholders.
     *
     * @param string $message
     * @param array  $context
     * @return type
     */
    private function interpolate($message, array $context = array())
    {
        // build a replacement array with braces around the context keys
        $replace = array();
        foreach ($context as $key => $val) {
            $replace['{' . $key . '}'] = $val;
        }

        // interpolate replacement values into the message and return
        return strtr($message, $replace);
    }

    /**
     * Enable or disable the debug class.
     *
     * @param  bool $enabled
     * @return self
     */
    public function setEnabled($enabled)
    {
        $this->enabled = $enabled;

        return $this;
    }

    /**
     * Is the debug class enabled?
     *
     * @return bool
     */
    public function isEnabled()
    {
        return $this->enabled === true;
    }

    /**
     * Set an array of options.
     *
     * @param array $options
     */
    public function setOptions(array $options = array())
    {
        foreach ($options as $key => $value) {
            $this->setOption($key, $value);
        }

        return $this;
    }

    /**
     * Get all options.
     *
     * @return array
     */
    public function getOptions()
    {
        return $this->options;
    }

    /**
     * Set an individual option.
     *
     * @param string $key
     * @param string $value
     */
    public function setOption($key, $value)
    {
        if ($this->optionExists($key)) {
            $this->options[$key] = $value;

            return $this;
        }
    }

    /**
     * Get an individual option.
     *
     * @param  string $key
     * @return string|null
     */
    public function getOption($key)
    {
        if ($this->optionExists($key)) {
            return $this->options[$key];
        }
    }

    /**
     * Check whether an individual option exists.
     *
     * @param  string $key
     * @return bool
     */
    private function optionExists($key)
    {
        return array_key_exists($key, $this->getOptions());
    }

    /**
     * Outputs a log message if necessary.
     *
     * @param string $logLevel
     * @param string $message
     * @param string $context
     */
    public function log($level, $message, array $context = array())
    {
        if ($this->outputIsUrgent($level) || $this->isEnabled()) {
            $this->dispatch($message, $context);
        }
    }

    /**
     * Used to format the line outputted in the log file.
     *
     * @param  string $string
     * @return string
     */
    private function formatFileLine($string)
    {
        $format = $this->getOption('dateFormat') . $this->getOption('delimeter');

        return date($format) . $string;
    }

    /**
     * Dispatch a log output message.
     *
     * @param string $message
     * @param array  $context
     * @throws LoggingException
     */
    private function dispatch($message, $context)
    {
        $output = $this->interpolate($message, $context) . PHP_EOL;

        if ($this->getOption('outputToFile') === true) {
            $file = $this->getOption('logFile');

            if (!is_writable($file)) {
                throw new LoggingException(
                    'The log file either does not exist or is not writeable'
                );
            }

            // Output to file
            file_put_contents($file, $this->formatFileLine($output), FILE_APPEND);
        } else {
            echo $output;
        }
    }

    /**
     * Helper method, use PSR-3 warning function for deprecation warnings
     * @see http://www.php-fig.org/psr/psr-3/
     */
    public static function deprecated($method, $new)
    {
        return sprintf('The %s method is deprecated, please use %s instead', $method, $new);
    }
}
PK(m]�@��Common/Log/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK(m]](b�,�,Common/Collection.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common;

use OpenCloud\Common\Log\Logger;

/**
 * @deprecated
 * @codeCoverageIgnore
 */
class Collection extends Base
{
    private $service;
    private $itemClass;
    private $itemList = array();
    private $pointer = 0;
    private $sortKey;
    private $nextPageClass;
    private $nextPageCallback;
    private $nextPageUrl;

    /**
     * A Collection is an array of objects
     *
     * Some assumptions:
     * * The `Collection` class assumes that there exists on its service
     *   a factory method with the same name of the class. For example, if
     *   you create a Collection of class `Foobar`, it will attempt to call
     *   the method `parent::Foobar()` to create instances of that class.
     * * It assumes that the factory method can take an array of values, and
     *   it passes that to the method.
     *
     * @param Service $service   - the service associated with the collection
     * @param string  $itemclass - the Class of each item in the collection
     *                           (assumed to be the name of the factory method)
     * @param array   $arr       - the input array
     */
    public function __construct($service, $class, array $array = array())
    {
        $service->getLogger()->warning(Logger::deprecated(__METHOD__, 'OpenCloud\Common\Collection\CollectionBuilder'));

        $this->setService($service);

        $this->setNextPageClass($class);

        // If they've supplied a FQCN, only get the last part
        $class = (false !== ($classNamePos = strrpos($class, '\\')))
            ? substr($class, $classNamePos + 1)
            : $class;

        $this->setItemClass($class);

        // Set data
        $this->setItemList($array);
    }

    /**
     * Set the entire data array.
     *
     * @param array $array
     */
    private function setItemList(array $array)
    {
        $this->itemList = $array;

        return $this;
    }

    /**
     * Retrieve the entire data array.
     *
     * @return array
     */
    public function getItemList()
    {
        return $this->itemList;
    }

    /**
     * Set the service.
     *
     * @param Service|PersistentObject $service
     */
    public function setService($service)
    {
        $this->service = $service;

        return $this;
    }

    /**
     * Retrieves the service associated with the Collection
     *
     * @return Service
     */
    public function getService()
    {
        return $this->service;
    }

    /**
     * Set the resource class name.
     */
    private function setItemClass($itemClass)
    {
        $this->itemClass = $itemClass;

        return $this;
    }

    /**
     * Get item class.
     */
    private function getItemClass()
    {
        return $this->itemClass;
    }

    /**
     * Set the key that will be used for sorting.
     */
    private function setSortKey($sortKey)
    {
        $this->sortKey = $sortKey;

        return $this;
    }

    /**
     * Get the key that will be used for sorting.
     */
    private function getSortKey()
    {
        return $this->sortKey;
    }

    /**
     * Set next page class.
     */
    private function setNextPageClass($nextPageClass)
    {
        $this->nextPageClass = $nextPageClass;

        return $this;
    }

    /**
     * Get next page class.
     */
    private function getNextPageClass()
    {
        return $this->nextPageClass;
    }

    /**
     * for paginated collection, sets the callback function and URL for
     * the next page
     *
     * The callback function should have the signature:
     *
     *      function Whatever($class, $url, $parent)
     *
     * and the `$url` should be the URL of the next page of results
     *
     * @param callable $callback the name of the function (or array of
     *                           object, function name)
     * @param string   $url      the URL of the next page of results
     * @return void
     */
    public function setNextPageCallback($callback, $url)
    {
        $this->nextPageCallback = $callback;
        $this->nextPageUrl = $url;

        return $this;
    }

    /**
     * Get next page callback.
     */
    private function getNextPageCallback()
    {
        return $this->nextPageCallback;
    }

    /**
     * Get next page URL.
     */
    private function getNextPageUrl()
    {
        return $this->nextPageUrl;
    }

    /**
     * Returns the number of items in the collection
     *
     * For most services, this is the total number of items. If the Collection
     * is paginated, however, this only returns the count of items in the
     * current page of data.
     *
     * @return int
     */
    public function count()
    {
        return count($this->getItemList());
    }

    /**
     * Pseudonym for count()
     *
     * @codeCoverageIgnore
     */
    public function size()
    {
        return $this->count();
    }

    /**
     * Resets the pointer to the beginning, but does NOT return the first item
     *
     * @api
     * @return void
     */
    public function reset()
    {
        $this->pointer = 0;
    }

    /**
     * Resets the collection pointer back to the first item in the page
     * and returns it
     *
     * This is useful if you're only interested in the first item in the page.
     *
     * @api
     * @return Base the first item in the set
     */
    public function first()
    {
        $this->reset();

        return $this->next();
    }

    /**
     * Return the item at a particular point of the array.
     *
     * @param  mixed $offset
     * @return mixed
     */
    public function getItem($pointer)
    {
        return (isset($this->itemList[$pointer])) ? $this->itemList[$pointer] : false;
    }

    /**
     * Add an item to this collection
     *
     * @param mixed $item
     */
    public function addItem($item)
    {
        $this->itemList[] = $item;
    }

    /**
     * Returns the next item in the page
     *
     * @api
     * @return Base the next item or FALSE if at the end of the page
     */
    public function next()
    {
        if ($this->pointer >= $this->count()) {
            return false;
        }

        $data = $this->getItem($this->pointer++);
        $class = $this->getItemClass();

        // Are there specific methods in the parent/service that can be used to
        // instantiate the resource? Currently supported: getResource(), resource()
        foreach (array($class, 'get' . ucfirst($class)) as $method) {
            if (method_exists($this->service, $method)) {
                return call_user_func(array($this->service, $method), $data);
            }
        }

        // Backup method
        if (method_exists($this->service, 'resource')) {
            return $this->service->resource($class, $data);
        }

        return false;
    }

    /**
     * sorts the collection on a specified key
     *
     * Note: only top-level keys can be used as the sort key. Note that this
     * only sorts the data in the current page of the Collection (for
     * multi-page data).
     *
     * @api
     * @param string $keyname the name of the field to use as the sort key
     * @return void
     */
    public function sort($keyname = 'id')
    {
        $this->setSortKey($keyname);
        usort($this->itemList, array($this, 'sortCompare'));
    }

    /**
     * selects only specified items from the Collection
     *
     * This provides a simple form of filtering on Collections. For each item
     * in the collection, it calls the callback function, passing it the item.
     * If the callback returns `TRUE`, then the item is retained; if it returns
     * `FALSE`, then the item is deleted from the collection.
     *
     * Note that this should not supersede server-side filtering; the
     * `Collection::Select()` method requires that *all* of the data for the
     * Collection be retrieved from the server before the filtering is
     * performed; this can be very inefficient, especially for large data
     * sets. This method is mostly useful on smaller-sized sets.
     *
     * Example:
     * <code>
     * $services = $connection->ServiceList();
     * $services->Select(function ($item) { return $item->region=='ORD';});
     * // now the $services Collection only has items from the ORD region
     * </code>
     *
     * `Select()` is *destructive*; that is, it actually removes entries from
     * the collection. For example, if you use `Select()` to find items with
     * the ID > 10, then use it again to find items that are <= 10, it will
     * return an empty list.
     *
     * @api
     * @param callable $testfunc a callback function that is passed each item
     *                           in turn. Note that `Select()` performs an explicit test for
     *                           `FALSE`, so functions like `strpos()` need to be cast into a
     *                           boolean value (and not just return the integer).
     * @returns void
     * @throws DomainError if callback doesn't return a boolean value
     */
    public function select($testfunc)
    {
        foreach ($this->getItemList() as $index => $item) {
            $test = call_user_func($testfunc, $item);
            if (!is_bool($test)) {
                throw new Exceptions\DomainError(
                    Lang::translate('Callback function for Collection::Select() did not return boolean')
                );
            }
            if ($test === false) {
                unset($this->itemList[$index]);
            }
        }
    }

    /**
     * returns the Collection object for the next page of results, or
     * FALSE if there are no more pages
     *
     * Generally, the structure for a multi-page collection will look like
     * this:
     *
     *      $coll = $obj->Collection();
     *      do {
     *          while ($item = $coll->Next()) {
     *              // do something with the item
     *          }
     *      } while ($coll = $coll->NextPage());
     *
     * @api
     * @return Collection if there are more pages of results, otherwise FALSE
     */
    public function nextPage()
    {
        return ($this->getNextPageUrl() !== null)
            ? call_user_func($this->getNextPageCallback(), $this->getNextPageClass(), $this->getNextPageUrl())
            : false;
    }

    /**
     * Compares two values of sort keys
     */
    private function sortCompare($a, $b)
    {
        $key = $this->getSortKey();

        // Handle strings
        if (is_string($a->$key)) {
            return strcmp($a->$key, $b->$key);
        }

        // Handle others with logical comparisons
        if ($a->$key == $b->$key) {
            return 0;
        } elseif ($a->$key < $b->$key) {
            return -1;
        } else {
            return 1;
        }
    }
}
PK(m]3)P4P4Common/Base.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common;

use OpenCloud\Common\Collection\ResourceIterator;
use OpenCloud\Common\Constants\Header as HeaderConst;
use OpenCloud\Common\Constants\Mime as MimeConst;
use OpenCloud\Common\Exceptions\JsonError;
use Psr\Log\LoggerInterface;

/**
 * The root class for all other objects used or defined by this SDK.
 *
 * It contains common code for error handling as well as service functions that
 * are useful. Because it is an abstract class, it cannot be called directly,
 * and it has no publicly-visible properties.
 */
abstract class Base
{
    /**
     * Holds all the properties added by overloading.
     *
     * @var array
     */
    private $properties = array();

    /**
     * The logger instance
     *
     * @var LoggerInterface
     */
    private $logger;

    /**
     * The aliases configure for the properties of the instance.
     *
     * @var array
     */
    protected $aliases = array();

    /**
     * @return static
     */
    public static function getInstance()
    {
        return new static();
    }

    /**
     * Intercept non-existent method calls for dynamic getter/setter functionality.
     *
     * @param $method
     * @param $args
     * @throws Exceptions\RuntimeException
     */
    public function __call($method, $args)
    {
        $prefix = substr($method, 0, 3);

        // Get property - convert from camel case to underscore
        $property = lcfirst(substr($method, 3));

        // Only do these methods on properties which exist
        if ($this->propertyExists($property) && $prefix == 'get') {
            return $this->getProperty($property);
        }

        // Do setter
        if ($this->propertyExists($property) && $prefix == 'set') {
            return $this->setProperty($property, $args[0]);
        }

        throw new Exceptions\RuntimeException(sprintf(
            'No method %s::%s()',
            get_class($this),
            $method
        ));
    }

    /**
     * We can set a property under three conditions:
     *
     * 1. If it has a concrete setter: setProperty()
     * 2. If the property exists
     * 3. If the property name's prefix is in an approved list
     *
     * @param  mixed $property
     * @param  mixed $value
     * @return mixed
     */
    protected function setProperty($property, $value)
    {
        $setter = 'set' . $this->toCamel($property);

        if (method_exists($this, $setter)) {
            return call_user_func(array($this, $setter), $value);
        } elseif (false !== ($propertyVal = $this->propertyExists($property))) {
            // Are we setting a public or private property?
            if ($this->isAccessible($propertyVal)) {
                $this->$propertyVal = $value;
            } else {
                $this->properties[$propertyVal] = $value;
            }

            return $this;
        } else {
            $this->getLogger()->warning(
                'Attempted to set {property} with value {value}, but the'
                . ' property has not been defined. Please define first.',
                array(
                    'property' => $property,
                    'value'    => print_r($value, true)
                )
            );
        }
    }

    /**
     * Basic check to see whether property exists.
     *
     * @param string $property   The property name being investigated.
     * @param bool   $allowRetry If set to TRUE, the check will try to format the name in underscores because
     *                           there are sometimes discrepancies between camelCaseNames and underscore_names.
     * @return bool
     */
    protected function propertyExists($property, $allowRetry = true)
    {
        if (!property_exists($this, $property) && !$this->checkAttributePrefix($property)) {
            // Convert to under_score and retry
            if ($allowRetry) {
                return $this->propertyExists($this->toUnderscores($property), false);
            } else {
                $property = false;
            }
        }

        return $property;
    }

    /**
     * Convert a string to camelCase format.
     *
     * @param       $string
     * @param  bool $capitalise Optional flag which allows for word capitalization.
     * @return mixed
     */
    public function toCamel($string, $capitalise = true)
    {
        if ($capitalise) {
            $string = ucfirst($string);
        }

        return preg_replace_callback('/_([a-z])/', function ($char) {
            return strtoupper($char[1]);
        }, $string);
    }

    /**
     * Convert string to underscore format.
     *
     * @param $string
     * @return mixed
     */
    public function toUnderscores($string)
    {
        $string = lcfirst($string);

        return preg_replace_callback('/([A-Z])/', function ($char) {
            return "_" . strtolower($char[1]);
        }, $string);
    }

    /**
     * Does the property exist in the object variable list (i.e. does it have public or protected visibility?)
     *
     * @param $property
     * @return bool
     */
    private function isAccessible($property)
    {
        return array_key_exists($property, get_object_vars($this));
    }

    /**
     * Checks the attribute $property and only permits it if the prefix is
     * in the specified $prefixes array
     *
     * This is to support extension namespaces in some services.
     *
     * @param string $property the name of the attribute
     * @return boolean
     */
    private function checkAttributePrefix($property)
    {
        if (!method_exists($this, 'getService')) {
            return false;
        }
        $prefix = strstr($property, ':', true);

        return in_array($prefix, $this->getService()->namespaces());
    }

    /**
     * Grab value out of the data array.
     *
     * @param string $property
     * @return mixed
     */
    protected function getProperty($property)
    {
        if (array_key_exists($property, $this->properties)) {
            return $this->properties[$property];
        } elseif (array_key_exists($this->toUnderscores($property), $this->properties)) {
            return $this->properties[$this->toUnderscores($property)];
        } elseif (method_exists($this, 'get' . ucfirst($property))) {
            return call_user_func(array($this, 'get' . ucfirst($property)));
        } elseif (false !== ($propertyVal = $this->propertyExists($property)) && $this->isAccessible($propertyVal)) {
            return $this->$propertyVal;
        }

        return null;
    }

    /**
     * Sets the logger.
     *
     * @param LoggerInterface $logger
     *
     * @return $this
     */
    public function setLogger(LoggerInterface $logger = null)
    {
        $this->logger = $logger;

        return $this;
    }

    /**
     * Returns the Logger object.
     *
     * @return LoggerInterface
     */
    public function getLogger()
    {
        if (null === $this->logger) {
            $this->setLogger(new Log\Logger);
        }

        return $this->logger;
    }

    /**
     * @return bool
     */
    public function hasLogger()
    {
        return (null !== $this->logger);
    }

    /**
     * @deprecated
     */
    public function url($path = null, array $query = array())
    {
        return $this->getUrl($path, $query);
    }

    /**
     * Populates the current object based on an unknown data type.
     *
     * @param  mixed $info
     * @param        bool
     * @throws Exceptions\InvalidArgumentError
     */
    public function populate($info, $setObjects = true)
    {
        if (is_string($info) || is_integer($info)) {
            $this->setProperty($this->primaryKeyField(), $info);
            $this->refresh($info);
        } elseif (is_object($info) || is_array($info)) {
            foreach ($info as $key => $value) {
                if ($key == 'metadata' || $key == 'meta') {
                    // Try retrieving existing value
                    if (null === ($metadata = $this->getProperty($key))) {
                        // If none exists, create new object
                        $metadata = new Metadata;
                    }

                    // Set values for metadata
                    $metadata->setArray($value);

                    // Set object property
                    $this->setProperty($key, $metadata);
                } elseif (!empty($this->associatedResources[$key]) && $setObjects === true) {
                    // Associated resource
                    try {
                        $resource = $this->getService()->resource($this->associatedResources[$key], $value);
                        $resource->setParent($this);

                        $this->setProperty($key, $resource);
                    } catch (Exception\ServiceException $e) {
                    }
                } elseif (!empty($this->associatedCollections[$key]) && $setObjects === true) {
                    // Associated collection
                    try {
                        $className = $this->associatedCollections[$key];
                        $options = $this->makeResourceIteratorOptions($className);
                        $iterator = ResourceIterator::factory($this, $options, $value);

                        $this->setProperty($key, $iterator);
                    } catch (Exception\ServiceException $e) {
                    }
                } elseif (!empty($this->aliases[$key])) {
                    // Sometimes we might want to preserve camelCase
                    // or covert `rax-bandwidth:bandwidth` to `raxBandwidth`
                    $this->setProperty($this->aliases[$key], $value);
                } else {
                    // Normal key/value pair
                    $this->setProperty($key, $value);
                }
            }
        } elseif (null !== $info) {
            throw new Exceptions\InvalidArgumentError(sprintf(
                Lang::translate('Argument for [%s] must be string or object'),
                get_class()
            ));
        }
    }

    /**
     * Checks the most recent JSON operation for errors.
     *
     * @throws Exceptions\JsonError
     * @codeCoverageIgnore
     */
    public static function checkJsonError()
    {
        switch (json_last_error()) {
            case JSON_ERROR_NONE:
                return;
            case JSON_ERROR_DEPTH:
                $jsonError = 'JSON error: The maximum stack depth has been exceeded';
                break;
            case JSON_ERROR_STATE_MISMATCH:
                $jsonError = 'JSON error: Invalid or malformed JSON';
                break;
            case JSON_ERROR_CTRL_CHAR:
                $jsonError = 'JSON error: Control character error, possibly incorrectly encoded';
                break;
            case JSON_ERROR_SYNTAX:
                $jsonError = 'JSON error: Syntax error';
                break;
            case JSON_ERROR_UTF8:
                $jsonError = 'JSON error: Malformed UTF-8 characters, possibly incorrectly encoded';
                break;
            default:
                $jsonError = 'Unexpected JSON error';
                break;
        }

        if (isset($jsonError)) {
            throw new JsonError(Lang::translate($jsonError));
        }
    }

    public static function generateUuid()
    {
        return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            // 32 bits for "time_low"
            mt_rand(0, 0xffff), mt_rand(0, 0xffff),

            // 16 bits for "time_mid"
            mt_rand(0, 0xffff),

            // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 4
            mt_rand(0, 0x0fff) | 0x4000,

            // 16 bits, 8 bits for "clk_seq_hi_res",
            // 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            mt_rand(0, 0x3fff) | 0x8000,

            // 48 bits for "node"
            mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
        );
    }

    public function makeResourceIteratorOptions($resource)
    {
        $options = array('resourceClass' => $this->stripNamespace($resource));

        if (method_exists($resource, 'jsonCollectionName')) {
            $options['key.collection'] = $resource::jsonCollectionName();
        }

        if (method_exists($resource, 'jsonCollectionElement')) {
            $options['key.collectionElement'] = $resource::jsonCollectionElement();
        }

        return $options;
    }

    public function stripNamespace($namespace)
    {
        $array = explode('\\', $namespace);

        return end($array);
    }

    protected static function getJsonHeader()
    {
        return array(HeaderConst::CONTENT_TYPE => MimeConst::JSON);
    }
}
PK(m]�@��Common/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK(m]�r��VV%Common/Collection/ArrayCollection.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Collection;

use Countable;
use OpenCloud\Common\ArrayAccess;

/**
 * A generic, abstract collection class that allows collections to exhibit array functionality.
 *
 * @package OpenCloud\Common\Collection
 */
abstract class ArrayCollection extends ArrayAccess implements Countable
{
    /**
     * @var array The elements being held by this iterator.
     */
    protected $elements;

    /**
     * @param array $data
     */
    public function __construct(array $data = array())
    {
        $this->setElements($data);
    }

    /**
     * @return int
     */
    public function count()
    {
        return count($this->elements);
    }

    /**
     * @param array $data
     * @return $this
     */
    public function setElements(array $data = array())
    {
        $this->elements = $data;

        return $this;
    }

    /**
     * Appends a value to the container.
     *
     * @param $value
     */
    public function append($value)
    {
        $this->elements[] = $value;
    }

    /**
     * Checks to see whether a particular value exists.
     *
     * @param $value
     * @return bool
     */
    public function valueExists($value)
    {
        return array_search($value, $this->elements) !== false;
    }
}
PK(m]��n�1"1"'Common/Collection/PaginatedIterator.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Collection;

use Guzzle\Http\Exception\ClientErrorResponseException;
use Guzzle\Http\Url;
use Iterator;
use OpenCloud\Common\Http\Message\Formatter;

/**
 * Class ResourceIterator is tasked with iterating over resource collections - many of which are paginated. Based on
 * a base URL, the iterator will append elements based on further requests to the API. Each time this happens,
 * query parameters (marker) are updated based on the current value.
 *
 * @package OpenCloud\Common\Collection
 * @since   1.8.0
 */
class PaginatedIterator extends ResourceIterator implements Iterator
{
    const MARKER = 'marker';
    const LIMIT = 'limit';

    /**
     * @var string Used for requests which append elements.
     */
    protected $currentMarker;

    /**
     * @var \Guzzle\Http\Url The next URL for pagination
     */
    protected $nextUrl;

    protected $defaults = array(
        // Collection limits
        'limit.total'           => 10000,
        'limit.page'            => 100,

        // The "links" element key in response
        'key.links'             => 'links',

        // JSON structure
        'key.collection'        => null,
        'key.collectionElement' => null,

        // The property used as the marker
        'key.marker'            => 'name',

        // Options for "next page" request
        'request.method'        => 'GET',
        'request.headers'       => array(),
        'request.body'          => null,
        'request.curlOptions'   => array()
    );

    protected $required = array('resourceClass', 'baseUrl');

    /**
     * Basic factory method to easily instantiate a new ResourceIterator.
     *
     * @param       $parent  The parent object
     * @param array $options Iterator options
     * @param array $data    Optional data to set initially
     * @return static
     */
    public static function factory($parent, array $options = array(), array $data = null)
    {
        $list = new static();

        $list->setOptions($list->parseOptions($options))
            ->setResourceParent($parent)
            ->rewind();

        if ($data) {
            $list->setElements($data);
        } else {
            $list->appendNewCollection();
        }

        return $list;
    }


    /**
     * @param Url $url
     * @return $this
     */
    public function setBaseUrl(Url $url)
    {
        $this->baseUrl = $url;

        return $this;
    }

    public function current()
    {
        return parent::current();
    }

    public function key()
    {
        return parent::key();
    }

    /**
     * {@inheritDoc}
     * Also update the current marker.
     */
    public function next()
    {
        if (!$this->valid()) {
            return false;
        }

        $current = $this->current();

        $this->position++;
        $this->updateMarkerToCurrent();

        return $current;
    }

    /**
     * Update the current marker based on the current element. The marker will be based on a particular property of this
     * current element, so you must retrieve it first.
     */
    public function updateMarkerToCurrent()
    {
        if (!isset($this->elements[$this->position])) {
            return;
        }

        $element = $this->elements[$this->position];
        $this->setMarkerFromElement($element);
    }

    protected function setMarkerFromElement($element)
    {
        $key = $this->getOption('key.marker');

        if (isset($element->$key)) {
            $this->currentMarker = $element->$key;
        }
    }

    /**
     * {@inheritDoc}
     * Also reset current marker.
     */
    public function rewind()
    {
        parent::rewind();
        $this->currentMarker = null;
    }

    public function valid()
    {
        $totalLimit = $this->getOption('limit.total');
        if ($totalLimit !== false && $this->position >= $totalLimit) {
            return false;
        } elseif (isset($this->elements[$this->position])) {
            return true;
        } elseif ($this->shouldAppend() === true) {
            $before = $this->count();
            $this->appendNewCollection();
            return ($this->count() > $before) ? true : false;
        }

        return false;
    }

    protected function shouldAppend()
    {
        return $this->currentMarker && (
            $this->nextUrl ||
            $this->position % $this->getOption('limit.page') == 0
        );
    }

    /**
     * Append an array of standard objects to the current collection.
     *
     * @param array $elements
     * @return $this
     */
    public function appendElements(array $elements)
    {
        $this->elements = array_merge($this->elements, $elements);

        return $this;
    }

    /**
     * Retrieve a new page of elements from the API (based on a new request), parse its response, and append them to the
     * collection.
     *
     * @return $this|bool
     */
    public function appendNewCollection()
    {
        $request = $this->resourceParent
            ->getClient()
            ->createRequest(
                $this->getOption('request.method'),
                $this->constructNextUrl(),
                $this->getOption('request.headers'),
                $this->getOption('request.body'),
                $this->getOption('request.curlOptions')
            );

        try {
            $response = $request->send();
        } catch (ClientErrorResponseException $e) {
            return false;
        }

        if (!($body = Formatter::decode($response)) || $response->getStatusCode() == 204) {
            return false;
        }

        $this->nextUrl = $this->extractNextLink($body);

        return $this->appendElements($this->parseResponseBody($body));
    }

    /**
     * Based on the response body, extract the explicitly set "link" value if provided.
     *
     * @param $body
     * @return bool
     */
    public function extractNextLink($body)
    {
        $key = $this->getOption('key.links');

        $value = null;

        if (isset($body->$key)) {
            foreach ($body->$key as $link) {
                if (isset($link->rel) && $link->rel == 'next') {
                    $value = $link->href;
                    break;
                }
            }
        }

        return $value;
    }

    /**
     * Make the next page URL.
     *
     * @return Url|string
     */
    public function constructNextUrl()
    {
        if (!$url = $this->nextUrl) {
            $url = clone $this->getOption('baseUrl');
            $query = $url->getQuery();

            if (isset($this->currentMarker)) {
                $query[static::MARKER] = $this->currentMarker;
            }

            if (($limit = $this->getOption('limit.page')) && !$query->hasKey(static::LIMIT)) {
                $query[static::LIMIT] = $limit;
            }

            $url->setQuery($query);
        }

        return $url;
    }

    /**
     * Based on the response from the API, parse it for the data we need (i.e. an meaningful array of elements).
     *
     * @param $body
     * @return array
     */
    public function parseResponseBody($body)
    {
        $collectionKey = $this->getOption('key.collection');

        $data = array();

        if (is_array($body)) {
            $data = $body;
        } elseif (isset($body->$collectionKey)) {
            if (null !== ($elementKey = $this->getOption('key.collectionElement'))) {
                // The object has element levels which need to be iterated over
                foreach ($body->$collectionKey as $item) {
                    $subValues = $item->$elementKey;
                    unset($item->$elementKey);
                    $data[] = array_merge((array) $item, (array) $subValues);
                }
            } else {
                // The object has a top-level collection name only
                $data = $body->$collectionKey;
            }
        }

        return $data;
    }

    /**
     * Walk the entire collection, populating everything.
     */
    public function populateAll()
    {
        while ($this->valid()) {
            $this->next();
        }
    }
}
PK(m]��k��&Common/Collection/ResourceIterator.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Collection;

use Iterator;
use OpenCloud\Common\Exceptions\InvalidArgumentError;
use OpenCloud\Common\Log\Logger;

class ResourceIterator extends ArrayCollection implements Iterator
{
    /**
     * @var int Internal pointer of the iterator - reveals its current position.
     */
    protected $position;

    /**
     * @var object The parent object which resource models are instantiated from. The parent needs to have appropriate
     *             methods to instantiate the particular object.
     */
    protected $resourceParent;

    /**
     * @var array The options for this iterator.
     */
    protected $options;

    /**
     * @var array Fallback defaults if options are not explicitly set or provided.
     */
    protected $defaults = array('limit.total' => 1000);

    /**
     * @var array Required options
     */
    protected $required = array();

    public static function factory($parent, array $options = array(), array $data = array())
    {
        $iterator = new static($data);

        $iterator->setResourceParent($parent)
            ->setElements($data)
            ->setOptions($iterator->parseOptions($options))
            ->rewind();

        return $iterator;
    }

    protected function parseOptions(array $options)
    {
        $options = $options + $this->defaults;

        if ($missing = array_diff($this->required, array_keys($options))) {
            throw new InvalidArgumentError(sprintf('%s is a required option', implode(',', $missing)));
        }

        return $options;
    }

    /**
     * @param $parent
     * @return $this
     */
    public function setResourceParent($parent)
    {
        $this->resourceParent = $parent;

        return $this;
    }

    /**
     * @param array $options
     * @return $this
     */
    public function setOptions(array $options)
    {
        $this->options = $options;

        return $this;
    }

    /**
     * @return array Options for the resource iterator.
     */
    public function getOptions()
    {
        return $this->options;
    }

    /**
     * Set a particular option.
     *
     * @param $key
     * @param $value
     * @return $this
     */
    public function setOption($key, $value)
    {
        $this->options[$key] = $value;

        return $this;
    }

    /**
     * @param $key
     * @return null
     */
    public function getOption($key)
    {
        return (isset($this->options[$key])) ? $this->options[$key] : null;
    }

    /**
     * This method is called after self::rewind() and self::next() to check if the current position is valid.
     *
     * @return bool
     */
    public function valid()
    {
        return $this->offsetExists($this->position) && $this->position < $this->getOption('limit.total');
    }

    /**
     * Increment the current pointer by 1, and also update the current marker.
     */
    public function next()
    {
        $this->position++;

        return $this->current();
    }

    /**
     * Reset the pointer and current marker.
     */
    public function rewind()
    {
        $this->position = 0;
    }

    /**
     * @return mixed
     */
    public function current()
    {
        return $this->constructResource($this->currentElement());
    }

    /**
     * @return mixed
     */
    public function currentElement()
    {
        return $this->offsetGet($this->key());
    }

    /**
     * Using a standard object, this method populates a resource model with all the object data. It does this using a
     * whatever method the parent object has for resource creation.
     *
     * @param $object Standard object
     * @return mixed
     * @throws \OpenCloud\Common\Exceptions\CollectionException
     */
    public function constructResource($object)
    {
        $className = $this->getOption('resourceClass');

        if (substr_count($className, '\\')) {
            $array = explode('\\', $className);
            $className = end($array);
        }

        $parent = $this->resourceParent;
        $getter = sprintf('get%s', ucfirst($className));

        if (method_exists($parent, $className)) {
            // $parent->server($data)
            return call_user_func(array($parent, $className), $object);
        } elseif (method_exists($parent, $getter)) {
            // $parent->getServer($data)
            return call_user_func(array($parent, $getter), $object);
        } elseif (method_exists($parent, 'resource')) {
            // $parent->resource('Server', $data)
            return $parent->resource($className, $object);
        } else {
            return $object;
        }
    }

    /**
     * Return the current position/internal pointer.
     *
     * @return int|mixed
     */
    public function key()
    {
        return $this->position;
    }

    public function getElement($offset)
    {
        return (!$this->offsetExists($offset)) ? false : $this->constructResource($this->offsetGet($offset));
    }

    /**
     * @deprecated
     */
    public function first()
    {
        Logger::newInstance()->warning(Logger::deprecated(__METHOD__, 'getElement'));

        return $this->getElement(0);
    }

    /**
     * @todo Implement
     */
    public function sort()
    {
    }

    public function search($callback)
    {
        $return = false;

        if (!is_callable($callback)) {
            throw new InvalidArgumentError('The provided argument must be a valid callback');
        }

        foreach ($this->elements as $element) {
            $resource = $this->constructResource($element);
            if (call_user_func($callback, $resource) === true) {
                $return = $resource;
                break;
            }
        }

        return $return;
    }
}
PK(m]�@��Common/Collection/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK(m]@��C��!Common/Service/ServiceBuilder.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Service;

use Guzzle\Http\ClientInterface;
use OpenCloud\Common\Exceptions\ServiceException;

/**
 * This object is a factory for building Service objects.
 */
class ServiceBuilder
{
    /**
     * Simple factory method for creating services.
     *
     * @param Client $client  The HTTP client object
     * @param string $class   The class name of the service
     * @param array  $options The options.
     * @return \OpenCloud\Common\Service\ServiceInterface
     * @throws ServiceException
     */
    public static function factory(ClientInterface $client, $class, array $options = array())
    {
        $name = isset($options['name']) ? $options['name'] : null;
        $urlType = isset($options['urlType']) ? $options['urlType'] : null;

        if (isset($options['region'])) {
            $region = $options['region'];
        } elseif ($client->getUser() && ($defaultRegion = $client->getUser()->getDefaultRegion())) {
            $region = $defaultRegion;
        } else {
            $region = null;
        }

        return new $class($client, null, $name, $region, $urlType);
    }
}
PK(m]�Z�F��Common/Service/Catalog.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Service;

use OpenCloud\Common\Exceptions\InvalidArgumentError;

/**
 * This object represents the service catalog returned by the Rackspace API. It contains all the services available
 * to the end-user, including specific information for each service.
 */
class Catalog
{
    /**
     * @var array Service items
     */
    private $items = array();

    /**
     * Produces a Catalog from a mixed input.
     *
     * @param  $config
     * @return Catalog
     * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
     */
    public static function factory($config)
    {
        if (is_array($config)) {
            $catalog = new self();
            foreach ($config as $item) {
                $catalog->items[] = CatalogItem::factory($item);
            }
        } elseif ($config instanceof Catalog) {
            $catalog = $config;
        } else {
            throw new InvalidArgumentError(sprintf(
                'Argument for Catalog::factory must be either an array or an '
                . 'instance of %s. You passed in: %s',
                get_class(),
                print_r($config, true)
            ));
        }

        return $catalog;
    }

    /**
     * @return array
     */
    public function getItems()
    {
        return $this->items;
    }
}
PK(m],p�ԓ�#Common/Service/ServiceInterface.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Service;

use Guzzle\Http\ClientInterface;

interface ServiceInterface
{
    public function setClient(ClientInterface $client);

    public function getClient();

    public function setEndpoint($endpoint);

    public function getEndpoint();

    public function getUrl();
}
PK(m]2�^[
[
Common/Service/CatalogItem.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Service;

/**
 * This object represents an individual service catalog item - in other words an API Service. Each service has
 * particular information which form the basis of how it distinguishes itself, and how it executes API operations.
 */
class CatalogItem
{
    /**
     * @var string
     */
    private $name;

    /**
     * @var string
     */
    private $type;

    /**
     * @var array
     */
    private $endpoints = array();

    /**
     * Construct a CatalogItem from a mixed input.
     *
     * @param  $object
     * @return CatalogItem
     */
    public static function factory($object)
    {
        $item = new self();
        $item->setName($object->name)
            ->setType($object->type)
            ->setEndpoints($object->endpoints);

        return $item;
    }

    /**
     * @param $name
     * @return $this
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * A basic string check.
     *
     * @param  $string
     * @return bool
     */
    public function hasName($string)
    {
        return !strnatcasecmp($this->name, $string);
    }

    /**
     * @param $type
     * @return $this
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }

    /**
     * @return string
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * @param $string
     * @return bool
     */
    public function hasType($string)
    {
        return !strnatcasecmp($this->type, $string);
    }

    /**
     * @param  array $endpoints
     * @return $this
     */
    public function setEndpoints(array $endpoints)
    {
        $this->endpoints = $endpoints;

        return $this;
    }

    /**
     * @return array
     */
    public function getEndpoints()
    {
        return $this->endpoints;
    }

    /**
     * Using a standard data object, extract its endpoint.
     *
     * @param $region
     * @return mixed
     * @throws \OpenCloud\Common\Exceptions\EndpointError
     */
    public function getEndpointFromRegion($region)
    {
        foreach ($this->endpoints as $endpoint) {
            // Return the endpoint if it is regionless OR if the endpoint's
            // region matches the $region supplied by the caller.
            if (!isset($endpoint->region) || $endpoint->region == $region) {
                return $endpoint;
            }
        }

        throw new \OpenCloud\Common\Exceptions\EndpointError(sprintf(
            'This service [%s] does not have access to the [%s] endpoint.',
            $this->name,
            $region
        ));
    }
}
PK(m]�w��Common/Service/Endpoint.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Service;

use Guzzle\Http\Url;
use OpenCloud\OpenStack;
use OpenCloud\Common\Http\Message\Formatter;
use OpenCloud\Common\Exceptions\UnsupportedVersionError;

/**
 * An endpoint serves as a location which receives and emits API interactions. It will therefore also host
 * particular API resources. Each endpoint object has different access methods - one receives network connections over
 * the public Internet, another receives traffic through an internal network. You will be able to access the latter
 * from a Server, for example, in the same Region - which will incur no bandwidth charges, and be quicker.
 */
class Endpoint
{
    /**
     * @var \Guzzle\Http\Url
     */
    private $publicUrl;

    /**
     * @var \Guzzle\Http\Url
     */
    private $privateUrl;

    /**
     * @var string
     */
    private $region;

    /**
     * @param $object
     * @param string $supportedServiceVersion Service version supported by the SDK
     * @param OpenCloud\OpenStack $client OpenStack client
     * @return Endpoint
     */
    public static function factory($object, $supportedServiceVersion, OpenStack $client)
    {
        $endpoint = new self();

        if (isset($object->publicURL)) {
            $endpoint->setPublicUrl($endpoint->getVersionedUrl($object->publicURL, $supportedServiceVersion, $client));
        }
        if (isset($object->internalURL)) {
            $endpoint->setPrivateUrl($endpoint->getVersionedUrl($object->internalURL, $supportedServiceVersion, $client));
        }
        if (isset($object->region)) {
            $endpoint->setRegion($object->region);
        }

        return $endpoint;
    }

    /**
     * @param $publicUrl
     * @return $this
     */
    public function setPublicUrl(Url $publicUrl)
    {
        $this->publicUrl = $publicUrl;

        return $this;
    }

    /**
     * @return Url
     */
    public function getPublicUrl()
    {
        return $this->publicUrl;
    }

    /**
     * @param $privateUrl
     * @return $this
     */
    public function setPrivateUrl(Url $privateUrl)
    {
        $this->privateUrl = $privateUrl;

        return $this;
    }

    /**
     * @return Url
     */
    public function getPrivateUrl()
    {
        return $this->privateUrl;
    }

    /**
     * @param $region
     * @return $this
     */
    public function setRegion($region)
    {
        $this->region = $region;

        return $this;
    }

    /**
     * @return string
     */
    public function getRegion()
    {
        return $this->region;
    }

    /**
     * Returns the endpoint URL with a version in it
     *
     * @param string $url Endpoint URL
     * @param string $supportedServiceVersion Service version supported by the SDK
     * @param OpenCloud\OpenStack $client OpenStack client
     * @return Guzzle/Http/Url Endpoint URL with version in it
     */
    private function getVersionedUrl($url, $supportedServiceVersion, OpenStack $client)
    {
        $versionRegex = '/\/[vV][0-9][0-9\.]*/';
        if (1 === preg_match($versionRegex, $url)) {
            // URL has version in it; use it as-is
            return Url::factory($url);
        }

        // If there is no version in $url but no $supportedServiceVersion
        // is specified, just return $url as-is but log a warning
        if (is_null($supportedServiceVersion)) {
            $client->getLogger()->warning('Service version supported by SDK not specified. Using versionless service URL as-is, without negotiating version.');
            return Url::factory($url);
        }

        // Make GET request to URL
        $response = Formatter::decode($client->get($url)->send());

        // Attempt to parse response and determine URL for given $version
        if (!isset($response->versions) || !is_array($response->versions)) {
            throw new UnsupportedVersionError('Could not negotiate version with service.');
        }

        foreach ($response->versions as $version) {
            if (($version->status == 'CURRENT' || $version->status == 'SUPPORTED')
                && $version->id == $supportedServiceVersion) {
                foreach ($version->links as $link) {
                    if ($link->rel == 'self') {
                        return Url::factory($link->href);
                    }
                }
            }
        }

        // If we've reached this point, we could not find a versioned
        // URL in the response; throw an error
        throw new UnsupportedVersionError(sprintf(
            'SDK supports version %s which is not currently provided by service.',
            $supportedServiceVersion
        ));
    }
}
PK(m]����Common/Service/NovaService.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Service;

use OpenCloud\Compute\Resource\Flavor;

/**
 * NovaService serves as an additional abstraction for particular OpenStack services that exhibit shared functionality.
 */
abstract class NovaService extends CatalogService
{
    /**
     * Returns a flavor from the service
     *
     * @param string|null $id
     * @return Flavor
     */
    public function flavor($id = null)
    {
        return new Flavor($this, $id);
    }

    /**
     * Returns a list of Flavor objects
     *
     * @param boolean $details Returns full details or not.
     * @param array   $filter  Array for creating queries
     * @return Collection
     */
    public function flavorList($details = true, array $filter = array())
    {
        $path = Flavor::resourceName();

        if ($details === true) {
            $path .= '/detail';
        }

        return $this->collection('OpenCloud\Compute\Resource\Flavor', $this->getUrl($path, $filter));
    }

    /**
     * Loads the available namespaces from the /extensions resource
     */
    protected function loadNamespaces()
    {
        foreach ($this->getExtensions() as $object) {
            $this->namespaces[] = $object->alias;
        }

        if (!empty($this->additionalNamespaces)) {
            $this->namespaces += $this->additionalNamespaces;
        }
    }
}
PK(m]�@��Common/Service/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK(m]��WW"Common/Service/AbstractService.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Service;

use Guzzle\Http\ClientInterface;
use OpenCloud\Common\Base;
use OpenCloud\Common\Collection\PaginatedIterator;
use OpenCloud\Common\Exceptions;

/**
 * This class defines a cloud service; a relationship between a specific OpenStack
 * and a provided service, represented by a URL in the service catalog.
 *
 * Because Service is an abstract class, it cannot be called directly. Provider
 * services such as Rackspace Cloud Servers or OpenStack Swift are each
 * subclassed from Service.
 */
abstract class AbstractService extends Base implements ServiceInterface
{
    /**
     * @var \OpenCloud\Common\Http\Client The client which interacts with the API.
     */
    protected $client;

    /**
     * @var \OpenCloud\Common\Service\Endpoint The endpoint for this service.
     */
    protected $endpoint;

    /**
     * @var array A collection of resource models that this service has control over.
     */
    protected $resources = array();

    /**
     * @var array Namespaces for this service.
     */
    protected $namespaces = array();

    /**
     * @param ClientInterface $client
     */
    public function setClient(ClientInterface $client)
    {
        $this->client = $client;
    }

    /**
     * @return \OpenCloud\Common\Http\Client
     */
    public function getClient()
    {
        return $this->client;
    }

    /**
     * @param Endpoint $endpoint
     */
    public function setEndpoint($endpoint)
    {
        $this->endpoint = $endpoint;
    }

    /**
     * @return \OpenCloud\Common\Service\Endpoint
     */
    public function getEndpoint()
    {
        return $this->endpoint;
    }

    /**
     * Get all associated resources for this service.
     *
     * @access public
     * @return array
     */
    public function getResources()
    {
        return $this->resources;
    }

    /**
     * Internal method for accessing child namespace from parent scope.
     *
     * @return type
     */
    protected function getCurrentNamespace()
    {
        $namespace = get_class($this);

        return substr($namespace, 0, strrpos($namespace, '\\'));
    }

    /**
     * Resolves FQCN for local resource.
     *
     * @param  $resourceName
     * @return string
     * @throws \OpenCloud\Common\Exceptions\UnrecognizedServiceError
     */
    protected function resolveResourceClass($resourceName)
    {
        $className = substr_count($resourceName, '\\')
            ? $resourceName
            : $this->getCurrentNamespace() . '\\Resource\\' . ucfirst($resourceName);

        if (!class_exists($className)) {
            throw new Exceptions\UnrecognizedServiceError(sprintf(
                '%s resource does not exist, please try one of the following: %s',
                $resourceName,
                implode(', ', $this->getResources())
            ));
        }

        return $className;
    }

    /**
     * Factory method for instantiating resource objects.
     *
     * @param  string $resourceName
     * @param  mixed  $info   (default: null)
     * @param  mixed  $parent The parent object
     * @return object
     */
    public function resource($resourceName, $info = null, $parent = null)
    {
        $className = $this->resolveResourceClass($resourceName);

        $resource = new $className($this);

        if ($parent) {
            $resource->setParent($parent);
        }

        $resource->populate($info);

        return $resource;
    }

    /**
     * Factory method for instantiating a resource collection.
     *
     * @param string      $resourceName
     * @param string|null $url
     * @param string|null $parent
     * @return PaginatedIterator
     */
    public function resourceList($resourceName, $url = null, $parent = null)
    {
        $className = $this->resolveResourceClass($resourceName);

        return $this->collection($className, $url, $parent);
    }

    /**
     * @codeCoverageIgnore
     */
    public function collection($class, $url = null, $parent = null, $data = null)
    {
        if (!$parent) {
            $parent = $this;
        }

        if (!$url) {
            $resource = $this->resolveResourceClass($class);
            $url = $parent->getUrl($resource::resourceName());
        }

        $options = $this->makeResourceIteratorOptions($this->resolveResourceClass($class));
        $options['baseUrl'] = $url;

        return PaginatedIterator::factory($parent, $options, $data);
    }

    /**
     * @deprecated
     */
    public function namespaces()
    {
        return $this->getNamespaces();
    }

    /**
     * Returns a list of supported namespaces
     *
     * @return array
     */
    public function getNamespaces()
    {
        return (isset($this->namespaces) && is_array($this->namespaces))
            ? $this->namespaces
            : array();
    }
}
PK(m]�2;S!Common/Service/CatalogService.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Service;

use Guzzle\Http\ClientInterface;
use Guzzle\Http\Exception\BadResponseException;
use Guzzle\Http\Url;
use OpenCloud\Common\Base;
use OpenCloud\Common\Exceptions;
use OpenCloud\Common\Http\Message\Formatter;
use OpenCloud\OpenStack;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

abstract class CatalogService extends AbstractService
{
    const DEFAULT_URL_TYPE = 'publicURL';
    const SUPPORTED_VERSION = null;

    /**
     * @var string The type of this service, as set in Catalog.
     */
    private $type;

    /**
     * @var string The name of this service, as set in Catalog.
     */
    private $name;

    /**
     * @var string The chosen region(s) for this service.
     */
    private $region;

    /**
     * @var string Either 'publicURL' or 'internalURL'.
     */
    private $urlType;

    /**
     * @var bool Indicates whether a service is "regionless" or not. Defaults to FALSE because nearly all services
     *           are region-specific.
     */
    protected $regionless = false;

    /**
     * Creates a service object, based off the specified client.
     *
     * The service's URL is defined in the client's serviceCatalog; it
     * uses the $type, $name, $region, and $urlType to find the proper endpoint
     * and set it. If it cannot find a URL in the service catalog that matches
     * the criteria, then an exception is thrown.
     *
     * @param Client $client  Client object
     * @param string $type    Service type (e.g. 'compute')
     * @param string $name    Service name (e.g. 'cloudServersOpenStack')
     * @param string $region  Service region (e.g. 'DFW', 'ORD', 'IAD', 'LON', 'SYD' or 'HKG')
     * @param string $urlType Either 'publicURL' or 'internalURL'
     */
    public function __construct(ClientInterface $client, $type = null, $name = null, $region = null, $urlType = null)
    {
        if (($client instanceof Base || $client instanceof OpenStack) && $client->hasLogger()) {
            $this->setLogger($client->getLogger());
        }

        $this->setClient($client);

        $this->name = $name ? : static::DEFAULT_NAME;
        $this->region = $region;

        $this->region = $region;
        if ($this->regionless !== true && !$this->region) {
            throw new Exceptions\ServiceException(sprintf(
                'The %s service must have a region set. You can either pass in a region string as an argument param, or'
                . ' set a default region for your user account by executing User::setDefaultRegion and ::update().',
                $this->name
            ));
        }

        $this->type = $type ? : static::DEFAULT_TYPE;
        $this->urlType = $urlType ? : static::DEFAULT_URL_TYPE;
        $this->setEndpoint($this->findEndpoint());

        $this->client->setBaseUrl($this->getBaseUrl());

        if ($this instanceof EventSubscriberInterface) {
            $this->client->getEventDispatcher()->addSubscriber($this);
        }
    }

    /**
     * @return string
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * @return string
     */
    public function getRegion()
    {
        return $this->region;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @return string
     */
    public function getUrlType()
    {
        return $this->urlType;
    }

    /**
     * @deprecated
     */
    public function region()
    {
        return $this->getRegion();
    }

    /**
     * @deprecated
     */
    public function name()
    {
        return $this->name;
    }

    /**
     * Returns the URL for the Service
     *
     * @param  string $path  URL path segment
     * @param  array  $query Array of query pairs
     * @return Guzzle\Http\Url
     */
    public function getUrl($path = null, array $query = array())
    {
        return Url::factory($this->getBaseUrl())
            ->addPath($path)
            ->setQuery($query);
    }

    /**
     * @deprecated
     */
    public function url($path = null, array $query = array())
    {
        return $this->getUrl($path, $query);
    }

    /**
     * Returns the /extensions for the service
     *
     * @api
     * @return array of objects
     */
    public function getExtensions()
    {
        $ext = $this->getMetaUrl('extensions');

        return (is_object($ext) && isset($ext->extensions)) ? $ext->extensions : array();
    }

    /**
     * Returns the limits for the service
     *
     * @return array of limits
     */
    public function limits()
    {
        $limits = $this->getMetaUrl('limits');

        return (is_object($limits)) ? $limits->limits : array();
    }

    /**
     * Extracts the appropriate endpoint from the service catalog based on the
     * name and type of a service, and sets for further use.
     *
     * @return \OpenCloud\Common\Service\Endpoint
     * @throws \OpenCloud\Common\Exceptions\EndpointError
     */
    private function findEndpoint()
    {
        if (!$this->getClient()->getCatalog()) {
            $this->getClient()->authenticate();
        }

        $catalog = $this->getClient()->getCatalog();

        // Search each service to find The One
        foreach ($catalog->getItems() as $service) {
            if ($service->hasType($this->type) && $service->hasName($this->name)) {
                return Endpoint::factory($service->getEndpointFromRegion($this->region), static::SUPPORTED_VERSION, $this->getClient());
            }
        }

        throw new Exceptions\EndpointError(sprintf(
            'No endpoints for service type [%s], name [%s], region [%s] and urlType [%s]',
            $this->type,
            $this->name,
            $this->region,
            $this->urlType
        ));
    }

    /**
     * Constructs a specified URL from the subresource
     *
     * Given a subresource (e.g., "extensions"), this constructs the proper
     * URL and retrieves the resource.
     *
     * @param string $resource The resource requested; should NOT have slashes
     *                         at the beginning or end
     * @return \stdClass object
     */
    private function getMetaUrl($resource)
    {
        $url = clone $this->getBaseUrl();
        $url->addPath($resource);
        try {
            $response = $this->getClient()->get($url)->send();

            return Formatter::decode($response);
        } catch (BadResponseException $e) {
            // @codeCoverageIgnoreStart
            return array();
            // @codeCoverageIgnoreEnd
        }
    }

    /**
     * Get the base URL for this service, based on the set URL type.
     * @return \Guzzle\Http\Url
     * @throws \OpenCloud\Common\Exceptions\ServiceException
     */
    public function getBaseUrl()
    {
        $url = ($this->urlType == 'publicURL')
            ? $this->endpoint->getPublicUrl()
            : $this->endpoint->getPrivateUrl();

        if ($url === null) {
            throw new Exceptions\ServiceException(sprintf(
                'The base %s could not be found. Perhaps the service '
                . 'you are using requires a different URL type, or does '
                . 'not support this region.',
                $this->urlType
            ));
        }

        return $url;
    }
}
PK(m]rȗH��Common/ArrayAccess.phpnu&1i�<?php

namespace OpenCloud\Common;

class ArrayAccess implements \ArrayAccess
{
    protected $elements;

    public function __construct($data = array())
    {
        $this->elements = (array) $data;
    }

    /**
     * Sets a value to a particular offset.
     *
     * @param mixed $offset
     * @param mixed $value
     */
    public function offsetSet($offset, $value)
    {
        if ($offset === null) {
            $this->elements[] = $value;
        } else {
            $this->elements[$offset] = $value;
        }
    }

    /**
     * Checks to see whether a particular offset key exists.
     *
     * @param mixed $offset
     * @return bool
     */
    public function offsetExists($offset)
    {
        return array_key_exists($offset, $this->elements);
    }

    /**
     * Unset a particular key.
     *
     * @param mixed $offset
     */
    public function offsetUnset($offset)
    {
        unset($this->elements[$offset]);
    }

    /**
     * Get the value for a particular offset key.
     *
     * @param mixed $offset
     * @return mixed|null
     */
    public function offsetGet($offset)
    {
        return $this->offsetExists($offset) ? $this->elements[$offset] : null;
    }
}
PK(m]�8]���Common/Lang.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common;

class Lang
{
    public static function translate($word = null)
    {
        return $word;
    }

    public static function noslash($str)
    {
        while ($str && (substr($str, -1) == '/')) {
            $str = substr($str, 0, strlen($str) - 1);
        }

        return $str;
    }
}
PK(m]
��U��Common/Constants/Size.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Constants;

class Size
{
    const KB = 1024;
    const MB = 1048576;
    const GB = 1073741824;
    const TB = 1099511627776;
}
PK(m]�6�Common/Constants/State.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Constants;

class State
{
    const ACTIVE = 'ACTIVE';
    const ERROR = 'ERROR';
    const DEFAULT_TIMEOUT = 3600;
    const DEFAULT_INTERVAL = 10;
}
PK(m]ĝe��Common/Constants/Service.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Constants;

class Service
{
    const INTERNAL_URL = 'internalUrl';
    const PUBLIC_URL = 'publicUrl';
}
PK(m]S�a��Common/Constants/Mime.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Constants;

class Mime
{
    const JSON = 'application/json';
    const TEXT = 'text/plain';
}
PK(m]�
��Common/Constants/Datetime.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Constants;

class Datetime
{
    /**
     * Values in s.
     */
    const SECOND = 1;
    const MINUTE = 60;
    const HOUR = 3600;
    const DAY = 86400;

    /**
     * Values in ms.
     */
    const MILLISECOND = 1;
    const SECOND_M = 1000;
    const MINUTE_M = 60000;
    const HOUR_M = 3600000;
    const DAY_M = 86400000;
}
PK(m]�@��Common/Constants/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK(m]ٻoU�	�	Common/Constants/Header.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Constants;

/**
 * Standard Header Field names as defined in RFC2616.
 *
 * @link    http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
 * @package OpenCloud\Common\Constants
 */
class Header
{
    const ACCEPT = 'Accept';
    const ACCEPT_CHARSET = 'Accept-Charset';
    const ACCEPT_ENCODING = 'Accept-Encoding';
    const ACCEPT_LANGUAGE = 'Accept-Language';
    const ACCEPT_RANGES = 'Accept-Ranges';
    const AGE = 'Age';
    const ALLOW = 'Allow';
    const AUTHORIZATION = 'Authorization';
    const CACHE_CONTROL = 'Cache-Control';
    const CONNECTION = 'Connection';
    const CONTENT_ENCODING = 'Content-Encoding';
    const CONTENT_LANGUAGE = 'Content-Language';
    const CONTENT_LENGTH = 'Content-Length';
    const CONTENT_LOCATION = 'Content-Location';
    const CONTENT_MD5 = 'Content-MD5';
    const CONTENT_RANGE = 'Content-Range';
    const CONTENT_TYPE = 'Content-Type';
    const DATE = 'Date';
    const ETAG = 'ETag';
    const EXPECT = 'Expect';
    const EXPIRES = 'Expires';
    const FROM = 'From';
    const HOST = 'Host';
    const IF_MATCH = 'If-Match';
    const IF_MODIFIED_SINCE = 'If-Modified-Since';
    const IF_NONE_MATCH = 'If-None-Match';
    const IF_RANGE = 'If-Range';
    const IF_UNMODIFIED_SINCE = 'If-Unmodified-Since';
    const LAST_MODIFIED = 'Last-Modified';
    const LOCATION = 'Location';
    const MAX_FORWARDS = 'Max-Forwards';
    const PRAGMA = 'Pragma';
    const PROXY_AUTHENTICATION = 'Proxy-Authenticate';
    const PROXY_AUTHORIZATION = 'Proxy-Authorization';
    const RANGE = 'Range';
    const REFERER = 'Referer';
    const RETRY_AFTER = 'Retry-After';
    const SERVER = 'Server';
    const TE = 'TE';
    const TRAILER = 'Trailer';
    const TRANSFER_ENCODING = 'Transfer-Encoding';
    const UPGRADE = 'Upgrade';
    const USER_AGENT = 'User-Agent';
    const VARY = 'Vary';
    const VIA = 'Via';
}
PK(m]�@��Common/Http/Message/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK(m]\Uו!Common/Http/Message/Formatter.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Http\Message;

use Guzzle\Http\Message\Response;
use OpenCloud\Common\Constants\Header;
use OpenCloud\Common\Constants\Mime;
use OpenCloud\Common\Exceptions\JsonError;

class Formatter
{
    public static function decode(Response $response)
    {
        if (strpos($response->getHeader(Header::CONTENT_TYPE), Mime::JSON) !== false) {
            $string = (string) $response->getBody();
            $response = json_decode($string);
            self::checkJsonError($string);

            return $response;
        }
    }

    public static function encode($body)
    {
        return json_encode($body);
    }

    public static function checkJsonError($string = null)
    {
        if (json_last_error()) {
            $error = sprintf('%s', json_last_error_msg());
            $message = ($string) ? sprintf('%s trying to decode: %s', $error, $string) : $error;
            throw new JsonError($message);
        }
    }
}
PK(m]��\~~)Common/Http/Message/RequestSubscriber.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Http\Message;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Description of RequestSubscriber
 */
class RequestSubscriber implements EventSubscriberInterface
{
    public static function getInstance()
    {
        return new self();
    }

    public static function getSubscribedEvents()
    {
        return array(
            'curl.callback.progress' => 'doCurlProgress'
        );
    }

    /**
     * @param $options
     * @return mixed
     * @codeCoverageIgnore
     */
    public function doCurlProgress($options)
    {
        $curlOptions = $options['request']->getCurlOptions();

        if ($curlOptions->hasKey('progressCallback')) {
            return call_user_func($curlOptions->get('progressCallback'));
        }
    }
}
PK(m]!^��Common/Http/Client.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Http;

use Guzzle\Http\Client as GuzzleClient;
use Guzzle\Http\Curl\CurlVersion;
use OpenCloud\Common\Exceptions\UnsupportedVersionError;

/**
 * Base client object which handles HTTP transactions. Each service is based off of a Client which acts as a
 * centralized parent.
 */
class Client extends GuzzleClient
{
    const VERSION = '1.9.0';
    const MINIMUM_PHP_VERSION = '5.3.0';

    public function __construct($baseUrl = '', $config = null)
    {
        // @codeCoverageIgnoreStart
        if (PHP_VERSION < self::MINIMUM_PHP_VERSION) {
            throw new UnsupportedVersionError(sprintf(
                'You must have PHP version >= %s installed.',
                self::MINIMUM_PHP_VERSION
            ));
        }
        // @codeCoverageIgnoreEnd

        parent::__construct($baseUrl, $config);
    }

    public function getDefaultUserAgent()
    {
        return 'OpenCloud/' . self::VERSION
        . ' cURL/' . CurlVersion::getInstance()->get('version')
        . ' PHP/' . PHP_VERSION;
    }

    public function getUserAgent()
    {
        return $this->userAgent;
    }
}
PK(m]�@��Common/Http/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK(m]l<§Common/Metadata.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common;

/**
 * The Metadata class represents either Server or Image metadata
 */
class Metadata extends Base implements \Countable
{
    /**
     * @var array Internal data store.
     */
    protected $metadata = array();

    /**
     * This setter overrides the base one, since the metadata key can be
     * anything
     *
     * @param string $property
     * @param string $value
     * @return void
     */
    public function __set($property, $value)
    {
        return $this->setProperty($property, $value);
    }

    public function __get($key)
    {
        return $this->getProperty($key);
    }

    public function propertyExists($property, $allowRetry = true)
    {
        return isset($this->metadata[strtolower($property)])
        || parent::propertyExists($property, $allowRetry);
    }

    public function getProperty($property)
    {
        return $this->propertyExists($property) ? $this->metadata[strtolower($property)] : null;
    }

    public function setProperty($property, $value)
    {
        $this->metadata[strtolower($property)] = $value;
    }

    public function __isset($property)
    {
        return $this->propertyExists($property);
    }

    /**
     * Returns the list of keys defined
     *
     * @return array
     */
    public function keylist()
    {
        return $this->metadata;
    }

    /**
     * Sets metadata values from an array, with optional prefix
     *
     * If $prefix is provided, then only array keys that match the prefix
     * are set as metadata values, and $prefix is stripped from the key name.
     *
     * @param array  $values an array of key/value pairs to set
     * @param string $prefix if provided, a prefix that is used to identify
     *                       metadata values. For example, you can set values from headers
     *                       for a Container by using $prefix='X-Container-Meta-'.
     * @return void
     */
    public function setArray($values, $prefix = null)
    {
        if (empty($values)) {
            return false;
        }

        foreach ($values as $key => $value) {
            if ($prefix && strpos($key, $prefix) === 0) {
                $key = substr($key, strlen($prefix));
            }
            $this->setProperty($key, $value);
        }
    }

    public function toArray()
    {
        return $this->metadata;
    }

    public function count()
    {
        return count($this->metadata);
    }
}
PK(m]ZR[��"Common/Exceptions/NetworkError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class NetworkError extends \Exception
{
}
PK(m]O*�<��Common/Exceptions/IOError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class IOError extends \Exception
{
}
PK(m]��+��&Common/Exceptions/HttpTimeoutError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class HttpTimeoutError extends \Exception
{
}
PK(m]?r����"Common/Exceptions/UnknownError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UnknownError extends \Exception
{
}
PK(m].t�K��#Common/Exceptions/UserListError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UserListError extends \Exception
{
}
PK(m]�l��!Common/Exceptions/UpdateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UpdateError extends \Exception
{
}
PK(m]�U���(Common/Exceptions/EmptyResponseError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class EmptyResponseError extends \Exception
{
}
PK(m]�Dp��$Common/Exceptions/AttributeError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class AttributeError extends \Exception
{
}
PK(m]W����-Common/Exceptions/ResourceBucketException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ResourceBucketException extends \Exception
{
}
PK(m]\Y-Y��'Common/Exceptions/AsyncTimeoutError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class AsyncTimeoutError extends \Exception
{
}
PK(m]/xrB��%Common/Exceptions/UserUpdateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UserUpdateError extends \Exception
{
}
PK(m]��<��-Common/Exceptions/MisMatchedChecksumError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class MisMatchedChecksumError extends \Exception
{
}
PK(m]
�J���)Common/Exceptions/DatabaseCreateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class DatabaseCreateError extends \Exception
{
}
PK(m]-����+Common/Exceptions/UnknownParameterError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UnknownParameterError extends \Exception
{
}
PK(m]t6u(��!Common/Exceptions/VolumeError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class VolumeError extends \Exception
{
}
PK(m]�@���'Common/Exceptions/MissingValueError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class MissingValueError extends \Exception
{
}
PK(m]��Hg��#Common/Exceptions/MetadataError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class MetadataError extends \Exception
{
}
PK(m]z���#Common/Exceptions/EndpointError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class EndpointError extends \Exception
{
}
PK(m]��׻�(Common/Exceptions/HttpForbiddenError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class HttpForbiddenError extends \Exception
{
}
PK(m]\P��)Common/Exceptions/InstanceDeleteError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InstanceDeleteError extends \Exception
{
}
PK(m]:?a`��$Common/Exceptions/ServerUrlError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ServerUrlError extends \Exception
{
}
PK(m]��-��%Common/Exceptions/IdRequiredError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class IdRequiredError extends \Exception
{
}
PK(m]}3eָ�%Common/Exceptions/ObjectCopyError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ObjectCopyError extends \Exception
{
}
PK(m]��3D��Common/Exceptions/HttpError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class HttpError extends \Exception
{
}
PK(m]n�J��)Common/Exceptions/MetadataCreateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class MetadataCreateError extends \Exception
{
}
PK(m]�@��Common/Exceptions/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK(m]����&Common/Exceptions/LoggingException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

use Exception;

class LoggingException extends Exception
{
}
PK(m]�#Y��,Common/Exceptions/ContainerNotFoundError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ContainerNotFoundError extends \Exception
{
}
PK(m]��a��(Common/Exceptions/NoContentTypeError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class NoContentTypeError extends \Exception
{
}
PK(m]�
Ȼ�(Common/Exceptions/NetworkUpdateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class NetworkUpdateError extends \Exception
{
}
PK(m]�o���)Common/Exceptions/MetadataPrefixError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class MetadataPrefixError extends \Exception
{
}
PK(m]_�+��'Common/Exceptions/ServerDeleteError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ServerDeleteError extends \Exception
{
}
PK(m]�G���#Common/Exceptions/InstanceError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InstanceError extends \Exception
{
}
PK(m]߹����,Common/Exceptions/ContainerNotEmptyError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ContainerNotEmptyError extends \Exception
{
}
PK(m]��$��#Common/Exceptions/SnapshotError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class SnapshotError extends \Exception
{
}
PK(m]pC�3��(Common/Exceptions/HttpOverLimitError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class HttpOverLimitError extends \Exception
{
}
PK(m]��BV��.Common/Exceptions/UnrecognizedServiceError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UnrecognizedServiceError extends \Exception
{
}
PK(m]�踼�)Common/Exceptions/MetadataDeleteError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class MetadataDeleteError extends \Exception
{
}
PK(m]ff��'Common/Exceptions/ServerActionError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ServerActionError extends \Exception
{
}
PK(m]��ٺ�'Common/Exceptions/ServerCreateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ServerCreateError extends \Exception
{
}
PK(m]���5��%Common/Exceptions/VolumeTypeError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class VolumeTypeError extends \Exception
{
}
PK(m]�����)Common/Exceptions/CollectionException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class CollectionException extends \Exception
{
}
PK(m]�����)Common/Exceptions/InstanceCreateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InstanceCreateError extends \Exception
{
}
PK(m]�I6�&Common/Exceptions/InstanceNotFound.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InstanceNotFound extends \Exception
{
}
PK(m]��ʚ��!Common/Exceptions/FlavorError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class FlavorError extends \Exception
{
}
PK(m]�^�3��)Common/Exceptions/DatabaseDeleteError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class DatabaseDeleteError extends \Exception
{
}
PK(m]6���LL+Common/Exceptions/HttpResponseException.phpnu&1i�<?php

namespace OpenCloud\Common\Exceptions;

use Guzzle\Http\Message\RequestInterface;
use Guzzle\Http\Message\Response;

class HttpResponseException extends \Exception
{
    protected $response;
    protected $request;

    /**
     * Set the request that caused the exception
     *
     * @param RequestInterface $request Request to set
     *
     * @return RequestException
     */
    public function setRequest(RequestInterface $request)
    {
        $this->request = $request;

        return $this;
    }

    /**
     * Get the request that caused the exception
     *
     * @return RequestInterface
     */
    public function getRequest()
    {
        return $this->request;
    }

    /**
     * Set the response that caused the exception
     *
     * @param Response $response Response to set
     */
    public function setResponse(Response $response)
    {
        $this->response = $response;
    }

    /**
     * Get the response that caused the exception
     *
     * @return Response
     */
    public function getResponse()
    {
        return $this->response;
    }
}
PK(m],ڏ�1Common/Exceptions/ForbiddenOperationException.phpnu&1i�<?php

namespace OpenCloud\Common\Exceptions;

use Guzzle\Http\Exception\BadResponseException;

class ForbiddenOperationException extends HttpResponseException
{
    public static function factory(BadResponseException $exception)
    {
        $response = $exception->getResponse();

        $message = sprintf(
            "This operation was forbidden; the API returned a %s status code with this message:\n%s",
            $response->getStatusCode(),
            (string) $response->getBody()
        );

        $e = new self($message);
        $e->setResponse($response);
        $e->setRequest($exception->getRequest());

        return $e;
    }
}
PK(m]BD���&Common/Exceptions/MetadataKeyError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class MetadataKeyError extends \Exception
{
}
PK(m]j��ǽ�*Common/Exceptions/CdnNotAvailableError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class CdnNotAvailableError extends \Exception
{
}
PK(m]�����"Common/Exceptions/CdnHttpError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class CdnHttpError extends \Exception
{
}
PK(m]��6��#Common/Exceptions/UserNameError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UserNameError extends \Exception
{
}
PK(m]p���(Common/Exceptions/InvalidIpTypeError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InvalidIpTypeError extends \Exception
{
}
PK(m]�!���%Common/Exceptions/RecordTypeError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class RecordTypeError extends \Exception
{
}
PK(m]�'v۵�"Common/Exceptions/HttpUrlError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class HttpUrlError extends \Exception
{
}
PK(m]
C����'Common/Exceptions/CreateUpdateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class CreateUpdateError extends \Exception
{
}
PK(m]�s���*Common/Exceptions/ContainerDeleteError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ContainerDeleteError extends \Exception
{
}
PK(m]�DL��%Common/Exceptions/UserDeleteError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UserDeleteError extends \Exception
{
}
PK(m]+R����-Common/Exceptions/UnsupportedVersionError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UnsupportedVersionError extends \Exception
{
}
PK)m]:�Ĵ�!Common/Exceptions/NoNameError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class NoNameError extends \Exception
{
}
PK)m]���-��Common/Exceptions/UrlError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UrlError extends \Exception
{
}
PK)m]=F>S��#Common/Exceptions/DocumentError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class DocumentError extends \Exception
{
}
PK)m]�����%Common/Exceptions/ServerJsonError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ServerJsonError extends \Exception
{
}
PK)m]�'�>��!Common/Exceptions/DomainError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class DomainError extends \Exception
{
}
PK)m]ھ:���#Common/Exceptions/BaseException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class BaseException extends \Exception
{
}
PK)m]���&Common/Exceptions/RuntimeException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class RuntimeException extends \Exception
{
}
PK)m]~t�9��1Common/Exceptions/UnsupportedFeatureExtension.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UnsupportedFeatureExtension extends \Exception
{
}
PK)m]����)Common/Exceptions/InvalidRequestError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InvalidRequestError extends \Exception
{
}
PK)m]��v��$Common/Exceptions/HttpRetryError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class HttpRetryError extends \Exception
{
}
PK)m]�;Z��!Common/Exceptions/DeleteError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class DeleteError extends \Exception
{
}
PK)m]�U��%Common/Exceptions/NetworkUrlError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class NetworkUrlError extends \Exception
{
}
PK)m]�ɳͽ�*Common/Exceptions/InvalidArgumentError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InvalidArgumentError extends \Exception
{
}
PK)m]YV��(Common/Exceptions/InvalidIdTypeError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InvalidIdTypeError extends \Exception
{
}
PK)m]�5ݳ� Common/Exceptions/AsyncError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class AsyncError extends \Exception
{
}
PK)m]�Q���/Common/Exceptions/ResourceNotFoundException.phpnu&1i�<?php

namespace OpenCloud\Common\Exceptions;

use Guzzle\Http\Exception\BadResponseException;

class ResourceNotFoundException extends HttpResponseException
{
    public static function factory(BadResponseException $exception)
    {
        $response = $exception->getResponse();

        $message = sprintf(
            "This resource you were looking for could not be found; the API returned a %s status code with this message:\n%s",
            $response->getStatusCode(),
            (string) $response->getBody()
        );

        $e = new self($message);
        $e->setResponse($response);
        $e->setRequest($exception->getRequest());

        return $e;
    }
}
PK)m]��<ƻ�(Common/Exceptions/NetworkDeleteError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class NetworkDeleteError extends \Exception
{
}
PK)m]��/�� Common/Exceptions/ImageError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ImageError extends \Exception
{
}
PK)m]b3%��'Common/Exceptions/ServerUpdateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ServerUpdateError extends \Exception
{
}
PK)m]4%���$Common/Exceptions/ServerIpsError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ServerIpsError extends \Exception
{
}
PK)m]a�,^��)Common/Exceptions/InstanceUpdateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InstanceUpdateError extends \Exception
{
}
PK)m]��-u��(Common/Exceptions/ContainerNameError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ContainerNameError extends \Exception
{
}
PK)m]J�)���!Common/Exceptions/ObjectError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ObjectError extends \Exception
{
}
PK)m]��"��(Common/Exceptions/TempUrlMethodError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class TempUrlMethodError extends \Exception
{
}
PK)m]�ػw��'Common/Exceptions/DatabaseListError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class DatabaseListError extends \Exception
{
}
PK)m]�aq���)Common/Exceptions/AuthenticationError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class AuthenticationError extends \Exception
{
}
PK)m]�0����%Common/Exceptions/CredentialError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class CredentialError extends \Exception
{
}
PK)m]�|�m��$Common/Exceptions/AsyncHttpError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class AsyncHttpError extends \Exception
{
}
PK)m]���u��#Common/Exceptions/ObjFetchError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ObjFetchError extends \Exception
{
}
PK)m]��tɱ�Common/Exceptions/CdnError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class CdnError extends \Exception
{
}
PK)m]6���"Common/Exceptions/RebuildError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class RebuildError extends \Exception
{
}
PK)m]����+Common/Exceptions/HttpUnauthorizedError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class HttpUnauthorizedError extends \Exception
{
}
PK)m]q��
��'Common/Exceptions/DatabaseNameError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class DatabaseNameError extends \Exception
{
}
PK)m]CG$K��*Common/Exceptions/InvalidTemplateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InvalidTemplateError extends \Exception
{
}
PK)m]�S����/Common/Exceptions/UnsupportedExtensionError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UnsupportedExtensionError extends \Exception
{
}
PK)m]���E��Common/Exceptions/NameError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class NameError extends \Exception
{
}
PK)m]l�H��$Common/Exceptions/ContainerError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ContainerError extends \Exception
{
}
PK)m]��޶��)Common/Exceptions/MetadataUpdateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class MetadataUpdateError extends \Exception
{
}
PK)m]+y����'Common/Exceptions/MetadataJsonError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class MetadataJsonError extends \Exception
{
}
PK)m]�4��(Common/Exceptions/NetworkCreateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class NetworkCreateError extends \Exception
{
}
PK)m]I���!Common/Exceptions/CreateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class CreateError extends \Exception
{
}
PK)m]+��ռ�)Common/Exceptions/InstanceFlavorError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InstanceFlavorError extends \Exception
{
}
PK)m]���=��)Common/Exceptions/DatabaseUpdateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class DatabaseUpdateError extends \Exception
{
}
PK)m]t�'��*Common/Exceptions/ContainerCreateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ContainerCreateError extends \Exception
{
}
PK)m]�^��.Common/Exceptions/ServerImageScheduleError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ServerImageScheduleError extends \Exception
{
}
PK)m]�t����%Common/Exceptions/UserCreateError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class UserCreateError extends \Exception
{
}
PK)m] mS���!Common/Exceptions/CdnTtlError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class CdnTtlError extends \Exception
{
}
PK)m]�  ��&Common/Exceptions/ServiceException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class ServiceException extends \Exception
{
}
PK)m]	y�ڲ�Common/Exceptions/JsonError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class JsonError extends \Exception
{
}
PK)m]��xF��+Common/Exceptions/InvalidParameterError.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Exceptions;

class InvalidParameterError extends \Exception
{
}
PK)m]�H�,,Common/PersistentObject.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common;

use OpenCloud\Common\Resource\PersistentResource;

/**
 * This class is deprecated; its functionality has been split out into the following classes:
 *
 * * {@see \OpenCloud\Common\Resource\BaseResource}
 * * {@see \OpenCloud\Common\Resource\NovaResource}
 * * {@see \OpenCloud\Common\Resource\PersistentResource}
 *
 * @deprecated
 * @package OpenCloud\Common
 */
abstract class PersistentObject extends PersistentResource
{
}
PK)m]`�]cc Common/Resource/NovaResource.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Resource;

abstract class NovaResource extends PersistentResource
{
    /**
     * This method is used for many purposes, such as rebooting server, etc.
     *
     * @param $object
     * @return \Guzzle\Http\Message\Response
     * @throws \RuntimeException
     * @throws \InvalidArgumentException
     */
    protected function action($object)
    {
        if (!$this->getProperty($this->primaryKeyField())) {
            throw new \RuntimeException('A primary key is required');
        }

        if (!is_object($object)) {
            throw new \InvalidArgumentException(sprintf('This method expects an object as its parameter'));
        }

        // convert the object to json
        $json = json_encode($object);
        $this->checkJsonError();

        // get the URL for the POST message
        $url = clone $this->getUrl();
        $url->addPath('action');

        // POST the message
        return $this->getClient()->post($url, self::getJsonHeader(), $json)->send();
    }
}
PK)m]l��UU$Common/Resource/ReadOnlyResource.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Resource;

/**
 * Represents a read-only resource: one that cannot be created, updated
 * or deleted.
 *
 * @package OpenCloud\Common\Resource
 */
abstract class ReadOnlyResource extends PersistentResource
{
    public function create($params = array())
    {
        return $this->noCreate();
    }

    public function update($params = array())
    {
        return $this->noUpdate();
    }

    public function delete()
    {
        return $this->noDelete();
    }
}
PK)m]�@��Common/Resource/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m]?V(y		 Common/Resource/BaseResource.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Resource;

use Guzzle\Http\Message\Response;
use Guzzle\Http\Url;
use OpenCloud\Common\Base;
use OpenCloud\Common\Exceptions\DocumentError;
use OpenCloud\Common\Exceptions\ServiceException;
use OpenCloud\Common\Exceptions\UrlError;
use OpenCloud\Common\Metadata;
use OpenCloud\Common\Service\ServiceInterface;
use OpenCloud\Common\Http\Message\Formatter;

abstract class BaseResource extends Base
{
    /** @var \OpenCloud\Common\Service\ServiceInterface */
    protected $service;

    /** @var BaseResource */
    protected $parent;

    /** @var \OpenCloud\Common\Metadata */
    protected $metadata;

    /**
     * @param ServiceInterface $service The service that this resource belongs to
     * @param $data $data
     */
    public function __construct(ServiceInterface $service, $data = null)
    {
        $this->setService($service);
        $this->metadata = new Metadata();
        $this->populate($data);
    }

    /**
     * @param \OpenCloud\Common\Service\ServiceInterface $service
     * @return \OpenCloud\Common\PersistentObject
     */
    public function setService(ServiceInterface $service)
    {
        $this->service = $service;

        return $this;
    }

    /**
     * @return \OpenCloud\Common\Service\ServiceInterface
     * @throws \OpenCloud\Common\Exceptions\ServiceException
     */
    public function getService()
    {
        if (null === $this->service) {
            throw new ServiceException('No service defined');
        }

        return $this->service;
    }

    /**
     * @param BaseResource $parent
     * @return self
     */
    public function setParent(BaseResource $parent)
    {
        $this->parent = $parent;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getParent()
    {
        if (null === $this->parent) {
            $this->parent = $this->getService();
        }

        return $this->parent;
    }

    /**
     * Convenience method to return the service's client
     *
     * @return \Guzzle\Http\ClientInterface
     */
    public function getClient()
    {
        return $this->getService()->getClient();
    }

    /**
     * @param mixed $metadata
     * @return $this
     */
    public function setMetadata($data)
    {
        if ($data instanceof Metadata) {
            $metadata = $data;
        } elseif (is_array($data) || is_object($data)) {
            $metadata = new Metadata();
            $metadata->setArray($data);
        } else {
            throw new \InvalidArgumentException(sprintf(
                'You must specify either an array/object of parameters, or an '
                . 'instance of Metadata. You provided: %s',
                print_r($data, true)
            ));
        }

        $this->metadata = $metadata;

        return $this;
    }

    /**
     * @return Metadata
     */
    public function getMetadata()
    {
        return $this->metadata;
    }

    /**
     * Get this resource's URL
     *
     * @param null  $path   URI path to add on
     * @param array $query  Query to add on
     * @return mixed
     */
    public function getUrl($path = null, array $query = array())
    {
        if (!$url = $this->findLink('self')) {
            // ...otherwise construct a URL from parent and this resource's
            // "URL name". If no name is set, resourceName() throws an error.
            $url = $this->getParent()->getUrl($this->resourceName());

            // Does it have a primary key?
            if (null !== ($primaryKey = $this->getProperty($this->primaryKeyField()))) {
                $url->addPath((string) $primaryKey);
            }
        }

        if (!$url instanceof Url) {
            $url = Url::factory($url);
        }

        return $url->addPath((string) $path)->setQuery($query);
    }

    /**
     * @deprecated
     */
    public function url($path = null, array $query = array())
    {
        return $this->getUrl($path, $query);
    }


    /**
     * Find a resource link based on a type
     *
     * @param string $type
     * @return bool
     */
    public function findLink($type = 'self')
    {
        if (empty($this->links)) {
            return false;
        }

        foreach ($this->links as $link) {
            if ($link->rel == $type) {
                return $link->href;
            }
        }

        return false;
    }

    /**
     * Returns the primary key field for the object
     *
     * @return string
     */
    protected function primaryKeyField()
    {
        return 'id';
    }

    /**
     * Returns the top-level key for the returned response JSON document
     *
     * @throws DocumentError
     */
    public static function jsonName()
    {
        if (isset(static::$json_name)) {
            return static::$json_name;
        }

        throw new DocumentError('A top-level JSON document key has not been defined for this resource');
    }

    /**
     * Returns the top-level key for collection responses
     *
     * @return string
     */
    public static function jsonCollectionName()
    {
        return isset(static::$json_collection_name) ? static::$json_collection_name : static::$json_name . 's';
    }

    /**
     * Returns the nested keys that could (rarely) prefix collection items. For example:
     *
     * {
     *    "keypairs": [
     *       {
     *          "keypair": {
     *              "fingerprint": "...",
     *              "name": "key1",
     *              "public_key": "..."
     *          }
     *       },
     *       {
     *          "keypair": {
     *              "fingerprint": "...",
     *              "name": "key2",
     *              "public_key": "..."
     *          }
     *       }
     *    ]
     * }
     *
     * In the above example, "keypairs" would be the $json_collection_name and "keypair" would be the
     * $json_collection_element
     *
     * @return string
     */
    public static function jsonCollectionElement()
    {
        if (isset(static::$json_collection_element)) {
            return static::$json_collection_element;
        }
    }

    /**
     * Returns the URI path for this resource
     *
     * @throws UrlError
     */
    public static function resourceName()
    {
        if (isset(static::$url_resource)) {
            return static::$url_resource;
        }

        throw new UrlError('No URL path defined for this resource');
    }

    /**
     * Parse a HTTP response for the required content
     *
     * @param Response $response
     * @return mixed
     */
    public function parseResponse(Response $response)
    {
        $document = Formatter::decode($response);

        $topLevelKey = $this->jsonName();

        return ($topLevelKey && isset($document->$topLevelKey)) ? $document->$topLevelKey : $document;
    }
}
PK)m]9f(++++&Common/Resource/PersistentResource.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Common\Resource;

use Guzzle\Http\Url;
use OpenCloud\Common\Constants\State;
use OpenCloud\Common\Exceptions\CreateError;
use OpenCloud\Common\Exceptions\DeleteError;
use OpenCloud\Common\Exceptions\IdRequiredError;
use OpenCloud\Common\Exceptions\NameError;
use OpenCloud\Common\Exceptions\UnsupportedExtensionError;
use OpenCloud\Common\Exceptions\UpdateError;

abstract class PersistentResource extends BaseResource
{
    /**
     * Create a new resource
     *
     * @param array $params
     * @return \Guzzle\Http\Message\Response
     */
    public function create($params = array())
    {
        // set parameters
        if (!empty($params)) {
            $this->populate($params, false);
        }

        // construct the JSON
        $json = json_encode($this->createJson());
        $this->checkJsonError();

        $createUrl = $this->createUrl();

        $response = $this->getClient()->post($createUrl, self::getJsonHeader(), $json)->send();

        // We have to try to parse the response body first because it should have precedence over a Location refresh.
        // I'd like to reverse the order, but Nova instances return ephemeral properties on creation which are not
        // available when you follow the Location link...
        if (null !== ($decoded = $this->parseResponse($response))) {
            $this->populate($decoded);
        } elseif ($location = $response->getHeader('Location')) {
            $this->refreshFromLocationUrl($location);
        }

        return $response;
    }

    /**
     * Update a resource
     *
     * @param array $params
     * @return \Guzzle\Http\Message\Response
     */
    public function update($params = array())
    {
        // set parameters
        if (!empty($params)) {
            $this->populate($params);
        }

        // construct the JSON
        $json = json_encode($this->updateJson($params));
        $this->checkJsonError();

        // send the request
        return $this->getClient()->put($this->getUrl(), self::getJsonHeader(), $json)->send();
    }

    /**
     * Delete this resource
     *
     * @return \Guzzle\Http\Message\Response
     */
    public function delete()
    {
        return $this->getClient()->delete($this->getUrl())->send();
    }

    /**
     * Refresh the state of a resource
     *
     * @param null $id
     * @param null $url
     * @return \Guzzle\Http\Message\Response
     * @throws IdRequiredError
     */
    public function refresh($id = null, $url = null)
    {
        $primaryKey = $this->primaryKeyField();
        $primaryKeyVal = $this->getProperty($primaryKey);

        if (!$url) {
            if (!$id = $id ?: $primaryKeyVal) {
                $message = sprintf("This resource cannot be refreshed because it has no %s", $primaryKey);
                throw new IdRequiredError($message);
            }

            if ($primaryKeyVal != $id) {
                $this->setProperty($primaryKey, $id);
            }

            $url = $this->getUrl();
        }

        // reset status, if available
        if ($this->getProperty('status')) {
            $this->setProperty('status', null);
        }

        $response = $this->getClient()->get($url)->send();

        if (null !== ($decoded = $this->parseResponse($response))) {
            $this->populate($decoded);
        }

        return $response;
    }


    /**
     * Causes resource to refresh based on parent's URL
     */
    protected function refreshFromParent()
    {
        $url = clone $this->getParent()->getUrl();
        $url->addPath($this->resourceName());

        $response = $this->getClient()->get($url)->send();

        if (null !== ($decoded = $this->parseResponse($response))) {
            $this->populate($decoded);
        }
    }

    /**
     * Given a `location` URL, refresh this resource
     *
     * @param $url
     */
    public function refreshFromLocationUrl($url)
    {
        $fullUrl = Url::factory($url);

        $response = $this->getClient()->get($fullUrl)->send();

        if (null !== ($decoded = $this->parseResponse($response))) {
            $this->populate($decoded);
        }
    }

    /**
     * A method to repeatedly poll the API resource, waiting for an eventual state change
     *
     * @param null $state    The expected state of the resource
     * @param null $timeout  The maximum timeout to wait
     * @param null $callback The callback to use to check the state
     * @param null $interval How long between each refresh request
     */
    public function waitFor($state = null, $timeout = null, $callback = null, $interval = null)
    {
        $state    = $state ?: State::ACTIVE;
        $timeout  = $timeout ?: State::DEFAULT_TIMEOUT;
        $interval = $interval ?: State::DEFAULT_INTERVAL;

        // save stats
        $startTime = time();

        $states = array('ERROR', $state);

        while (true) {
            $this->refresh($this->getProperty($this->primaryKeyField()));

            if ($callback) {
                call_user_func($callback, $this);
            }

            if (in_array($this->status(), $states) || (time() - $startTime) > $timeout) {
                return;
            }

            sleep($interval);
        }
    }

    /**
     * Provides JSON for create request body
     *
     * @return object
     * @throws \RuntimeException
     */
    protected function createJson()
    {
        if (!isset($this->createKeys)) {
            throw new \RuntimeException(sprintf(
                'This resource object [%s] must have a visible createKeys array',
                get_class($this)
            ));
        }

        $element = (object) array();

        foreach ($this->createKeys as $key) {
            if (null !== ($property = $this->getProperty($key))) {
                $element->{$this->getAlias($key)} = $this->recursivelyAliasPropertyValue($property);
            }
        }

        if (isset($this->metadata) && count($this->metadata)) {
            $element->metadata = (object) $this->metadata->toArray();
        }

        return (object) array($this->jsonName() => (object) $element);
    }

    /**
     * Returns the alias configured for the given key. If no alias exists
     * it returns the original key.
     *
     * @param  string $key
     * @return string
     */
    protected function getAlias($key)
    {
        if (false !== ($alias = array_search($key, $this->aliases))) {
            return $alias;
        }

        return $key;
    }

    /**
     * Returns the given property value's alias, if configured; Else, the
     * unchanged property value is returned. If the given property value
     * is an array or an instance of \stdClass, it is aliases recursively.
     *
     * @param  mixed $propertyValue Array or \stdClass instance to alias
     * @return mixed Property value, aliased recursively
     */
    protected function recursivelyAliasPropertyValue($propertyValue)
    {
        if (is_array($propertyValue)) {
            foreach ($propertyValue as $key => $subValue) {
                $aliasedSubValue = $this->recursivelyAliasPropertyValue($subValue);
                if (is_numeric($key)) {
                    $propertyValue[$key] = $aliasedSubValue;
                } else {
                    unset($propertyValue[$key]);
                    $propertyValue[$this->getAlias($key)] = $aliasedSubValue;
                }
            }
        } elseif (is_object($propertyValue) && ($propertyValue instanceof \stdClass)) {
            foreach ($propertyValue as $key => $subValue) {
                unset($propertyValue->$key);
                $propertyValue->{$this->getAlias($key)} = $this->recursivelyAliasPropertyValue($subValue);
            }
        }

        return $propertyValue;
    }

    /**
     * Provides JSON for update request body
     */
    protected function updateJson($params = array())
    {
        if (!isset($this->updateKeys)) {
            throw new \RuntimeException(sprintf(
                'This resource object [%s] must have a visible updateKeys array',
                get_class($this)
            ));
        }

        $element = (object) array();

        foreach ($this->updateKeys as $key) {
            if (null !== ($property = $this->getProperty($key))) {
                $element->{$this->getAlias($key)} = $this->recursivelyAliasPropertyValue($property);
            }
        }

        return (object) array($this->jsonName() => (object) $element);
    }

    /**
     * @throws CreateError
     */
    protected function noCreate()
    {
        throw new CreateError('This resource does not support the create operation');
    }

    /**
     * @throws DeleteError
     */
    protected function noDelete()
    {
        throw new DeleteError('This resource does not support the delete operation');
    }

    /**
     * @throws UpdateError
     */
    protected function noUpdate()
    {
        throw new UpdateError('his resource does not support the update operation');
    }

    /**
     * Check whether an extension is valid
     *
     * @param mixed $alias The extension name
     * @return bool
     * @throws UnsupportedExtensionError
     */
    public function checkExtension($alias)
    {
        if (!in_array($alias, $this->getService()->namespaces())) {
            throw new UnsupportedExtensionError(sprintf("%s extension is not installed", $alias));
        }

        return true;
    }

    /********  DEPRECATED METHODS ********/

    /**
     * @deprecated
     * @return string
     * @throws NameError
     */
    public function name()
    {
        if (null !== ($name = $this->getProperty('name'))) {
            return $name;
        } else {
            throw new NameError('Name attribute does not exist for this resource');
        }
    }

    /**
     * @deprecated
     * @return mixed
     */
    public function id()
    {
        return $this->id;
    }

    /**
     * @deprecated
     * @return string
     */
    public function status()
    {
        return (isset($this->status)) ? $this->status : 'N/A';
    }

    /**
     * @deprecated
     * @return mixed
     */
    public function region()
    {
        return $this->getService()->region();
    }

    /**
     * @deprecated
     * @return \Guzzle\Http\Url
     */
    public function createUrl()
    {
        return $this->getParent()->getUrl($this->resourceName());
    }
}
PK)m]+��
Rackspace.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud;

use OpenCloud\Common\Exceptions\CredentialError;
use OpenCloud\Common\Service\ServiceBuilder;

/**
 * Rackspace extends the OpenStack class with support for Rackspace's
 * API key and tenant requirements.
 *
 * The only difference between Rackspace and OpenStack is that the
 * Rackspace class generates credentials using the username
 * and API key, as required by the Rackspace authentication
 * service.
 *
 * Example:
 * <pre><code>
 * $client = new Rackspace(
 *      'https://identity.api.rackspacecloud.com/v2.0/',
 *      array(
 *          'username' => 'FRED',
 *          'apiKey'   => '0900af093093788912388fc09dde090ffee09'
 *      )
 * );
 * </code></pre>
 */
class Rackspace extends OpenStack
{
    const US_IDENTITY_ENDPOINT = 'https://identity.api.rackspacecloud.com/v2.0/';
    const UK_IDENTITY_ENDPOINT = 'https://lon.identity.api.rackspacecloud.com/v2.0/';

    /**
     * Generates Rackspace API key credentials
     * {@inheritDoc}
     */
    public function getCredentials()
    {
        $secret = $this->getSecret();

        if (!empty($secret['username']) && !empty($secret['apiKey'])) {
            $credentials = array('auth' => array(
                'RAX-KSKEY:apiKeyCredentials' => array(
                    'username' => $secret['username'],
                    'apiKey'   => $secret['apiKey']
                )
            ));

            if (!empty($secret['tenantName'])) {
                $credentials['auth']['tenantName'] = $secret['tenantName'];
            } elseif (!empty($secret['tenantId'])) {
                $credentials['auth']['tenantId'] = $secret['tenantId'];
            }

            return json_encode($credentials);
        } else {
            throw new CredentialError('Unrecognized credential secret');
        }
    }

    /**
     * Creates a new Database service. Note: this is a Rackspace-only feature.
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\Database\Service
     */
    public function databaseService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\Database\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new Load Balancer service. Note: this is a Rackspace-only feature.
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\LoadBalancer\Service
     */
    public function loadBalancerService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\LoadBalancer\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new DNS service. Note: this is a Rackspace-only feature.
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return OpenCloud\DNS\Service
     */
    public function dnsService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\DNS\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new CloudMonitoring service. Note: this is a Rackspace-only feature.
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\CloudMonitoring\Service
     */
    public function cloudMonitoringService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\CloudMonitoring\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new CloudQueues service. Note: this is a Rackspace-only feature.
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\Autoscale\Service
     */
    public function autoscaleService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\Autoscale\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new CloudQueues service. Note: this is a Rackspace-only feature.
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\Queues\Service
     */
    public function queuesService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\Queues\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }
}
PK)m]�F;�VVObjectStore/Enum/ReturnType.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Enum;

/**
 * Enumerated types for return types
 *
 * @package OpenCloud\ObjectStore\Enum
 */
class ReturnType
{
    const RESPONSE_ARRAY = 'RESPONSE_ARRAY';
    const DATA_OBJECT_ARRAY = 'DATA_OBJECT_ARRAY';
}
PK)m]�@��ObjectStore/Enum/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m]f۸�� ObjectStore/Constants/Header.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Constants;

/**
 * Constants for different request and metadata headers.
 */
class Header
{
    const OBJECT_COUNT = 'Object-Count';
    const BYTES_USED = 'Bytes-Used';
    const ACCESS_LOGS = 'Access-Log-Delivery';

    const TRANS_ID = 'Trans-Id';
    const ENABLED = 'Enabled';
    const LOG_RETENTION = 'Log-Retention';
}
PK)m]�@��ObjectStore/Constants/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m]񴌑��!ObjectStore/Constants/UrlType.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Constants;

/**
 * Enumerated constants used in CloudFiles for URL types.
 */
class UrlType
{
    const CDN = 'CDN';
    const SSL = 'SSL';
    const STREAMING = 'Streaming';
    const IOS_STREAMING = 'IOS-Streaming';

    const TAR = 'tar';
    const TAR_GZ = 'tar.gz';
    const TAR_BZ2 = 'tar.bz2';
}
PK)m]9�y�**'ObjectStore/Upload/AbstractTransfer.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Upload;

use Exception;
use Guzzle\Http\EntityBody;
use OpenCloud\Common\Exceptions\RuntimeException;
use OpenCloud\Common\Http\Client;
use OpenCloud\ObjectStore\Exception\UploadException;

/**
 * Contains abstract functionality for transfer objects.
 */
class AbstractTransfer
{
    /**
     * Minimum chunk size is 1MB.
     */
    const MIN_PART_SIZE = 1048576;

    /**
     * Maximum chunk size is 5GB.
     */
    const MAX_PART_SIZE = 5368709120;

    /**
     * Default chunk size is 1GB.
     */
    const DEFAULT_PART_SIZE = 1073741824;

    /**
     * @var \OpenCloud\Common\Http\Client The client object which handles all HTTP interactions
     */
    protected $client;

    /**
     * @var \Guzzle\Http\EntityBody The payload being transferred
     */
    protected $entityBody;

    /**
     * The current state of the transfer responsible for, among other things, holding an itinerary of uploaded parts
     *
     * @var \OpenCloud\ObjectStore\Upload\TransferState
     */
    protected $transferState;

    /**
     * @var array User-defined key/pair options
     */
    protected $options;

    /**
     * @var int
     */
    protected $partSize;

    /**
     * @var array Defaults that will always override user-defined options
     */
    protected $defaultOptions = array(
        'concurrency'    => true,
        'partSize'       => self::DEFAULT_PART_SIZE,
        'prefix'         => 'segment',
        'doPartChecksum' => true
    );

    /**
     * @return static
     */
    public static function newInstance()
    {
        return new static();
    }

    /**
     * @param Client $client
     * @return $this
     */
    public function setClient(Client $client)
    {
        $this->client = $client;

        return $this;
    }

    /**
     * @param EntityBody $entityBody
     * @return $this
     */
    public function setEntityBody(EntityBody $entityBody)
    {
        $this->entityBody = $entityBody;

        return $this;
    }

    /**
     * @param TransferState $transferState
     * @return $this
     */
    public function setTransferState(TransferState $transferState)
    {
        $this->transferState = $transferState;

        return $this;
    }

    /**
     * @return array
     */
    public function getOptions()
    {
        return $this->options;
    }

    /**
     * @param $options
     * @return $this
     */
    public function setOptions($options)
    {
        $this->options = $options;

        return $this;
    }

    /**
     * @param $option The key being updated
     * @param $value  The option's value
     * @return $this
     */
    public function setOption($option, $value)
    {
        $this->options[$option] = $value;

        return $this;
    }

    public function getPartSize()
    {
        return $this->partSize;
    }

    /**
     * @return $this
     */
    public function setup()
    {
        $this->options = array_merge($this->defaultOptions, $this->options);
        $this->partSize = $this->validatePartSize();

        return $this;
    }

    /**
     * Make sure the part size falls within a valid range
     *
     * @return mixed
     */
    protected function validatePartSize()
    {
        $min = min($this->options['partSize'], self::MAX_PART_SIZE);

        return max($min, self::MIN_PART_SIZE);
    }

    /**
     * Initiates the upload procedure.
     *
     * @return \Guzzle\Http\Message\Response
     * @throws RuntimeException If the transfer is not in a "running" state
     * @throws UploadException  If any errors occur during the upload
     * @codeCoverageIgnore
     */
    public function upload()
    {
        if (!$this->transferState->isRunning()) {
            throw new RuntimeException('The transfer has been aborted.');
        }

        try {
            $this->transfer();
            $response = $this->createManifest();
        } catch (Exception $e) {
            throw new UploadException($this->transferState, $e);
        }

        return $response;
    }

    /**
     * With large uploads, you must create a manifest file. Although each segment or TransferPart remains
     * individually addressable, the manifest file serves as the unified file (i.e. the 5GB download) which, when
     * retrieved, streams all the segments concatenated.
     *
     * @link http://docs.rackspace.com/files/api/v1/cf-devguide/content/Large_Object_Creation-d1e2019.html
     * @return \Guzzle\Http\Message\Response
     * @codeCoverageIgnore
     */
    private function createManifest()
    {
        $parts = array();

        foreach ($this->transferState as $part) {
            $parts[] = (object) array(
                'path'       => $part->getPath(),
                'etag'       => $part->getETag(),
                'size_bytes' => $part->getContentLength()
            );
        }

        $headers = array(
            'Content-Length'    => 0,
            'X-Object-Manifest' => sprintf('%s/%s/%s/',
                $this->options['containerName'],
                $this->options['objectName'],
                $this->options['prefix']
            )
        );

        $url = clone $this->options['containerUrl'];
        $url->addPath($this->options['objectName']);

        return $this->client->put($url, $headers)->send();
    }
}
PK)m]�@��ObjectStore/Upload/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m]��Y�GG)ObjectStore/Upload/ContainerMigration.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Upload;

use Guzzle\Batch\BatchBuilder;
use Guzzle\Common\Collection;
use Guzzle\Http\Message\Response;
use Guzzle\Http\Url;
use OpenCloud\ObjectStore\Resource\Container;

/**
 * Class responsible for migrating the contents of one container to another
 *
 * @package OpenCloud\ObjectStore\Upload
 */
class ContainerMigration
{
    /** @var \Guzzle\Batch\Batch */
    protected $readQueue;

    /** @var \Guzzle\Batch\Batch */
    protected $writeQueue;

    /** @var \OpenCloud\ObjectStore\Resource\Container */
    protected $oldContainer;

    /** @var \OpenCloud\ObjectStore\Resource\Container */
    protected $newContainer;

    /** @var \Guzzle\Common\Collection */
    protected $options = array();

    protected $defaults = array(
        'read.batchLimit'  => 1000,
        'read.pageLimit'   => 10000,
        'write.batchLimit' => 100
    );

    /**
     * @param Container $old     Source container
     * @param Container $new     Target container
     * @param array     $options Options that configure process
     * @return ContainerMigration
     */
    public static function factory(Container $old, Container $new, array $options = array())
    {
        $migration = new self();

        $migration->setOldContainer($old);
        $migration->setNewContainer($new);
        $migration->setOptions($options);

        $migration->setupReadQueue();
        $migration->setupWriteQueue();

        return $migration;
    }

    /**
     * @param Container $old
     */
    public function setOldContainer(Container $old)
    {
        $this->oldContainer = $old;
    }

    /**
     * @return Container
     */
    public function getOldContainer()
    {
        return $this->oldContainer;
    }

    /**
     * @param Container $new
     */
    public function setNewContainer(Container $new)
    {
        $this->newContainer = $new;
    }

    /**
     * @return Container
     */
    public function getNewContainer()
    {
        return $this->newContainer;
    }

    /**
     * @param array $options
     */
    public function setOptions(array $options)
    {
        $this->options = Collection::fromConfig($options, $this->defaults);
    }

    /**
     * @return \Guzzle\Common\Collection
     */
    public function getOptions()
    {
        return $this->options;
    }

    /**
     * Set the read queue as a {@see \Guzzle\Batch\Batch} queue using the {@see \Guzzle\Batch\BatchBuilder}
     */
    public function setupReadQueue()
    {
        $this->readQueue = BatchBuilder::factory()
            ->transferRequests($this->options->get('read.batchLimit'))
            ->build();
    }

    /**
     * Set the write queue as a {@see \Guzzle\Batch\Batch} queue using the {@see \Guzzle\Batch\BatchBuilder}
     */
    public function setupWriteQueue()
    {
        $this->writeQueue = BatchBuilder::factory()
            ->transferRequests($this->options->get('write.batchLimit'))
            ->build();
    }

    /**
     * @return \Guzzle\Http\ClientInterface
     */
    private function getClient()
    {
        return $this->newContainer->getService()->getClient();
    }

    /**
     * Create a collection of files to be migrated and add them to the read queue
     */
    protected function enqueueGetRequests()
    {
        $files = $this->oldContainer->objectList(array(
            'limit.total' => false,
            'limit.page'  => $this->options->get('read.pageLimit')
        ));

        foreach ($files as $file) {
            $this->readQueue->add(
                $this->getClient()->get($file->getUrl())
            );
        }
    }

    /**
     * Send the read queue (in order to gather more information about individual files)
     *
     * @return array Responses
     */
    protected function sendGetRequests()
    {
        $this->enqueueGetRequests();

        return $this->readQueue->flush();
    }

    /**
     * Create a tailored PUT request for each file
     *
     * @param Response $response
     * @return \Guzzle\Http\Message\EntityEnclosingRequestInterface
     */
    protected function createPutRequest(Response $response)
    {
        $segments = Url::factory($response->getEffectiveUrl())->getPathSegments();
        $name = end($segments);

        // Retrieve content and metadata
        $file = $this->newContainer->dataObject()->setName($name);
        $file->setMetadata($response->getHeaders(), true);

        return $this->getClient()->put(
            $file->getUrl(),
            $file::stockHeaders($file->getMetadata()->toArray()),
            $response->getBody()
        );
    }

    /**
     * Initiate the transfer process
     *
     * @return array PUT responses
     */
    public function transfer()
    {
        $requests = $this->sendGetRequests();
        $this->readQueue = null;

        foreach ($requests as $key => $request) {
            $this->writeQueue->add(
                $this->createPutRequest($request->getResponse())
            );
            unset($requests[$key]);
        }

        return $this->writeQueue->flush();
    }
}
PK)m]J$�]��#ObjectStore/Upload/TransferPart.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Upload;

use Guzzle\Http\Message\Response;
use Guzzle\Http\Url;
use OpenCloud\Common\Constants\Header;

/**
 * Represents an individual part of the EntityBody being uploaded.
 *
 * @codeCoverageIgnore
 */
class TransferPart
{
    /**
     * @var int Its position in the upload queue.
     */
    protected $partNumber;

    /**
     * @var string This upload's ETag checksum.
     */
    protected $eTag;

    /**
     * @var int The length of this upload in bytes.
     */
    protected $contentLength;

    /**
     * @var string The API path of this upload.
     */
    protected $path;

    /**
     * @param int $contentLength
     * @return $this
     */
    public function setContentLength($contentLength)
    {
        $this->contentLength = $contentLength;

        return $this;
    }

    /**
     * @return int
     */
    public function getContentLength()
    {
        return $this->contentLength;
    }

    /**
     * @param  string $etag
     * @return $this
     */
    public function setETag($etag)
    {
        $this->etag = $etag;

        return $this;
    }

    /**
     * @return string
     */
    public function getETag()
    {
        return $this->etag;
    }

    /**
     * @param int $partNumber
     * @return $this
     */
    public function setPartNumber($partNumber)
    {
        $this->partNumber = $partNumber;

        return $this;
    }

    /**
     * @return int
     */
    public function getPartNumber()
    {
        return $this->partNumber;
    }

    /**
     * @param $path
     * @return $this
     */
    public function setPath($path)
    {
        $this->path = $path;

        return $this;
    }

    /**
     * @return string
     */
    public function getPath()
    {
        return $this->path;
    }

    /**
     * Create the request needed for this upload to the API.
     *
     * @param EntityBody $part    The entity body being uploaded
     * @param int        $number  Its number/position, needed for name
     * @param OpenStack  $client  Client responsible for issuing requests
     * @param array      $options Set by the Transfer object
     * @return OpenCloud\Common\Http\Request
     */
    public static function createRequest($part, $number, $client, $options)
    {
        $name = sprintf('%s/%s/%d', $options['objectName'], $options['prefix'], $number);
        $url = clone $options['containerUrl'];
        $url->addPath($name);

        $headers = array(
            Header::CONTENT_LENGTH => $part->getContentLength(),
            Header::CONTENT_TYPE   => $part->getContentType()
        );

        if ($options['doPartChecksum'] === true) {
            $headers['ETag'] = $part->getContentMd5();
        }

        $request = $client->put($url, $headers, $part);

        if (isset($options['progress'])) {
            $request->getCurlOptions()->add('progress', true);
            if (is_callable($options['progress'])) {
                $request->getCurlOptions()->add('progressCallback', $options['progress']);
            }
        }

        return $request;
    }

    /**
     * Construct a TransferPart from a HTTP response delivered by the API.
     *
     * @param Response $response
     * @param int      $partNumber
     * @return TransferPart
     */
    public static function fromResponse(Response $response, $partNumber = 1)
    {
        $responseUri = Url::factory($response->getEffectiveUrl());

        $object = new self();

        $object->setPartNumber($partNumber)
            ->setContentLength($response->getHeader(Header::CONTENT_LENGTH))
            ->setETag($response->getHeader(Header::ETAG))
            ->setPath($responseUri->getPath());

        return $object;
    }
}
PK)m]f��		*ObjectStore/Upload/ConsecutiveTransfer.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Upload;

use Guzzle\Http\EntityBody;
use Guzzle\Http\ReadLimitEntityBody;
use OpenCloud\Common\Constants\Size;

/**
 * A transfer type which executes consecutively - i.e. it will upload an entire EntityBody and then move on to the next
 * in a linear fashion. There is no concurrency here.
 *
 * @codeCoverageIgnore
 */
class ConsecutiveTransfer extends AbstractTransfer
{
    public function transfer()
    {
        while (!$this->entityBody->isConsumed()) {
            if ($this->entityBody->getContentLength() && $this->entityBody->isSeekable()) {
                // Stream directly from the data
                $body = new ReadLimitEntityBody($this->entityBody, $this->partSize, $this->entityBody->ftell());
            } else {
                // If not-seekable, read the data into a new, seekable "buffer"
                $body = EntityBody::factory();
                $output = true;
                while ($body->getContentLength() < $this->partSize && $output !== false) {
                    // Write maximum of 10KB at a time
                    $length = min(10 * Size::KB, $this->partSize - $body->getContentLength());
                    $output = $body->write($this->entityBody->read($length));
                }
            }

            if ($body->getContentLength() == 0) {
                break;
            }

            $request = TransferPart::createRequest(
                $body,
                $this->transferState->count() + 1,
                $this->client,
                $this->options
            );

            $response = $request->send();

            $this->transferState->addPart(TransferPart::fromResponse($response));
        }
    }
}
PK)m]X]�l@@$ObjectStore/Upload/DirectorySync.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Upload;

use DirectoryIterator;
use Guzzle\Http\EntityBody;
use OpenCloud\Common\Collection\ResourceIterator;
use OpenCloud\Common\Exceptions\InvalidArgumentError;
use OpenCloud\ObjectStore\Resource\Container;

/**
 * DirectorySync upload class, in charge of creating, replacing and delete data objects on the API. The goal of
 * this execution is to sync local directories with remote CloudFiles containers so that they are consistent.
 *
 * @package OpenCloud\ObjectStore\Upload
 */
class DirectorySync
{
    /**
     * @var string The path to the directory you're syncing.
     */
    private $basePath;
    /**
     * @var ResourceIterator A collection of remote files in Swift.
     */
    private $remoteFiles;
    /**
     * @var AbstractContainer The Container object you are syncing.
     */
    private $container;

    /**
     * Basic factory method to instantiate a new DirectorySync object with all the appropriate properties.
     *
     * @param           $path      The local path
     * @param Container $container The container you're syncing
     * @return DirectorySync
     */
    public static function factory($path, Container $container)
    {
        $transfer = new self();
        $transfer->setBasePath($path);
        $transfer->setContainer($container);
        $transfer->setRemoteFiles($container->objectList());

        return $transfer;
    }

    /**
     * @param $path
     * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
     */
    public function setBasePath($path)
    {
        if (!file_exists($path)) {
            throw new InvalidArgumentError(sprintf('%s does not exist', $path));
        }

        $this->basePath = $path;
    }

    /**
     * @param ResourceIterator $remoteFiles
     */
    public function setRemoteFiles(ResourceIterator $remoteFiles)
    {
        $this->remoteFiles = $remoteFiles;
    }

    /**
     * @param Container $container
     */
    public function setContainer(Container $container)
    {
        $this->container = $container;
    }

    /**
     * Execute the sync process. This will collect all the remote files from the API and do a comparison. There are
     * four scenarios that need to be dealt with:
     *
     * - Exists locally, exists remotely (identical checksum) = no action
     * - Exists locally, exists remotely (diff checksum) = local overwrites remote
     * - Exists locally, not exists remotely = local is written to remote
     * - Not exists locally, exists remotely = remote file is deleted
     */
    public function execute()
    {
        $localFiles = $this->traversePath($this->basePath);

        $this->remoteFiles->rewind();
        $this->remoteFiles->populateAll();

        $entities = array();
        $requests = array();
        $deletePaths = array();

        // Handle PUT requests (create/update files)
        foreach ($localFiles as $filename) {
            $callback = $this->getCallback($filename);
            $filePath = rtrim($this->basePath, '/') . '/' . $filename;

            if (!is_readable($filePath)) {
                continue;
            }

            $entities[] = $entityBody = EntityBody::factory(fopen($filePath, 'r+'));

            if (false !== ($remoteFile = $this->remoteFiles->search($callback))) {
                // if different, upload updated version
                if ($remoteFile->getEtag() != $entityBody->getContentMd5()) {
                    $requests[] = $this->container->getClient()->put(
                        $remoteFile->getUrl(),
                        $remoteFile->getMetadata()->toArray(),
                        $entityBody
                    );
                }
            } else {
                // upload new file
                $url = clone $this->container->getUrl();
                $url->addPath($filename);

                $requests[] = $this->container->getClient()->put($url, array(), $entityBody);
            }
        }

        // Handle DELETE requests
        foreach ($this->remoteFiles as $remoteFile) {
            $remoteName = $remoteFile->getName();
            if (!in_array($remoteName, $localFiles)) {
                $deletePaths[] = sprintf('/%s/%s', $this->container->getName(), $remoteName);
            }
        }

        // send update/create requests
        if (count($requests)) {
            $this->container->getClient()->send($requests);
        }

        // bulk delete
        if (count($deletePaths)) {
            $this->container->getService()->bulkDelete($deletePaths);
        }

        // close all streams
        if (count($entities)) {
            foreach ($entities as $entity) {
                $entity->close();
            }
        }
    }

    /**
     * Given a path, traverse it recursively for nested files.
     *
     * @param $path
     * @return array
     */
    private function traversePath($path)
    {
        $filenames = array();

        $directory = new DirectoryIterator($path);

        foreach ($directory as $file) {
            if ($file->isDot()) {
                continue;
            }
            if ($file->isDir()) {
                $filenames = array_merge($filenames, $this->traversePath($file->getPathname()));
            } else {
                $filenames[] = $this->trimFilename($file);
            }
        }

        return $filenames;
    }

    /**
     * Given a path, trim away leading slashes and strip the base path.
     *
     * @param $file
     * @return string
     */
    private function trimFilename($file)
    {
        return ltrim(str_replace($this->basePath, '', $file->getPathname()), '/');
    }

    /**
     * Get the callback used to do a search function on the remote iterator.
     *
     * @param $name     The name of the file we're looking for.
     * @return callable
     */
    private function getCallback($name)
    {
        $name = trim($name, '/');

        return function ($remoteFile) use ($name) {
            if ($remoteFile->getName() == $name) {
                return true;
            }

            return false;
        };
    }
}
PK)m]Kf����$ObjectStore/Upload/TransferState.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Upload;

/**
 * Represents the current state of the Transfer.
 *
 * @codeCoverageIgnore
 */
class TransferState
{
    /**
     * @var array Holds all of the parts which have been transferred.
     */
    protected $completedParts = array();

    /**
     * @var bool
     */
    protected $running;

    /**
     * @return $this
     */
    public static function factory()
    {
        $self = new self();

        return $self->init();
    }

    /**
     * @param TransferPart $part
     */
    public function addPart(TransferPart $part)
    {
        $this->completedParts[] = $part;
    }

    /**
     * @return int
     */
    public function count()
    {
        return count($this->completedParts);
    }

    /**
     * @return bool
     */
    public function isRunning()
    {
        return $this->running;
    }

    /**
     * @return $this
     */
    public function init()
    {
        $this->running = true;

        return $this;
    }

    /**
     * @return $this
     */
    public function cancel()
    {
        $this->running = false;

        return $this;
    }
}
PK)m]� �ճ�&ObjectStore/Upload/TransferBuilder.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Upload;

use Guzzle\Http\EntityBody;
use OpenCloud\Common\Exceptions\InvalidArgumentError;
use OpenCloud\ObjectStore\Resource\Container;

/**
 * Factory which creates Transfer objects, either ConcurrentTransfer or ConsecutiveTransfer.
 */
class TransferBuilder
{
    /**
     * @var Container The container being uploaded to
     */
    protected $container;

    /**
     * @var EntityBody The data payload.
     */
    protected $entityBody;

    /**
     * @var array A key/value pair of options.
     */
    protected $options = array();

    /**
     * @return TransferBuilder
     */
    public static function newInstance()
    {
        return new self();
    }

    /**
     * @param type $options Available configuration options:
     *
     * * `concurrency'    <bool>   The number of concurrent workers.
     * * `partSize'       <int>    The size, in bytes, for the chunk
     * * `doPartChecksum' <bool>   Enable or disable MD5 checksum in request (ETag)
     *
     * If you are uploading FooBar, its chunks will have the following naming structure:
     *
     * FooBar/1
     * FooBar/2
     * FooBar/3
     *
     * @return \OpenCloud\ObjectStore\Upload\UploadBuilder
     */
    public function setOptions($options)
    {
        $this->options = $options;

        return $this;
    }

    /**
     * @param $key   The option name
     * @param $value The option value
     * @return $this
     */
    public function setOption($key, $value)
    {
        $this->options[$key] = $value;

        return $this;
    }

    /**
     * @param Container $container
     * @return $this
     */
    public function setContainer(Container $container)
    {
        $this->container = $container;

        return $this;
    }

    /**
     * @param EntityBody $entityBody
     * @return $this
     */
    public function setEntityBody(EntityBody $entityBody)
    {
        $this->entityBody = $entityBody;

        return $this;
    }

    /**
     * Build the transfer.
     *
     * @return mixed
     * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
     */
    public function build()
    {
        // Validate properties
        if (!$this->container || !$this->entityBody || !$this->options['objectName']) {
            throw new InvalidArgumentError('A container, entity body and object name must be set');
        }

        // Create TransferState object for later use
        $transferState = TransferState::factory();

        // Instantiate Concurrent-/ConsecutiveTransfer
        $transferClass = isset($this->options['concurrency']) && $this->options['concurrency'] > 1
            ? __NAMESPACE__ . '\\ConcurrentTransfer'
            : __NAMESPACE__ . '\\ConsecutiveTransfer';

        return $transferClass::newInstance()
            ->setClient($this->container->getClient())
            ->setEntityBody($this->entityBody)
            ->setTransferState($transferState)
            ->setOptions($this->options)
            ->setOption('containerName', $this->container->getName())
            ->setOption('containerUrl', $this->container->getUrl())
            ->setup();
    }
}
PK)m]"�*�
�
)ObjectStore/Upload/ConcurrentTransfer.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Upload;

use Guzzle\Http\EntityBody;
use Guzzle\Http\ReadLimitEntityBody;

/**
 * A transfer type which executes in a concurrent fashion, i.e. with multiple workers uploading at once. Each worker is
 * charged with uploading a particular chunk of data. The entity body is fragmented into n pieces - calculated by
 * dividing the total size by the individual part size.
 *
 * @codeCoverageIgnore
 */
class ConcurrentTransfer extends AbstractTransfer
{
    public function transfer()
    {
        $totalParts = (int) ceil($this->entityBody->getContentLength() / $this->partSize);
        $workers = min($totalParts, $this->options['concurrency']);
        $parts = $this->collectParts($workers);

        while ($this->transferState->count() < $totalParts) {
            $completedParts = $this->transferState->count();
            $requests = array();

            // Iterate over number of workers until total completed parts is what we need it to be
            for ($i = 0; $i < $workers && ($completedParts + $i) < $totalParts; $i++) {
                // Offset is the current pointer multiplied by the standard chunk length
                $offset = ($completedParts + $i) * $this->partSize;
                $parts[$i]->setOffset($offset);

                // If this segment is empty (i.e. buffering a half-full chunk), break the iteration
                if ($parts[$i]->getContentLength() == 0) {
                    break;
                }

                // Add this to the request queue for later processing
                $requests[] = TransferPart::createRequest(
                    $parts[$i],
                    $this->transferState->count() + $i + 1,
                    $this->client,
                    $this->options
                );
            }

            // Iterate over our queued requests and process them
            foreach ($this->client->send($requests) as $response) {
                // Add this part to the TransferState
                $this->transferState->addPart(TransferPart::fromResponse($response));
            }
        }
    }

    /**
     * Partitions the entity body into an array - each worker is represented by a key, and the value is a
     * ReadLimitEntityBody object, whose read limit is fixed based on this object's partSize value. This will always
     * ensure the chunks are sent correctly.
     *
     * @param int    The total number of workers
     * @return array The worker array
     */
    private function collectParts($workers)
    {
        $uri = $this->entityBody->getUri();

        $array = array(new ReadLimitEntityBody($this->entityBody, $this->partSize));

        for ($i = 1; $i < $workers; $i++) {
            // Need to create a fresh EntityBody, otherwise you'll get weird 408 responses
            $array[] = new ReadLimitEntityBody(new EntityBody(fopen($uri, 'r')), $this->partSize);
        }

        return $array;
    }
}
PK)m]���TTObjectStore/CDNService.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore;

use OpenCloud\ObjectStore\Resource\CDNContainer;
use OpenCloud\ObjectStore\Resource\ContainerMetadata;

/**
 * This is the CDN version of the ObjectStore service.
 */
class CDNService extends AbstractService
{
    const DEFAULT_NAME = 'cloudFilesCDN';
    const DEFAULT_TYPE = 'rax:object-cdn';

    /**
     * List CDN-enabled containers.
     *
     * @param array $filter
     * @return \OpenCloud\Common\Collection\PaginatedIterator
     */
    public function listContainers(array $filter = array())
    {
        $filter['format'] = 'json';
        return $this->resourceList('CDNContainer', $this->getUrl(null, $filter), $this);
    }

    public function cdnContainer($data)
    {
        $container = new CDNContainer($this, $data);

        $metadata = new ContainerMetadata();
        $metadata->setArray(array(
            'Streaming-Uri' => $data->cdn_streaming_uri,
            'Ios-Uri' => $data->cdn_ios_uri,
            'Ssl-Uri' => $data->cdn_ssl_uri,
            'Enabled' => $data->cdn_enabled,
            'Ttl' => $data->ttl,
            'Log-Retention' => $data->log_retention,
            'Uri' => $data->cdn_uri,
        ));

        $container->setMetadata($metadata);

        return $container;
    }
}
PK)m]
Jwͅ�1ObjectStore/Exception/ObjectNotFoundException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Exception;

class ObjectNotFoundException extends \RuntimeException
{
    public static function factory($name, \Exception $exception)
    {
        $message = sprintf(
            "%s could not be found. The API returned this HTTP response:\n\n%s",
            $name,
            (string) $exception->getResponse()
        );

        $e = new self($message);

        $e->name = $name;
        $e->response = $exception->getResponse();
        $e->request = $exception->getRequest();

        return $e;
    }
}
PK)m]-�����,ObjectStore/Exception/ContainerException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Exception;

class ContainerException extends \Exception
{
}
PK)m]�X���)ObjectStore/Exception/StreamException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Exception;

class StreamException extends \Exception
{
}
PK)m]��t<<)ObjectStore/Exception/UploadException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Exception;

class UploadException extends \Exception
{
    protected $state;

    public function __construct($state, \Exception $exception = null)
    {
        parent::__construct(
            'An error was encountered while performing an upload: ' . $exception->getMessage(),
            0,
            $exception
        );

        $this->state = $state;
    }

    public function getState()
    {
        return $this->state;
    }
}
PK)m]�6{��0ObjectStore/Exception/BulkOperationException.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Exception;

class BulkOperationException extends \Exception
{
    public function __construct(array $errors)
    {
        $output = '';

        foreach ($errors as $error) {
            $output .= "$error[0]: $error[1]" . PHP_EOL;
        }

        parent::__construct(
            'These errors occurred while performing an archive upload: ' . $output
        );
    }
}
PK)m]�@��ObjectStore/Exception/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m]��[�
�
 ObjectStore/Resource/Account.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Resource;

/**
 * Represents an account that interacts with the CloudFiles API.
 *
 * @link http://docs.rackspace.com/files/api/v1/cf-devguide/content/Accounts-d1e421.html
 */
class Account extends AbstractResource
{
    const METADATA_LABEL = 'Account';

    /**
     * @var string The temporary URL secret for this account
     */
    private $tempUrlSecret;

    public function getUrl($path = null, array $query = array())
    {
        return $this->getService()->getUrl();
    }

    /**
     * Convenience method.
     *
     * @return \OpenCloud\Common\Metadata
     */
    public function getDetails()
    {
        return $this->retrieveMetadata();
    }

    /**
     * @return null|string|int
     */
    public function getObjectCount()
    {
        return $this->metadata->getProperty('Object-Count');
    }

    /**
     * @return null|string|int
     */
    public function getContainerCount()
    {
        return $this->metadata->getProperty('Container-Count');
    }

    /**
     * @return null|string|int
     */
    public function getBytesUsed()
    {
        return $this->metadata->getProperty('Bytes-Used');
    }

    /**
     * Sets the secret value for the temporary URL.
     *
     * @link http://docs.rackspace.com/files/api/v1/cf-devguide/content/Set_Account_Metadata-d1a4460.html
     *
     * @param null $secret The value to set the secret to. If left blank, a random hash is generated.
     * @return $this
     */
    public function setTempUrlSecret($secret = null)
    {
        if (!$secret) {
            $secret = sha1(rand(1, 99999));
        }

        $this->tempUrlSecret = $secret;

        $this->saveMetadata($this->appendToMetadata(array('Temp-Url-Key' => $secret)));

        return $this;
    }

    /**
     * @return null|string
     */
    public function getTempUrlSecret()
    {
        if (null === $this->tempUrlSecret) {
            $this->retrieveMetadata();
            $this->tempUrlSecret = $this->metadata->getProperty('Temp-Url-Key');
        }

        return $this->tempUrlSecret;
    }
}
PK)m]\��%ObjectStore/Resource/CDNContainer.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Resource;

use OpenCloud\ObjectStore\Constants\Header as HeaderConst;

/**
 * A container that has been CDN-enabled. Each CDN-enabled container has a unique
 * Uniform Resource Locator (URL) that can be combined with its object names and
 * openly distributed in web pages, emails, or other applications.
 */
class CDNContainer extends AbstractContainer
{
    const METADATA_LABEL = 'Cdn';

    /**
     * @return null|string|int
     */
    public function getCdnSslUri()
    {
        return $this->metadata->getProperty('Ssl-Uri');
    }

    /**
     * @return null|string|int
     */
    public function getCdnUri()
    {
        return $this->metadata->getProperty('Uri');
    }

    /**
     * @return null|string|int
     */
    public function getTtl()
    {
        return $this->metadata->getProperty('Ttl');
    }

    /**
     * @return null|string|int
     */
    public function getCdnStreamingUri()
    {
        return $this->metadata->getProperty('Streaming-Uri');
    }

    /**
     * @return null|string|int
     */
    public function getIosStreamingUri()
    {
        return $this->metadata->getProperty('Ios-Uri');
    }

    public function refresh($name = null, $url = null)
    {
        $response = $this->createRefreshRequest()->send();

        $headers = $response->getHeaders();
        $this->setMetadata($headers, true);

        return $headers;
    }

    /**
     * Turn on access logs, which track all the web traffic that your data objects accrue.
     *
     * @return \Guzzle\Http\Message\Response
     */
    public function enableCdnLogging()
    {
        $headers = array('X-Log-Retention' => 'True');

        return $this->getClient()->put($this->getUrl(), $headers)->send();
    }

    /**
     * Disable access logs.
     *
     * @return \Guzzle\Http\Message\Response
     */
    public function disableCdnLogging()
    {
        $headers = array('X-Log-Retention' => 'False');

        return $this->getClient()->put($this->getUrl(), $headers)->send();
    }

    public function isCdnEnabled()
    {
        return $this->metadata->getProperty(HeaderConst::ENABLED) == 'True';
    }

    /**
     * Set the TTL.
     *
     * @param $ttl The time-to-live in seconds.
     * @return \Guzzle\Http\Message\Response
     */
    public function setTtl($ttl)
    {
        $headers = array('X-Ttl' => $ttl);

        return $this->getClient()->post($this->getUrl(), $headers)->send();
    }
}
PK)m]
*���*ObjectStore/Resource/ContainerMetadata.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Resource;

class ContainerMetadata extends \OpenCloud\Common\Metadata
{
}
PK)m]�@��ObjectStore/Resource/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m]ɤ�Q�Q"ObjectStore/Resource/Container.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Resource;

use Guzzle\Http\EntityBody;
use Guzzle\Http\Exception\BadResponseException;
use Guzzle\Http\Exception\ClientErrorResponseException;
use Guzzle\Http\Message\Response;
use Guzzle\Http\Url;
use OpenCloud\Common\Constants\Size;
use OpenCloud\Common\Exceptions;
use OpenCloud\Common\Service\ServiceInterface;
use OpenCloud\ObjectStore\Constants\Header as HeaderConst;
use OpenCloud\ObjectStore\Exception\ContainerException;
use OpenCloud\ObjectStore\Exception\ObjectNotFoundException;
use OpenCloud\ObjectStore\Upload\DirectorySync;
use OpenCloud\ObjectStore\Upload\TransferBuilder;
use OpenCloud\ObjectStore\Enum\ReturnType;

/**
 * A container is a storage compartment for your data and provides a way for you
 * to organize your data. You can think of a container as a folder in Windows
 * or a directory in Unix. The primary difference between a container and these
 * other file system concepts is that containers cannot be nested.
 *
 * A container can also be CDN-enabled (for public access), in which case you
 * will need to interact with a CDNContainer object instead of this one.
 */
class Container extends AbstractContainer
{
    const METADATA_LABEL = 'Container';

    /**
     * This is the object that holds all the CDN functionality. This Container therefore acts as a simple wrapper and is
     * interested in storage concerns only.
     *
     * @var CDNContainer|null
     */
    private $cdn;

    public function __construct(ServiceInterface $service, $data = null)
    {
        parent::__construct($service, $data);

        // Set metadata items for collection listings
        if (isset($data->count)) {
            $this->metadata->setProperty('Object-Count', $data->count);
        }
        if (isset($data->bytes)) {
            $this->metadata->setProperty('Bytes-Used', $data->bytes);
        }
    }

    /**
     * Factory method that instantiates an object from a Response object.
     *
     * @param Response         $response
     * @param ServiceInterface $service
     * @return static
     */
    public static function fromResponse(Response $response, ServiceInterface $service)
    {
        $self = parent::fromResponse($response, $service);

        $segments = Url::factory($response->getEffectiveUrl())->getPathSegments();
        $self->name = end($segments);

        return $self;
    }

    /**
     * Get the CDN object.
     *
     * @return null|CDNContainer
     * @throws \OpenCloud\Common\Exceptions\CdnNotAvailableError
     */
    public function getCdn()
    {
        if (!$this->isCdnEnabled()) {
            throw new Exceptions\CdnNotAvailableError(
                'Either this container is not CDN-enabled or the CDN is not available'
            );
        }

        return $this->cdn;
    }

    /**
     * It would be awesome to put these convenience methods (which are identical to the ones in the Account object) in
     * a trait, but we have to wait for v5.3 EOL first...
     *
     * @return null|string|int
     */
    public function getObjectCount()
    {
        return $this->metadata->getProperty('Object-Count');
    }

    /**
     * @return null|string|int
     */
    public function getBytesUsed()
    {
        return $this->metadata->getProperty('Bytes-Used');
    }

    /**
     * @param $value
     * @return mixed
     */
    public function setCountQuota($value)
    {
        $this->metadata->setProperty('Quota-Count', $value);

        return $this->saveMetadata($this->metadata->toArray());
    }

    /**
     * @return null|string|int
     */
    public function getCountQuota()
    {
        return $this->metadata->getProperty('Quota-Count');
    }

    /**
     * @param $value
     * @return mixed
     */
    public function setBytesQuota($value)
    {
        $this->metadata->setProperty('Quota-Bytes', $value);

        return $this->saveMetadata($this->metadata->toArray());
    }

    /**
     * @return null|string|int
     */
    public function getBytesQuota()
    {
        return $this->metadata->getProperty('Quota-Bytes');
    }

    public function delete($deleteObjects = false)
    {
        if ($deleteObjects === true) {
            // Delegate to auxiliary method
            return $this->deleteWithObjects();
        }

        try {
            return $this->getClient()->delete($this->getUrl())->send();
        } catch (ClientErrorResponseException $e) {
            if ($e->getResponse()->getStatusCode() == 409) {
                throw new ContainerException(sprintf(
                    'The API returned this error: %s. You might have to delete all existing objects before continuing.',
                    (string) $e->getResponse()->getBody()
                ));
            } else {
                throw $e;
            }
        }
    }

    public function deleteWithObjects($secondsToWait = null)
    {
        // If container is empty, just delete it
        $numObjects = (int) $this->retrieveMetadata()->getProperty('Object-Count');
        if (0 === $numObjects) {
            return $this->delete();
        }

        // If timeout ($secondsToWait) is not specified by caller,
        // try to estimate it based on number of objects in container
        if (null === $secondsToWait) {
            $secondsToWait = round($numObjects / 2);
        }

        // Attempt to delete all objects and container
        $endTime = time() + $secondsToWait;
        $containerDeleted = false;
        while ((time() < $endTime) && !$containerDeleted) {
            $this->deleteAllObjects();
            try {
                $response = $this->delete();
                $containerDeleted = true;
            } catch (ContainerException $e) {
                // Ignore exception and try again
            } catch (ClientErrorResponseException $e) {
                if ($e->getResponse()->getStatusCode() == 404) {
                    // Container has been deleted
                    $containerDeleted = true;
                } else {
                    throw $e;
                }
            }
        }

        if (!$containerDeleted) {
            throw new ContainerException('Container and all its objects could not be deleted.');
        }

        return $response;
    }

    /**
     * Deletes all objects that this container currently contains. Useful when doing operations (like a delete) that
     * require an empty container first.
     *
     * @return mixed
     */
    public function deleteAllObjects()
    {
        $paths = array();
        $objects = $this->objectList();
        foreach ($objects as $object) {
            $paths[] = sprintf('/%s/%s', $this->getName(), $object->getName());
        }
        return $this->getService()->batchDelete($paths);
    }

    /**
     * Creates a Collection of objects in the container
     *
     * @param array $params associative array of parameter values.
     *                      * account/tenant - The unique identifier of the account/tenant.
     *                      * container- The unique identifier of the container.
     *                      * limit (Optional) - The number limit of results.
     *                      * marker (Optional) - Value of the marker, that the object names
     *                      greater in value than are returned.
     *                      * end_marker (Optional) - Value of the marker, that the object names
     *                      less in value than are returned.
     *                      * prefix (Optional) - Value of the prefix, which the returned object
     *                      names begin with.
     *                      * format (Optional) - Value of the serialized response format, either
     *                      json or xml.
     *                      * delimiter (Optional) - Value of the delimiter, that all the object
     *                      names nested in the container are returned.
     * @link   http://api.openstack.org for a list of possible parameter
     *                      names and values
     * @return \OpenCloud\Common\Collection
     * @throws ObjFetchError
     */
    public function objectList(array $params = array())
    {
        $params['format'] = 'json';

        return $this->getService()->resourceList('DataObject', $this->getUrl(null, $params), $this);
    }

    /**
     * Turn on access logs, which track all the web traffic that your data objects accrue.
     *
     * @return \Guzzle\Http\Message\Response
     */
    public function enableLogging()
    {
        return $this->saveMetadata($this->appendToMetadata(array(
            HeaderConst::ACCESS_LOGS => 'True'
        )));
    }

    /**
     * Disable access logs.
     *
     * @return \Guzzle\Http\Message\Response
     */
    public function disableLogging()
    {
        return $this->saveMetadata($this->appendToMetadata(array(
            HeaderConst::ACCESS_LOGS => 'False'
        )));
    }

    /**
     * Enable this container for public CDN access.
     *
     * @param null $ttl
     */
    public function enableCdn($ttl = null)
    {
        $headers = array('X-CDN-Enabled' => 'True');
        if ($ttl) {
            $headers['X-TTL'] = (int) $ttl;
        }

        $this->getClient()->put($this->getCdnService()->getUrl($this->name), $headers)->send();
        $this->refresh();
    }

    /**
     * Disables the containers CDN function. Note that the container will still
     * be available on the CDN until its TTL expires.
     *
     * @return \Guzzle\Http\Message\Response
     */
    public function disableCdn()
    {
        $headers = array('X-CDN-Enabled' => 'False');

        return $this->getClient()
            ->put($this->getCdnService()->getUrl($this->name), $headers)
            ->send();
    }

    public function refresh($id = null, $url = null)
    {
        $headers = $this->createRefreshRequest()->send()->getHeaders();
        $this->setMetadata($headers, true);

        try {
            if (null !== ($cdnService = $this->getService()->getCDNService())) {
                $cdn = new CDNContainer($cdnService);
                $cdn->setName($this->name);

                $response = $cdn->createRefreshRequest()->send();

                if ($response->isSuccessful()) {
                    $this->cdn = $cdn;
                    $this->cdn->setMetadata($response->getHeaders(), true);
                }
            } else {
                $this->cdn = null;
            }
        } catch (ClientErrorResponseException $e) {
        }
    }

    /**
     * Get either a fresh data object (no $info), or get an existing one by passing in data for population.
     *
     * @param  mixed $info
     * @return DataObject
     */
    public function dataObject($info = null)
    {
        return new DataObject($this, $info);
    }

    /**
     * Retrieve an object from the API. Apart from using the name as an
     * identifier, you can also specify additional headers that will be used
     * fpr a conditional GET request. These are
     *
     * * `If-Match'
     * * `If-None-Match'
     * * `If-Modified-Since'
     * * `If-Unmodified-Since'
     * * `Range'  For example:
     *      bytes=-5    would mean the last 5 bytes of the object
     *      bytes=10-15 would mean 5 bytes after a 10 byte offset
     *      bytes=32-   would mean all dat after first 32 bytes
     *
     * These are also documented in RFC 2616.
     *
     * @param string $name
     * @param array  $headers
     * @return DataObject
     */
    public function getObject($name, array $headers = array())
    {
        try {
            $response = $this->getClient()
                ->get($this->getUrl($name), $headers)
                ->send();
        } catch (BadResponseException $e) {
            if ($e->getResponse()->getStatusCode() == 404) {
                throw ObjectNotFoundException::factory($name, $e);
            }
            throw $e;
        }

        return $this->dataObject()
            ->populateFromResponse($response)
            ->setName($name);
    }

    /**
     * Essentially the same as {@see getObject()}, except only the metadata is fetched from the API.
     * This is useful for cases when the user does not want to fetch the full entity body of the
     * object, only its metadata.
     *
     * @param       $name
     * @param array $headers
     * @return $this
     */
    public function getPartialObject($name, array $headers = array())
    {
        $response = $this->getClient()
            ->head($this->getUrl($name), $headers)
            ->send();

        return $this->dataObject()
            ->populateFromResponse($response)
            ->setName($name);
    }

    /**
     * Check if an object exists inside a container. Uses {@see getPartialObject()}
     * to save on bandwidth and time.
     *
     * @param  $name    Object name
     * @return boolean  True, if object exists in this container; false otherwise.
     */
    public function objectExists($name)
    {
        try {
            // Send HEAD request to check resource existence
            $url = clone $this->getUrl();
            $url->addPath((string) $name);
            $this->getClient()->head($url)->send();
        } catch (ClientErrorResponseException $e) {
            // If a 404 was returned, then the object doesn't exist
            if ($e->getResponse()->getStatusCode() === 404) {
                return false;
            } else {
                throw $e;
            }
        }

        return true;
    }

    /**
     * Upload a single file to the API.
     *
     * @param       $name    Name that the file will be saved as in your container.
     * @param       $data    Either a string or stream representation of the file contents to be uploaded.
     * @param array $headers Optional headers that will be sent with the request (useful for object metadata).
     * @return DataObject
     */
    public function uploadObject($name, $data, array $headers = array())
    {
        $entityBody = EntityBody::factory($data);

        $url = clone $this->getUrl();
        $url->addPath($name);

        // @todo for new major release: Return response rather than populated DataObject

        $response = $this->getClient()->put($url, $headers, $entityBody)->send();

        return $this->dataObject()
            ->populateFromResponse($response)
            ->setName($name)
            ->setContent($entityBody);
    }

    /**
     * Upload an array of objects for upload. This method optimizes the upload procedure by batching requests for
     * faster execution. This is a very useful procedure when you just have a bunch of unremarkable files to be
     * uploaded quickly. Each file must be under 5GB.
     *
     * @param array $files   With the following array structure:
     *                       `name' Name that the file will be saved as in your container. Required.
     *                       `path' Path to an existing file, OR
     *                       `body' Either a string or stream representation of the file contents to be uploaded.
     * @param array $headers Optional headers that will be sent with the request (useful for object metadata).
     * @param string $returnType One of OpenCloud\ObjectStore\Enum\ReturnType::RESPONSE_ARRAY (to return an array of
     *                           Guzzle\Http\Message\Response objects) or OpenCloud\ObjectStore\Enum\ReturnType::DATA_OBJECT_ARRAY
     *                           (to return an array of OpenCloud\ObjectStore\Resource\DataObject objects).
     *
     * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
     * @return Guzzle\Http\Message\Response[] or OpenCloud\ObjectStore\Resource\DataObject[] depending on $returnType
     */
    public function uploadObjects(array $files, array $commonHeaders = array(), $returnType = ReturnType::RESPONSE_ARRAY)
    {
        $requests = $entities = array();

        foreach ($files as $entity) {
            if (empty($entity['name'])) {
                throw new Exceptions\InvalidArgumentError('You must provide a name.');
            }

            if (!empty($entity['path']) && file_exists($entity['path'])) {
                $body = fopen($entity['path'], 'r+');
            } elseif (!empty($entity['body'])) {
                $body = $entity['body'];
            } else {
                throw new Exceptions\InvalidArgumentError('You must provide either a readable path or a body');
            }

            $entityBody = $entities[] = EntityBody::factory($body);

            // @codeCoverageIgnoreStart
            if ($entityBody->getContentLength() >= 5 * Size::GB) {
                throw new Exceptions\InvalidArgumentError(
                    'For multiple uploads, you cannot upload more than 5GB per '
                    . ' file. Use the UploadBuilder for larger files.'
                );
            }
            // @codeCoverageIgnoreEnd

            // Allow custom headers and common
            $headers = (isset($entity['headers'])) ? $entity['headers'] : $commonHeaders;

            $url = clone $this->getUrl();
            $url->addPath($entity['name']);

            $requests[] = $this->getClient()->put($url, $headers, $entityBody);
        }

        $responses = $this->getClient()->send($requests);

        if (ReturnType::RESPONSE_ARRAY === $returnType) {
            foreach ($entities as $entity) {
                $entity->close();
            }
            return $responses;
        } else {
            // Convert responses to DataObjects before returning
            $dataObjects = array();
            foreach ($responses as $index => $response) {
                $dataObjects[] = $this->dataObject()
                               ->populateFromResponse($response)
                               ->setName($files[$index]['name'])
                               ->setContent($entities[$index]);
            }
            return $dataObjects;
        }
    }

    /**
     * When uploading large files (+5GB), you need to upload the file as chunks using multibyte transfer. This method
     * sets up the transfer, and in order to execute the transfer, you need to call upload() on the returned object.
     *
     * @param array Options
     * @see \OpenCloud\ObjectStore\Upload\UploadBuilder::setOptions for a list of accepted options.
     * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
     * @return mixed
     */
    public function setupObjectTransfer(array $options = array())
    {
        // Name is required
        if (empty($options['name'])) {
            throw new Exceptions\InvalidArgumentError('You must provide a name.');
        }

        // As is some form of entity body
        if (!empty($options['path']) && file_exists($options['path'])) {
            $body = fopen($options['path'], 'r+');
        } elseif (!empty($options['body'])) {
            $body = $options['body'];
        } else {
            throw new Exceptions\InvalidArgumentError('You must provide either a readable path or a body');
        }

        // Build upload
        $transfer = TransferBuilder::newInstance()
            ->setOption('objectName', $options['name'])
            ->setEntityBody(EntityBody::factory($body))
            ->setContainer($this);

        // Add extra options
        if (!empty($options['metadata'])) {
            $transfer->setOption('metadata', $options['metadata']);
        }
        if (!empty($options['partSize'])) {
            $transfer->setOption('partSize', $options['partSize']);
        }
        if (!empty($options['concurrency'])) {
            $transfer->setOption('concurrency', $options['concurrency']);
        }
        if (!empty($options['progress'])) {
            $transfer->setOption('progress', $options['progress']);
        }

        return $transfer->build();
    }

    /**
     * Upload the contents of a local directory to a remote container, effectively syncing them.
     *
     * @param $path The local path to the directory.
     */
    public function uploadDirectory($path)
    {
        $sync = DirectorySync::factory($path, $this);
        $sync->execute();
    }

    public function isCdnEnabled()
    {
        return ($this->cdn instanceof CDNContainer) && $this->cdn->isCdnEnabled();
    }
}
PK)m]
��``)ObjectStore/Resource/AbstractResource.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Resource;

use Guzzle\Http\Message\Response;
use OpenCloud\Common\Base;
use OpenCloud\Common\Service\ServiceInterface;

/**
 * Abstract base class which implements shared functionality of ObjectStore
 * resources. Provides support, for example, for metadata-handling and other
 * features that are common to the ObjectStore components.
 */
abstract class AbstractResource extends Base
{
    const GLOBAL_METADATA_PREFIX = 'X';

    /** @var \OpenCloud\Common\Metadata */
    protected $metadata;

    /** @var string The FQCN of the metadata object used for the container. */
    protected $metadataClass = 'OpenCloud\\Common\\Metadata';

    /** @var \OpenCloud\Common\Service\ServiceInterface The service object. */
    protected $service;

    public function __construct(ServiceInterface $service)
    {
        $this->service = $service;
        $this->metadata = new $this->metadataClass;
    }

    public function getService()
    {
        return $this->service;
    }

    public function getCdnService()
    {
        return $this->service->getCDNService();
    }

    public function getClient()
    {
        return $this->service->getClient();
    }

    /**
     * Factory method that allows for easy instantiation from a Response object.
     *
     * @param Response         $response
     * @param ServiceInterface $service
     * @return static
     */
    public static function fromResponse(Response $response, ServiceInterface $service)
    {
        $object = new static($service);

        if (null !== ($headers = $response->getHeaders())) {
            $object->setMetadata($headers, true);
        }

        return $object;
    }

    /**
     * Trim headers of their resource-specific prefixes.
     *
     * @param  $headers
     * @return array
     */
    public static function trimHeaders($headers)
    {
        $output = array();

        foreach ($headers as $header => $value) {
            // Only allow allow X-<keyword>-* headers to pass through after stripping them
            if (static::headerIsValidMetadata($header) && ($key = self::stripPrefix($header))) {
                $output[$key] = (string) $value;
            }
        }

        return $output;
    }

    protected static function headerIsValidMetadata($header)
    {
        $pattern = sprintf('#^%s\-#i', self::GLOBAL_METADATA_PREFIX);

        return preg_match($pattern, $header);
    }

    /**
     * Strip an individual header name of its resource-specific prefix.
     *
     * @param $header
     * @return mixed
     */
    protected static function stripPrefix($header)
    {
        $pattern = '#^' . self::GLOBAL_METADATA_PREFIX . '\-(' . static::METADATA_LABEL . '-)?(Meta-)?#i';

        return preg_replace($pattern, '', $header);
    }

    /**
     * Prepend/stock the header names with a resource-specific prefix.
     *
     * @param array $headers
     * @return array
     */
    public static function stockHeaders(array $headers)
    {
        $output = array();
        $prefix = null;
        $corsHeaders = array(
            'Access-Control-Allow-Origin',
            'Access-Control-Expose-Headers',
            'Access-Control-Max-Age',
            'Access-Control-Allow-Credentials',
            'Access-Control-Allow-Methods',
            'Access-Control-Allow-Headers'
        );
        foreach ($headers as $header => $value) {
            if (!in_array($header, $corsHeaders)) {
                $prefix = self::GLOBAL_METADATA_PREFIX . '-' . static::METADATA_LABEL . '-Meta-';
            }
            $output[$prefix . $header] = $value;
        }

        return $output;
    }

    /**
     * Set the metadata (local-only) for this object.
     *
     * @param      $data
     * @param bool $constructFromResponse
     * @return $this
     */
    public function setMetadata($data, $constructFromResponse = false)
    {
        if ($constructFromResponse) {
            $metadata = new $this->metadataClass;
            $metadata->setArray(self::trimHeaders($data));
            $data = $metadata;
        }

        $this->metadata = $data;

        return $this;
    }

    /**
     * @return \OpenCloud\Common\Metadata
     */
    public function getMetadata()
    {
        return $this->metadata;
    }

    /**
     * Push local metadata to the API, thereby executing a permanent save.
     *
     * @param array $metadata    The array of values you want to set as metadata
     * @param bool  $stockPrefix Whether to prepend each array key with the metadata-specific prefix. For objects, this
     *                           would be X-Object-Meta-Foo => Bar
     * @return mixed
     */
    public function saveMetadata(array $metadata, $stockPrefix = true)
    {
        $headers = ($stockPrefix === true) ? self::stockHeaders($metadata) : $metadata;

        return $this->getClient()->post($this->getUrl(), $headers)->send();
    }

    /**
     * Retrieve metadata from the API. This method will then set and return this value.
     *
     * @return \OpenCloud\Common\Metadata
     */
    public function retrieveMetadata()
    {
        $response = $this->getClient()
            ->head($this->getUrl())
            ->send();

        $this->setMetadata($response->getHeaders(), true);

        return $this->metadata;
    }

    /**
     * To delete or unset a particular metadata item.
     *
     * @param $key
     * @return mixed
     */
    public function unsetMetadataItem($key)
    {
        $header = sprintf('%s-Remove-%s-Meta-%s', self::GLOBAL_METADATA_PREFIX,
            static::METADATA_LABEL, $key);

        $headers = array($header => 'True');

        return $this->getClient()
            ->post($this->getUrl(), $headers)
            ->send();
    }

    /**
     * Append a particular array of values to the existing metadata. Analogous to a merge.
     *
     * @param array $values
     * @return array
     */
    public function appendToMetadata(array $values)
    {
        return (!empty($this->metadata) && is_array($this->metadata))
            ? array_merge($this->metadata, $values)
            : $values;
    }
}
PK)m]FX�*ObjectStore/Resource/AbstractContainer.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Resource;

use OpenCloud\Common\Exceptions;
use OpenCloud\Common\Service\ServiceInterface;
use OpenCloud\ObjectStore\Constants\Header as HeaderConst;

/**
 * Abstract class holding shared functionality for containers.
 */
abstract class AbstractContainer extends AbstractResource
{
    protected $metadataClass = 'OpenCloud\\ObjectStore\\Resource\\ContainerMetadata';

    /**
     * The name of the container.
     *
     * The only restrictions on container names is that they cannot contain a
     * forward slash (/) and must be less than 256 bytes in length. Please note
     * that the length restriction applies to the name after it has been URL
     * encoded. For example, a container named Course Docs would be URL encoded
     * as Course%20Docs - which is 13 bytes in length rather than the expected 11.
     *
     * @var string
     */
    public $name;

    public function __construct(ServiceInterface $service, $data = null)
    {
        $this->service = $service;
        $this->metadata = new $this->metadataClass;

        // Populate data if set
        $this->populate($data);
    }

    public function getTransId()
    {
        return $this->metadata->getProperty(HeaderConst::TRANS_ID);
    }

    abstract public function isCdnEnabled();

    public function hasLogRetention()
    {
        if ($this instanceof CDNContainer) {
            return $this->metadata->getProperty(HeaderConst::LOG_RETENTION) == 'True';
        } else {
            return $this->metadata->propertyExists(HeaderConst::ACCESS_LOGS);
        }
    }

    public function primaryKeyField()
    {
        return 'name';
    }

    public function getUrl($path = null, array $params = array())
    {
        if (strlen($this->getName()) == 0) {
            throw new Exceptions\NoNameError('Container does not have a name');
        }

        $url = $this->getService()->getUrl();

        return $url->addPath((string) $this->getName())->addPath((string) $path)->setQuery($params);
    }

    protected function createRefreshRequest()
    {
        return $this->getClient()->head($this->getUrl(), array('Accept' => '*/*'));
    }

    /**
     * This method will enable your CDN-enabled container to serve out HTML content like a website.
     *
     * @param $indexPage The data object name (i.e. a .html file) that will serve as the main index page.
     * @return \Guzzle\Http\Message\Response
     */
    public function setStaticIndexPage($page)
    {
        if ($this instanceof CDNContainer) {
            $this->getLogger()->warning(
                'This method cannot be called on the CDN object - please execute it on the normal Container'
            );
        }

        $headers = array('X-Container-Meta-Web-Index' => $page);

        return $this->getClient()->post($this->getUrl(), $headers)->send();
    }

    /**
     * Set the default error page for your static site.
     *
     * @param $name The data object name (i.e. a .html file) that will serve as the main error page.
     * @return \Guzzle\Http\Message\Response
     */
    public function setStaticErrorPage($page)
    {
        if ($this instanceof CDNContainer) {
            $this->getLogger()->warning(
                'This method cannot be called on the CDN object - please execute it on the normal Container'
            );
        }

        $headers = array('X-Container-Meta-Web-Error' => $page);

        return $this->getClient()->post($this->getUrl(), $headers)->send();
    }
}
PK)m])L r�,�,#ObjectStore/Resource/DataObject.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore\Resource;

use Guzzle\Http\EntityBody;
use Guzzle\Http\Message\Response;
use Guzzle\Http\Url;
use OpenCloud\Common\Constants\Header as HeaderConst;
use OpenCloud\Common\Exceptions;
use OpenCloud\Common\Lang;
use OpenCloud\ObjectStore\Constants\UrlType;

/**
 * Objects are the basic storage entities in Cloud Files. They represent the
 * files and their optional metadata you upload to the system. When you upload
 * objects to Cloud Files, the data is stored as-is (without compression or
 * encryption) and consists of a location (container), the object's name, and
 * any metadata you assign consisting of key/value pairs.
 */
class DataObject extends AbstractResource
{
    const METADATA_LABEL = 'Object';

    /**
     * @var Container
     */
    private $container;

    /**
     * @var The file name of the object
     */
    protected $name;

    /**
     * @var EntityBody
     */
    protected $content;

    /**
     * @var bool Whether or not this object is a "pseudo-directory"
     * @link http://docs.openstack.org/trunk/openstack-object-storage/developer/content/pseudo-hierarchical-folders-directories.html
     */
    protected $directory = false;

    /**
     * @var string The object's content type
     */
    protected $contentType;

    /**
     * @var The size of this object.
     */
    protected $contentLength;

    /**
     * @var string Date of last modification.
     */
    protected $lastModified;

    /**
     * @var string Etag.
     */
    protected $etag;

    /**
     * Also need to set Container parent and handle pseudo-directories.
     * {@inheritDoc}
     *
     * @param Container $container
     * @param null      $data
     */
    public function __construct(Container $container, $data = null)
    {
        $this->setContainer($container);

        parent::__construct($container->getService());

        // For pseudo-directories, we need to ensure the name is set
        if (!empty($data->subdir)) {
            $this->setName($data->subdir)->setDirectory(true);

            return;
        }

        $this->populate($data);
    }

    /**
     * A collection list of DataObjects contains a different data structure than the one returned for the
     * "Retrieve Object" operation. So we need to stock the values differently.
     * {@inheritDoc}
     */
    public function populate($info, $setObjects = true)
    {
        parent::populate($info, $setObjects);

        if (isset($info->bytes)) {
            $this->setContentLength($info->bytes);
        }
        if (isset($info->last_modified)) {
            $this->setLastModified($info->last_modified);
        }
        if (isset($info->content_type)) {
            $this->setContentType($info->content_type);
        }
        if (isset($info->hash)) {
            $this->setEtag($info->hash);
        }
    }

    /**
     * Takes a response and stocks common values from both the body and the headers.
     *
     * @param Response $response
     * @return $this
     */
    public function populateFromResponse(Response $response)
    {
        $this->content = $response->getBody();

        $headers = $response->getHeaders();

        return $this->setMetadata($headers, true)
            ->setContentType((string) $headers[HeaderConst::CONTENT_TYPE])
            ->setLastModified((string) $headers[HeaderConst::LAST_MODIFIED])
            ->setContentLength((string) $headers[HeaderConst::CONTENT_LENGTH])
            ->setEtag((string) $headers[HeaderConst::ETAG]);
    }

    public function refresh()
    {
        $response = $this->getService()->getClient()
            ->get($this->getUrl())
            ->send();

        return $this->populateFromResponse($response);
    }

    /**
     * @param Container $container
     * @return $this
     */
    public function setContainer(Container $container)
    {
        $this->container = $container;

        return $this;
    }

    /**
     * @return Container
     */
    public function getContainer()
    {
        return $this->container;
    }

    /**
     * @param $name string
     * @return $this
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param $directory bool
     * @return $this
     */
    public function setDirectory($directory)
    {
        $this->directory = $directory;

        return $this;
    }

    /**
     * @return bool
     */
    public function getDirectory()
    {
        return $this->directory;
    }

    /**
     * @return bool Is this data object a pseudo-directory?
     */
    public function isDirectory()
    {
        return (bool) $this->directory;
    }

    /**
     * @param  mixed $content
     * @return $this
     */
    public function setContent($content)
    {
        $this->etag = null;
        $this->contentType = null;
        $this->content = EntityBody::factory($content);

        return $this;
    }

    /**
     * @return EntityBody
     */
    public function getContent()
    {
        return $this->content;
    }

    /**
     * @param  string $contentType
     * @return $this
     */
    public function setContentType($contentType)
    {
        $this->contentType = $contentType;

        return $this;
    }

    /**
     * @return null|string
     */
    public function getContentType()
    {
        return $this->contentType ? : $this->content->getContentType();
    }

    /**
     * @param $contentType int
     * @return $this
     */
    public function setContentLength($contentLength)
    {
        $this->contentLength = $contentLength;

        return $this;
    }

    /**
     * @return int
     */
    public function getContentLength()
    {
        return $this->contentLength !== null ? $this->contentLength : $this->content->getContentLength();
    }

    /**
     * @param $etag
     * @return $this
     */
    public function setEtag($etag)
    {
        $this->etag = $etag;

        return $this;
    }

    /**
     * @return null|string
     */
    public function getEtag()
    {
        return $this->etag ? : $this->content->getContentMd5();
    }

    public function setLastModified($lastModified)
    {
        $this->lastModified = $lastModified;

        return $this;
    }

    public function getLastModified()
    {
        return $this->lastModified;
    }

    public function primaryKeyField()
    {
        return 'name';
    }

    public function getUrl($path = null, array $params = array())
    {
        if (!$this->name) {
            throw new Exceptions\NoNameError(Lang::translate('Object has no name'));
        }

        return $this->container->getUrl($this->name);
    }

    public function update($params = array())
    {
        $metadata = is_array($this->metadata) ? $this->metadata : $this->metadata->toArray();
        $metadata = self::stockHeaders($metadata);

        // merge specific properties with metadata
        $metadata += array(
            HeaderConst::CONTENT_TYPE   => $this->contentType,
            HeaderConst::LAST_MODIFIED  => $this->lastModified,
            HeaderConst::CONTENT_LENGTH => $this->contentLength,
            HeaderConst::ETAG           => $this->etag
        );

        return $this->container->uploadObject($this->name, $this->content, $metadata);
    }

    /**
     * @param string $destination Path (`container/object') of new object
     * @return \Guzzle\Http\Message\Response
     */
    public function copy($destination)
    {
        return $this->getService()
            ->getClient()
            ->createRequest('COPY', $this->getUrl(), array(
                'Destination' => (string) $destination
            ))
            ->send();
    }

    public function delete($params = array())
    {
        return $this->getService()->getClient()->delete($this->getUrl())->send();
    }

    /**
     * Get a temporary URL for this object.
     *
     * @link http://docs.rackspace.com/files/api/v1/cf-devguide/content/TempURL-d1a4450.html
     *
     * @param $expires Expiration time in seconds
     * @param $method  What method can use this URL? (`GET' or `PUT')
     * @return string
     * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
     * @throws \OpenCloud\Common\Exceptions\ObjectError
     *
     */
    public function getTemporaryUrl($expires, $method)
    {
        $method = strtoupper($method);
        $expiry = time() + (int) $expires;

        // check for proper method
        if ($method != 'GET' && $method != 'PUT') {
            throw new Exceptions\InvalidArgumentError(sprintf(
                'Bad method [%s] for TempUrl; only GET or PUT supported',
                $method
            ));
        }

        // @codeCoverageIgnoreStart
        if (!($secret = $this->getService()->getAccount()->getTempUrlSecret())) {
            throw new Exceptions\ObjectError('Cannot produce temporary URL without an account secret.');
        }
        // @codeCoverageIgnoreEnd

        $url = $this->getUrl();
        $urlPath = urldecode($url->getPath());
        $body = sprintf("%s\n%d\n%s", $method, $expiry, $urlPath);
        $hash = hash_hmac('sha1', $body, $secret);

        return sprintf('%s?temp_url_sig=%s&temp_url_expires=%d', $url, $hash, $expiry);
    }

    /**
     * Remove this object from the CDN.
     *
     * @param null $email
     * @return mixed
     */
    public function purge($email = null)
    {
        if (!$cdn = $this->getContainer()->getCdn()) {
            return false;
        }

        $url = clone $cdn->getUrl();
        $url->addPath($this->name);

        $headers = ($email !== null) ? array('X-Purge-Email' => $email) : array();

        return $this->getService()
            ->getClient()
            ->delete($url, $headers)
            ->send();
    }

    /**
     * @param string $type
     * @return bool|Url
     */
    public function getPublicUrl($type = UrlType::CDN)
    {
        $cdn = $this->container->getCdn();

        switch ($type) {
            case UrlType::CDN:
                $uri = $cdn->getCdnUri();
                break;
            case UrlType::SSL:
                $uri = $cdn->getCdnSslUri();
                break;
            case UrlType::STREAMING:
                $uri = $cdn->getCdnStreamingUri();
                break;
            case UrlType::IOS_STREAMING:
                $uri = $cdn->getIosStreamingUri();
                break;
        }

        return (isset($uri)) ? Url::factory($uri)->addPath($this->name) : false;
    }

    protected static function headerIsValidMetadata($header)
    {
        $pattern = sprintf('#^%s-%s-Meta-#i', self::GLOBAL_METADATA_PREFIX, self::METADATA_LABEL);

        return preg_match($pattern, $header);
    }
}
PK)m]�@��ObjectStore/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m]"0�A��ObjectStore/AbstractService.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore;

use OpenCloud\Common\Service\CatalogService;

/**
 * An abstract base class for common code shared between ObjectStore\Service
 * (container) and ObjectStore\CDNService (CDN containers).
 */
abstract class AbstractService extends CatalogService
{
    const MAX_CONTAINER_NAME_LENGTH = 256;
    const MAX_OBJECT_NAME_LEN = 1024;
    const MAX_OBJECT_SIZE = 5102410241025;

    /**
     * @return Resource\Account
     */
    public function getAccount()
    {
        return new Resource\Account($this);
    }
}
PK)m]ߋ+""ObjectStore/Service.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\ObjectStore;

use Guzzle\Http\EntityBody;
use OpenCloud\Common\Constants\Header;
use OpenCloud\Common\Constants\Mime;
use OpenCloud\Common\Exceptions;
use OpenCloud\Common\Exceptions\InvalidArgumentError;
use OpenCloud\Common\Http\Client;
use OpenCloud\Common\Http\Message\Formatter;
use OpenCloud\Common\Log\Logger;
use OpenCloud\Common\Service\ServiceBuilder;
use OpenCloud\ObjectStore\Constants\UrlType;
use OpenCloud\ObjectStore\Resource\Container;
use OpenCloud\ObjectStore\Upload\ContainerMigration;

/**
 * The ObjectStore (Cloud Files) service.
 */
class Service extends AbstractService
{
    const DEFAULT_NAME = 'cloudFiles';
    const DEFAULT_TYPE = 'object-store';
    const BATCH_DELETE_MAX = 10000;

    /**
     * This holds the associated CDN service (for Rackspace public cloud)
     * or is NULL otherwise. The existence of an object here is
     * indicative that the CDN service is available.
     */
    private $cdnService;

    public function __construct(Client $client, $type = null, $name = null, $region = null, $urlType = null)
    {
        parent::__construct($client, $type, $name, $region, $urlType);

        try {
            $this->cdnService = ServiceBuilder::factory($client, 'OpenCloud\ObjectStore\CDNService', array(
                'region' => $region
            ));
        } catch (Exceptions\EndpointError $e) {
        }
    }

    /**
     * @return CDNService
     */
    public function getCdnService()
    {
        return $this->cdnService;
    }

    /**
     * List all available containers.
     *
     * @param array $filter
     * @return \OpenCloud\Common\Collection\PaginatedIterator
     */
    public function listContainers(array $filter = array())
    {
        $filter['format'] = 'json';
        return $this->resourceList('Container', $this->getUrl(null, $filter), $this);
    }

    /**
     * @param $data
     * @return Container
     */
    public function getContainer($data = null)
    {
        return new Container($this, $data);
    }

    /**
     * Create a container for this service.
     *
     * @param       $name     The name of the container
     * @param array $metadata Additional (optional) metadata to associate with the container
     * @return bool|static
     */
    public function createContainer($name, array $metadata = array())
    {
        $this->checkContainerName($name);

        $containerHeaders = Container::stockHeaders($metadata);

        $response = $this->getClient()
            ->put($this->getUrl($name), $containerHeaders)
            ->send();

        if ($response->getStatusCode() == 201) {
            return Container::fromResponse($response, $this);
        }

        return false;
    }

    /**
     * Check the validity of a potential container name.
     *
     * @param $name
     * @return bool
     * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
     */
    public function checkContainerName($name)
    {
        if (strlen($name) == 0) {
            $error = 'Container name cannot be blank';
        }

        if (strpos($name, '/') !== false) {
            $error = 'Container name cannot contain "/"';
        }

        if (strlen($name) > self::MAX_CONTAINER_NAME_LENGTH) {
            $error = 'Container name is too long';
        }

        if (isset($error)) {
            throw new InvalidArgumentError($error);
        }

        return true;
    }

    /**
     * Perform a bulk extraction, expanding an archive file. If the $path is an empty string, containers will be
     * auto-created accordingly, and files in the archive that do not map to any container (files in the base directory)
     * will be ignored. You can create up to 1,000 new containers per extraction request. Also note that only regular
     * files will be uploaded. Empty directories, symlinks, and so on, will not be uploaded.
     *
     * @param        $path        The path to the archive being extracted
     * @param        $archive     The contents of the archive (either string or stream)
     * @param string $archiveType The type of archive you're using {@see \OpenCloud\ObjectStore\Constants\UrlType}
     * @return \Guzzle\Http\Message\Response
     * @throws Exception\BulkOperationException
     * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
     */
    public function bulkExtract($path = '', $archive, $archiveType = UrlType::TAR_GZ)
    {
        $entity = EntityBody::factory($archive);

        $acceptableTypes = array(
            UrlType::TAR,
            UrlType::TAR_GZ,
            UrlType::TAR_BZ2
        );

        if (!in_array($archiveType, $acceptableTypes)) {
            throw new InvalidArgumentError(sprintf(
                'The archive type must be one of the following: [%s]. You provided [%s].',
                implode($acceptableTypes, ','),
                print_r($archiveType, true)
            ));
        }

        $url = $this->getUrl()->addPath($path)->setQuery(array('extract-archive' => $archiveType));
        $response = $this->getClient()->put($url, array(Header::CONTENT_TYPE => ''), $entity)->send();

        $body = Formatter::decode($response);

        if (!empty($body->Errors)) {
            throw new Exception\BulkOperationException((array) $body->Errors);
        }

        return $response;
    }

    /**
     * @deprecated Please use {@see batchDelete()} instead.
     */
    public function bulkDelete(array $paths)
    {
        $this->getLogger()->warning(Logger::deprecated(__METHOD__, '::batchDelete()'));

        return $this->executeBatchDeleteRequest($paths);
    }

    /**
     * Batch delete will delete an array of object paths. By default,
     * the API will only accept a maximum of 10,000 object deletions
     * per request - so for arrays that exceed this size, it is chunked
     * and sent as individual requests.
     *
     * @param array $paths The objects you want to delete. Each path needs
     *                     be formatted as /{containerName}/{objectName}. If
     *                     you are deleting object_1 and object_2 from the
     *                     photos_container, the array will be:
     *
     *                     array(
     *                        '/photos_container/object_1',
     *                        '/photos_container/object_2'
     *                     )
     *
     * @return array The array of responses from the API
     * @throws Exception\BulkOperationException
     */
    public function batchDelete(array $paths)
    {
        $chunks = array_chunk($paths, self::BATCH_DELETE_MAX);

        $responses = array();

        foreach ($chunks as $chunk) {
            $responses[] = $this->executeBatchDeleteRequest($chunk);
        }

        return $responses;
    }

    /**
     * Internal method for dispatching single batch delete requests.
     *
     * @param array $paths
     * @return \Guzzle\Http\Message\Response
     * @throws Exception\BulkOperationException
     */
    private function executeBatchDeleteRequest(array $paths)
    {
        $entity = EntityBody::factory(implode(PHP_EOL, $paths));

        $url = $this->getUrl()->setQuery(array('bulk-delete' => true));

        $response = $this->getClient()
            ->delete($url, array(Header::CONTENT_TYPE => Mime::TEXT), $entity)
            ->send();

        try {
            $body = Formatter::decode($response);
            if (!empty($body->Errors)) {
                throw new Exception\BulkOperationException((array) $body->Errors);
            }
        } catch (Exceptions\JsonError $e) {
        }

        return $response;
    }

    /**
     * Allows files to be transferred from one container to another.
     *
     * @param Container $old Where you're moving files from
     * @param Container $new Where you're moving files to
     * @return array    Of PUT responses
     */
    public function migrateContainer(Container $old, Container $new, array $options = array())
    {
        $migration = ContainerMigration::factory($old, $new, $options);

        return $migration->transfer();
    }
}
PK)m]�N	��?�?
OpenStack.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud;

use Guzzle\Http\Url;
use OpenCloud\Common\Exceptions;
use OpenCloud\Common\Http\Client;
use OpenCloud\Common\Http\Message\Formatter;
use OpenCloud\Common\Http\Message\RequestSubscriber;
use OpenCloud\Common\Lang;
use OpenCloud\Common\Log\Logger;
use OpenCloud\Common\Service\Catalog;
use OpenCloud\Common\Service\ServiceBuilder;
use OpenCloud\Identity\Resource\Tenant;
use OpenCloud\Identity\Resource\Token;
use OpenCloud\Identity\Resource\User;
use OpenCloud\Identity\Service as IdentityService;
use Psr\Log\LoggerInterface;

define('RACKSPACE_US', 'https://identity.api.rackspacecloud.com/v2.0/');
define('RACKSPACE_UK', 'https://lon.identity.api.rackspacecloud.com/v2.0/');

/**
 * The main client of the library. This object is the central point of negotiation between your application and the
 * API because it handles all of the HTTP transactions required to perform operations. It also manages the services
 * for your application through convenient factory methods.
 */
class OpenStack extends Client
{
    /**
     * @var array Credentials passed in by the user
     */
    private $secret = array();

    /**
     * @var string The token produced by the API
     */
    private $token;

    /**
     * @var string The unique identifier for who's accessing the API
     */
    private $tenant;

    /**
     * @var \OpenCloud\Common\Service\Catalog The catalog of services which are provided by the API
     */
    private $catalog;

    /**
     * @var LoggerInterface The object responsible for logging output
     */
    private $logger;

    /**
     * @var string The endpoint URL used for authentication
     */
    private $authUrl;

    /**
     * @var \OpenCloud\Identity\Resource\User
     */
    private $user;

    public function __construct($url, array $secret, array $options = array())
    {
        if (isset($options['logger']) && $options['logger'] instanceof LoggerInterface) {
            $this->setLogger($options['logger']);
        }

        $this->setSecret($secret);
        $this->setAuthUrl($url);

        parent::__construct($url, $options);

        $this->addSubscriber(RequestSubscriber::getInstance());
        $this->setDefaultOption('headers/Accept', 'application/json');
    }

    /**
     * Set the credentials for the client
     *
     * @param array $secret
     * @return $this
     */
    public function setSecret(array $secret = array())
    {
        $this->secret = $secret;

        return $this;
    }

    /**
     * Get the secret.
     *
     * @return array
     */
    public function getSecret()
    {
        return $this->secret;
    }

    /**
     * Set the token. If a string is passed in, the SDK assumes you want to set the ID of the full Token object
     * and sets this property accordingly. For any other data type, it assumes you want to populate the Token object.
     * This ambiguity arises due to backwards compatibility.
     *
     * @param  string $token
     * @return $this
     */
    public function setToken($token)
    {
        $identity = IdentityService::factory($this);

        if (is_string($token)) {
            if (!$this->token) {
                $this->setTokenObject($identity->resource('Token'));
            }
            $this->token->setId($token);
        } else {
            $this->setTokenObject($identity->resource('Token', $token));
        }

        return $this;
    }

    /**
     * Get the token ID for this client.
     *
     * @return string
     */
    public function getToken()
    {
        return ($this->getTokenObject()) ? $this->getTokenObject()->getId() : null;
    }

    /**
     * Set the full token object
     */
    public function setTokenObject(Token $token)
    {
        $this->token = $token;
    }

    /**
     * Get the full token object.
     */
    public function getTokenObject()
    {
        return $this->token;
    }

    /**
     * @deprecated
     */
    public function setExpiration($expiration)
    {
        $this->getLogger()->warning(Logger::deprecated(__METHOD__, '::getTokenObject()->setExpires()'));
        if ($this->getTokenObject()) {
            $this->getTokenObject()->setExpires($expiration);
        }

        return $this;
    }

    /**
     * @deprecated
     */
    public function getExpiration()
    {
        $this->getLogger()->warning(Logger::deprecated(__METHOD__, '::getTokenObject()->getExpires()'));
        if ($this->getTokenObject()) {
            return $this->getTokenObject()->getExpires();
        }
    }

    /**
     * Set the tenant. If an integer or string is passed in, the SDK assumes you want to set the ID of the full
     * Tenant object and sets this property accordingly. For any other data type, it assumes you want to populate
     * the Tenant object. This ambiguity arises due to backwards compatibility.
     *
     * @param  mixed $tenant
     * @return $this
     */
    public function setTenant($tenant)
    {
        $identity = IdentityService::factory($this);

        if (is_numeric($tenant) || is_string($tenant)) {
            if (!$this->tenant) {
                $this->setTenantObject($identity->resource('Tenant'));
            }
            $this->tenant->setId($tenant);
        } else {
            $this->setTenantObject($identity->resource('Tenant', $tenant));
        }

        return $this;
    }

    /**
     * Returns the tenant ID only (backwards compatibility).
     *
     * @return string
     */
    public function getTenant()
    {
        return ($this->getTenantObject()) ? $this->getTenantObject()->getId() : null;
    }

    /**
     * Set the full Tenant object for this client.
     *
     * @param OpenCloud\Identity\Resource\Tenant $tenant
     */
    public function setTenantObject(Tenant $tenant)
    {
        $this->tenant = $tenant;
    }

    /**
     * Get the full Tenant object for this client.
     *
     * @return OpenCloud\Identity\Resource\Tenant
     */
    public function getTenantObject()
    {
        return $this->tenant;
    }

    /**
     * Set the service catalog.
     *
     * @param  mixed $catalog
     * @return $this
     */
    public function setCatalog($catalog)
    {
        $this->catalog = Catalog::factory($catalog);

        return $this;
    }

    /**
     * Get the service catalog.
     *
     * @return array
     */
    public function getCatalog()
    {
        return $this->catalog;
    }

    /**
     * @param LoggerInterface $logger
     *
     * @return $this
     */
    public function setLogger(LoggerInterface $logger)
    {
        $this->logger = $logger;

        return $this;
    }

    /**
     * @return LoggerInterface
     */
    public function getLogger()
    {
        if (null === $this->logger) {
            $this->setLogger(new Common\Log\Logger);
        }

        return $this->logger;
    }

    /**
     * @return bool
     */
    public function hasLogger()
    {
        return (null !== $this->logger);
    }

    /**
     * @deprecated
     */
    public function hasExpired()
    {
        $this->getLogger()->warning(Logger::deprecated(__METHOD__, 'getTokenObject()->hasExpired()'));

        return $this->getTokenObject() && $this->getTokenObject()->hasExpired();
    }

    /**
     * Formats the credentials array (as a string) for authentication
     *
     * @return string
     * @throws Common\Exceptions\CredentialError
     */
    public function getCredentials()
    {
        if (!empty($this->secret['username']) && !empty($this->secret['password'])) {
            $credentials = array('auth' => array(
                'passwordCredentials' => array(
                    'username' => $this->secret['username'],
                    'password' => $this->secret['password']
                )
            ));

            if (!empty($this->secret['tenantName'])) {
                $credentials['auth']['tenantName'] = $this->secret['tenantName'];
            } elseif (!empty($this->secret['tenantId'])) {
                $credentials['auth']['tenantId'] = $this->secret['tenantId'];
            }

            return json_encode($credentials);
        } else {
            throw new Exceptions\CredentialError(
                Lang::translate('Unrecognized credential secret')
            );
        }
    }

    /**
     * @param $url
     * @return $this
     */
    public function setAuthUrl($url)
    {
        $this->authUrl = Url::factory($url);

        return $this;
    }

    /**
     * @return Url
     */
    public function getAuthUrl()
    {
        return $this->authUrl;
    }

    /**
     * Sets the current user based on the generated token.
     *
     * @param $data Object of user data
     */
    public function setUser(User $user)
    {
        $this->user = $user;
    }

    /**
     * @return \OpenCloud\Identity\Resource\User
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * Authenticate the tenant using the supplied credentials
     *
     * @return void
     * @throws AuthenticationError
     */
    public function authenticate()
    {
        // OpenStack APIs will return a 401 if an expired X-Auth-Token is sent,
        // so we need to reset the value before authenticating for another one.
        $this->updateTokenHeader('');

        $identity = IdentityService::factory($this);
        $response = $identity->generateToken($this->getCredentials());

        $body = Formatter::decode($response);

        $this->setCatalog($body->access->serviceCatalog);
        $this->setTokenObject($identity->resource('Token', $body->access->token));
        $this->setUser($identity->resource('User', $body->access->user));

        if (isset($body->access->token->tenant)) {
            $this->setTenantObject($identity->resource('Tenant', $body->access->token->tenant));
        }

        // Set X-Auth-Token HTTP request header
        $this->updateTokenHeader($this->getToken());
    }

    /**
     * @deprecated
     */
    public function getUrl()
    {
        return $this->getBaseUrl();
    }

    /**
     * Convenience method for exporting current credentials. Useful for local caching.
     * @return array
     */
    public function exportCredentials()
    {
        if ($this->hasExpired()) {
            $this->authenticate();
        }

        return array(
            'token'      => $this->getToken(),
            'expiration' => $this->getExpiration(),
            'tenant'     => $this->getTenant(),
            'catalog'    => $this->getCatalog()
        );
    }

    /**
     * Convenience method for importing credentials. Useful for local caching because it reduces HTTP traffic.
     *
     * @param array $values
     */
    public function importCredentials(array $values)
    {
        if (!empty($values['token'])) {
            $this->setToken($values['token']);
            $this->updateTokenHeader($this->getToken());
        }
        if (!empty($values['expiration'])) {
            $this->setExpiration($values['expiration']);
        }
        if (!empty($values['tenant'])) {
            $this->setTenant($values['tenant']);
        }
        if (!empty($values['catalog'])) {
            $this->setCatalog($values['catalog']);
        }
    }

    /**
     * Sets the X-Auth-Token header. If no value is explicitly passed in, the current token is used.
     *
     * @param  string $token Value of header.
     * @return void
     */
    private function updateTokenHeader($token)
    {
        $this->setDefaultOption('headers/X-Auth-Token', (string) $token);
    }

    /**
     * Creates a new ObjectStore object (Swift/Cloud Files)
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\ObjectStore\Service
     */
    public function objectStoreService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\ObjectStore\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new Compute object (Nova/Cloud Servers)
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\Compute\Service
     */
    public function computeService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\Compute\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new Orchestration (Heat) service object
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\Orchestration\Service
     * @codeCoverageIgnore
     */
    public function orchestrationService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\Orchestration\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new Volume (Cinder) service object
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\Volume\Service
     */
    public function volumeService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\Volume\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new Rackspace "Cloud Identity" service.
     *
     * @return \OpenCloud\Identity\Service
     */
    public function identityService()
    {
        $service = IdentityService::factory($this);
        $this->authenticate();

        return $service;
    }

    /**
     * Creates a new Glance service
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return Common\Service\ServiceInterface
     */
    public function imageService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\Image\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }

    /**
     * Creates a new Networking (Neutron) service object
     *
     * @param string $name    The name of the service as it appears in the Catalog
     * @param string $region  The region (DFW, IAD, ORD, LON, SYD)
     * @param string $urltype The URL type ("publicURL" or "internalURL")
     * @return \OpenCloud\Networking\Service
     * @codeCoverageIgnore
     */
    public function networkingService($name = null, $region = null, $urltype = null)
    {
        return ServiceBuilder::factory($this, 'OpenCloud\Networking\Service', array(
            'name'    => $name,
            'region'  => $region,
            'urlType' => $urltype
        ));
    }
}
PK)m]�@��	.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m]GuYv��Identity/Constants/User.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Identity\Constants;

class User
{
    const MODE_NAME = 'name';
    const MODE_EMAIL = 'email';
    const MODE_ID = 'id';
}
PK)m]�@��Identity/Constants/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m])��::Identity/Service.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Identity;

use Guzzle\Http\ClientInterface;
use OpenCloud\Common\Base;
use OpenCloud\Common\Collection\PaginatedIterator;
use OpenCloud\Common\Collection\ResourceIterator;
use OpenCloud\Common\Http\Message\Formatter;
use OpenCloud\Common\Service\AbstractService;
use OpenCloud\Identity\Constants\User as UserConst;
use OpenCloud\OpenStack;

/**
 * Class responsible for working with Rackspace's Cloud Identity service.
 *
 * @package OpenCloud\Identity
 */
class Service extends AbstractService
{
    /**
     * Factory method which allows for easy service creation
     *
     * @param  ClientInterface $client
     * @return self
     */
    public static function factory(ClientInterface $client)
    {
        $identity = new self();

        if (($client instanceof Base || $client instanceof OpenStack) && $client->hasLogger()) {
            $identity->setLogger($client->getLogger());
        }

        $identity->setClient($client);
        $identity->setEndpoint(clone $client->getAuthUrl());

        return $identity;
    }

    /**
     * Get this service's URL, with appended path if necessary.
     *
     * @return \Guzzle\Http\Url
     */
    public function getUrl($path = null)
    {
        $url = clone $this->getEndpoint();

        if ($path) {
            $url->addPath($path);
        }

        return $url;
    }

    /**
     * Get all users for the current tenant.
     *
     * @return \OpenCloud\Common\Collection\ResourceIterator
     */
    public function getUsers()
    {
        $response = $this->getClient()->get($this->getUrl('users'))->send();

        if ($body = Formatter::decode($response)) {
            return ResourceIterator::factory($this, array(
                'resourceClass'  => 'User',
                'key.collection' => 'users'
            ), $body->users);
        }
    }

    /**
     * Used for iterator resource instantation.
     */
    public function user($info = null)
    {
        return $this->resource('User', $info);
    }

    /**
     * Get a user based on a particular keyword and a certain search mode.
     *
     * @param $search string Keyword
     * @param $mode   string Either 'name', 'userId' or 'email'
     * @return \OpenCloud\Identity\Resource\User
     */
    public function getUser($search, $mode = UserConst::MODE_NAME)
    {
        $url = $this->getUrl('users');

        switch ($mode) {
            default:
            case UserConst::MODE_NAME:
                $url->setQuery(array('name' => $search));
                break;
            case UserConst::MODE_ID:
                $url->addPath($search);
                break;
            case UserConst::MODE_EMAIL:
                $url->setQuery(array('email' => $search));
                break;
        }

        $user = $this->resource('User');
        $user->refreshFromLocationUrl($url);

        return $user;
    }

    /**
     * Create a new user with provided params.
     *
     * @param  $params array User data
     * @return \OpenCloud\Identity\Resource\User
     */
    public function createUser(array $params)
    {
        $user = $this->resource('User');
        $user->create($params);

        return $user;
    }

    /**
     * Get all possible roles.
     *
     * @return \OpenCloud\Common\Collection\PaginatedIterator
     */
    public function getRoles()
    {
        return PaginatedIterator::factory($this, array(
            'resourceClass'  => 'Role',
            'baseUrl'        => $this->getUrl()->addPath('OS-KSADM')->addPath('roles'),
            'key.marker'     => 'id',
            'key.collection' => 'roles'
        ));
    }

    /**
     * Get a specific role.
     *
     * @param $roleId string The ID of the role you're looking for
     * @return \OpenCloud\Identity\Resource\Role
     */
    public function getRole($roleId)
    {
        return $this->resource('Role', $roleId);
    }

    /**
     * Generate a new token for a given user.
     *
     * @param   $json    string The JSON data-structure used in the HTTP entity body when POSTing to the API
     * @headers $headers array  Additional headers to send (optional)
     * @return  \Guzzle\Http\Message\Response
     */
    public function generateToken($json, array $headers = array())
    {
        $url = $this->getUrl();
        $url->addPath('tokens');

        $headers += self::getJsonHeader();

        return $this->getClient()->post($url, $headers, $json)->send();
    }

    /**
     * Revoke a given token based on its ID
     *
     * @param $tokenId string Token ID
     * @return \Guzzle\Http\Message\Response
     */
    public function revokeToken($tokenId)
    {
        $token = $this->resource('Token');
        $token->setId($tokenId);

        return $token->delete();
    }

    /**
     * List over all the tenants for this cloud account.
     *
     * @return \OpenCloud\Common\Collection\ResourceIterator
     */
    public function getTenants()
    {
        $url = $this->getUrl();
        $url->addPath('tenants');

        $response = $this->getClient()->get($url)->send();

        if ($body = Formatter::decode($response)) {
            return ResourceIterator::factory($this, array(
                'resourceClass'  => 'Tenant',
                'key.collection' => 'tenants'
            ), $body->tenants);
        }
    }
}
PK)m]�@��Identity/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK)m]
R�ppIdentity/Resource/Token.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Identity\Resource;

use OpenCloud\Common\PersistentObject;

/**
 * Token class for token functionality.
 *
 * A token is an opaque string that represents an authorization to access cloud resources. Tokens may be revoked at any
 * time and are valid for a finite duration.
 *
 * @package OpenCloud\Identity\Resource
 */
class Token extends PersistentObject
{
    /** @var string The token ID */
    private $id;

    /** @var string Timestamp of when this token will expire */
    private $expires;

    protected static $url_resource = 'tokens';

    /**
     * @param $id Sets the ID
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @return string Returns the ID
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param $expires Set the expiry timestamp
     */
    public function setExpires($expires)
    {
        $this->expires = $expires;
    }

    /**
     * @return string Get the expiry timestamp
     */
    public function getExpires()
    {
        return $this->expires;
    }

    /**
     * @return bool Check whether this token has expired (i.e. still valid or not)
     */
    public function hasExpired()
    {
        return time() >= strtotime($this->expires);
    }
}
PK)m]/c�ͭ#�#Identity/Resource/User.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Identity\Resource;

use OpenCloud\Common\Collection\PaginatedIterator;
use OpenCloud\Common\Http\Message\Formatter;
use OpenCloud\Common\PersistentObject;
use OpenCloud\Rackspace;

/**
 * User class which encapsulates functionality for a user.
 *
 * A user is a digital representation of a person, system, or service who consumes cloud services. Users have
 * credentials and may be assigned tokens; based on these credentials and tokens, the authentication service validates
 * that incoming requests are being made by the user who claims to be making the request, and that the user has the
 * right to access the requested resources. Users may be directly assigned to a particular tenant and behave as if they
 * are contained within that tenant.
 *
 * @package OpenCloud\Identity\Resource
 */
class User extends PersistentObject
{
    /** @var string The default region for this region. Can be ORD, DFW, IAD, LON, HKG or SYD */
    private $defaultRegion;

    /** @var string */
    private $domainId;

    /** @var int The ID of this user */
    private $id;

    /** @var string The username of this user */
    private $username;

    /** @var string The email address of this user */
    private $email;

    /** @var bool Whether or not this user is enabled or not */
    private $enabled;

    /** @var string The string password for this user */
    private $password;

    protected $createKeys = array('username', 'email', 'enabled', 'password');
    protected $updateKeys = array('username', 'email', 'enabled', 'RAX-AUTH:defaultRegion', 'RAX-AUTH:domainId', 'id');

    protected $aliases = array(
        'name'                   => 'username',
        'RAX-AUTH:defaultRegion' => 'defaultRegion',
        'RAX-AUTH:domainId'      => 'domainId',
        'OS-KSADM:password'      => 'password'
    );

    protected static $url_resource = 'users';
    protected static $json_name = 'user';

    public function createJson()
    {
        $json = parent::createJson();

        if ($this->getClient() instanceof Rackspace) {
            $json->user->username = $json->user->name;
            unset($json->user->name);
        }

        return $json;
    }

    /**
     * @param $region Set the default region
     */
    public function setDefaultRegion($region)
    {
        $this->defaultRegion = $region;
    }

    /**
     * @return string Get the default region
     */
    public function getDefaultRegion()
    {
        return $this->defaultRegion;
    }

    /**
     * @param $domainId Set the domain ID
     */
    public function setDomainId($domainId)
    {
        $this->domainId = $domainId;
    }

    /**
     * @return string Get the domain ID
     */
    public function getDomainId()
    {
        return $this->domainId;
    }

    /**
     * @param $id Set the ID
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @return int Get the ID
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param $username Set the username
     */
    public function setUsername($username)
    {
        $this->username = $username;
    }

    /**
     * @return string Get the username
     */
    public function getUsername()
    {
        return $this->username;
    }

    /**
     * @param $email Sets the email
     */
    public function setEmail($email)
    {
        $this->email = $email;
    }

    /**
     * @return string Get the email
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * @param $enabled Sets the enabled flag
     */
    public function setEnabled($enabled)
    {
        $this->enabled = $enabled;
    }

    /**
     * @return bool Get the enabled flag
     */
    public function getEnabled()
    {
        return $this->enabled;
    }

    /**
     * @return bool Check whether this user is enabled or not
     */
    public function isEnabled()
    {
        return $this->enabled === true;
    }

    /**
     * @param $password Set the password
     */
    public function setPassword($password)
    {
        $this->password = $password;
    }

    /**
     * @return string Get the password
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * @return string
     */
    public function primaryKeyField()
    {
        return 'id';
    }

    public function updateJson($params = array())
    {
        $array = array();
        foreach ($this->updateKeys as $key) {
            if (isset($this->$key)) {
                $array[$key] = $this->$key;
            }
        }

        return (object) array('user' => $array);
    }

    /**
     * This operation will set the user's password to a new value.
     *
     * @param $newPassword The new password to use for this user
     * @return \Guzzle\Http\Message\Response
     */
    public function updatePassword($newPassword)
    {
        $array = array(
            'username'          => $this->username,
            'OS-KSADM:password' => $newPassword
        );

        $json = json_encode((object) array('user' => $array));

        return $this->getClient()->post($this->getUrl(), self::getJsonHeader(), $json)->send();
    }

    /**
     * This operation lists a user's non-password credentials for all authentication methods available to the user.
     *
     * @return array|null
     */
    public function getOtherCredentials()
    {
        $url = $this->getUrl();
        $url->addPath('OS-KSADM')->addPath('credentials');

        $response = $this->getClient()->get($url)->send();

        if ($body = Formatter::decode($response)) {
            return isset($body->credentials) ? $body->credentials : null;
        }
    }

    /**
     * Get the API key for this user.
     *
     * @return string|null
     */
    public function getApiKey()
    {
        $url = $this->getUrl();
        $url->addPath('OS-KSADM')->addPath('credentials')->addPath('RAX-KSKEY:apiKeyCredentials');

        $response = $this->getClient()->get($url)->send();

        if ($body = Formatter::decode($response)) {
            return isset($body->{'RAX-KSKEY:apiKeyCredentials'}->apiKey)
                ? $body->{'RAX-KSKEY:apiKeyCredentials'}->apiKey
                : null;
        }
    }

    /**
     * Reset the API key for this user to a new arbitrary value (which is returned).
     *
     * @return string|null
     */
    public function resetApiKey()
    {
        $url = $this->getUrl();
        $url->addPath('OS-KSADM')
            ->addPath('credentials')
            ->addPath('RAX-KSKEY:apiKeyCredentials')
            ->addPath('RAX-AUTH')
            ->addPath('reset');

        $response = $this->getClient()->post($url)->send();

        if ($body = Formatter::decode($response)) {
            return isset($body->{'RAX-KSKEY:apiKeyCredentials'}->apiKey)
                ? $body->{'RAX-KSKEY:apiKeyCredentials'}->apiKey
                : null;
        }
    }

    /**
     * Add a role, specified by its ID, to a user.
     *
     * @param $roleId
     * @return \Guzzle\Http\Message\Response
     */
    public function addRole($roleId)
    {
        $url = $this->getUrl();
        $url->addPath('roles')->addPath('OS-KSADM')->addPath($roleId);

        return $this->getClient()->put($url)->send();
    }

    /**
     * Remove a role, specified by its ID, from a user.
     *
     * @param $roleId
     * @return \Guzzle\Http\Message\Response
     */
    public function removeRole($roleId)
    {
        $url = $this->getUrl();
        $url->addPath('roles')->addPath('OS-KSADM')->addPath($roleId);

        return $this->getClient()->delete($url)->send();
    }

    /**
     * Get all the roles for which this user is associated with.
     *
     * @return \OpenCloud\Common\Collection\PaginatedIterator
     */
    public function getRoles()
    {
        $url = $this->getUrl();
        $url->addPath('roles');

        return PaginatedIterator::factory($this, array(
            'baseUrl'        => $url,
            'resourceClass'  => 'Role',
            'key.collection' => 'roles',
            'key.links'      => 'roles_links'
        ));
    }

    public function update($params = array())
    {
        if (!empty($params)) {
            $this->populate($params);
        }

        $json = json_encode($this->updateJson($params));
        $this->checkJsonError();

        return $this->getClient()->post($this->getUrl(), self::getJsonHeader(), $json)->send();
    }
}
PK)m]�̦�	�	Identity/Resource/Tenant.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Identity\Resource;

use OpenCloud\Common\PersistentObject;

/**
 * Tenant class for tenant functionality.
 *
 * A tenant is a container used to group or isolate resources and/or identity objects. Depending on the service
 * operator, a tenant may map to a customer, account, organization, or project.
 *
 * @package OpenCloud\Identity\Resource
 */
class Tenant extends PersistentObject
{
    /** @var int The tenant ID */
    private $id;

    /** @var string The tenant name */
    private $name;

    /** @var string A description of the tenant */
    private $description;

    /** @var bool Whether this tenant is enabled or not (i.e. whether it can fulfil API operations) */
    private $enabled;

    protected static $url_resource = 'tenants';
    protected static $json_name = 'tenants';

    /**
     * @param $id Sets the ID
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @return string Returns the ID
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param $name Sets the name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @return string Returns the name
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param $description Sets the description
     */
    public function setDescription($description)
    {
        $this->description = $description;
    }

    /**
     * @return string Returns the description
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * @param $enabled Enables/disables the tenant
     */
    public function setEnabled($enabled)
    {
        $this->enabled = $enabled;
    }

    /**
     * @return bool Checks whether this tenant is enabled or not
     */
    public function isEnabled()
    {
        return $this->enabled === true;
    }
}
PK)m]���	�	Identity/Resource/Role.phpnu&1i�<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\Identity\Resource;

use OpenCloud\Common\PersistentObject;

/**
 * A role object represents a role that a User has.
 *
 * A role is a personality that a user assumes when performing a
 * specific set of operations. A role includes a set of rights and privileges. A user assuming a role inherits the
 * rights and privileges associated with the role. A token that is issued to a user includes the list of roles the user
 * can assume. When a user calls a service, that service determines how to interpret a user's roles. A role that grants
 * access to a list of operations or resources within one service may grant access to a completely different list when
 * interpreted by a different service.
 *
 * @package OpenCloud\Identity\Resource
 */
class Role extends PersistentObject
{
    /** @var string The role ID */
    private $id;

    /** @var string The role name */
    private $name;

    /** @var string The role description */
    private $description;

    protected static $url_resource = 'OS-KSADM/roles';
    protected static $json_name = 'role';

    /**
     * @param $id Sets the ID
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @return string Returns the ID
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param $name Sets the name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @return string Returns the name
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param $description Sets the description
     */
    public function setDescription($description)
    {
        $this->description = $description;
    }

    /**
     * @return string Returns the description
     */
    public function getDescription()
    {
        return $this->description;
    }
}
PK)m]�@��Identity/Resource/.htaccessnu��6�$<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>PK(m]��01""Version.phpnu&1i�PK(m]��	��]Common/Log/Logger.phpnu&1i�PK(m]�@��kCommon/Log/.htaccessnu��6�$PK(m]](b�,�,�Common/Collection.phpnu&1i�PK(m]3)P4P4�JCommon/Base.phpnu&1i�PK(m]�@��CCommon/.htaccessnu��6�$PK(m]�r��VV%��Common/Collection/ArrayCollection.phpnu&1i�PK(m]��n�1"1"'B�Common/Collection/PaginatedIterator.phpnu&1i�PK(m]��k��&ʪCommon/Collection/ResourceIterator.phpnu&1i�PK(m]�@����Common/Collection/.htaccessnu��6�$PK(m]@��C��!]�Common/Service/ServiceBuilder.phpnu&1i�PK(m]�Z�F��z�Common/Service/Catalog.phpnu&1i�PK(m],p�ԓ�#N�Common/Service/ServiceInterface.phpnu&1i�PK(m]2�^[
[
4�Common/Service/CatalogItem.phpnu&1i�PK(m]�w����Common/Service/Endpoint.phpnu&1i�PK(m]�����Common/Service/NovaService.phpnu&1i�PK(m]�@���Common/Service/.htaccessnu��6�$PK(m]��WW"Common/Service/AbstractService.phpnu&1i�PK(m]�2;S!�Common/Service/CatalogService.phpnu&1i�PK(m]rȗH��(9Common/ArrayAccess.phpnu&1i�PK(m]�8]���1>Common/Lang.phpnu&1i�PK(m]
��U��BCommon/Constants/Size.phpnu&1i�PK(m]�6�\ECommon/Constants/State.phpnu&1i�PK(m]ĝe���HCommon/Constants/Service.phpnu&1i�PK(m]S�a���KCommon/Constants/Mime.phpnu&1i�PK(m]�
��OCommon/Constants/Datetime.phpnu&1i�PK(m]�@��.SCommon/Constants/.htaccessnu��6�$PK(m]ٻoU�	�	�TCommon/Constants/Header.phpnu&1i�PK(m]�@���^Common/Http/Message/.htaccessnu��6�$PK(m]\Uו!	`Common/Http/Message/Formatter.phpnu&1i�PK(m]��\~~)xfCommon/Http/Message/RequestSubscriber.phpnu&1i�PK(m]!^��OlCommon/Http/Client.phpnu&1i�PK(m]�@��^sCommon/Http/.htaccessnu��6�$PK(m]l<§�tCommon/Metadata.phpnu&1i�PK(m]ZR[��"��Common/Exceptions/NetworkError.phpnu&1i�PK(m]O*�<���Common/Exceptions/IOError.phpnu&1i�PK(m]��+��&�Common/Exceptions/HttpTimeoutError.phpnu&1i�PK(m]?r����"�Common/Exceptions/UnknownError.phpnu&1i�PK(m].t�K��#�Common/Exceptions/UserListError.phpnu&1i�PK(m]�l��!!�Common/Exceptions/UpdateError.phpnu&1i�PK(m]�U���(&�Common/Exceptions/EmptyResponseError.phpnu&1i�PK(m]�Dp��$9�Common/Exceptions/AttributeError.phpnu&1i�PK(m]W����-D�Common/Exceptions/ResourceBucketException.phpnu&1i�PK(m]\Y-Y��'a�Common/Exceptions/AsyncTimeoutError.phpnu&1i�PK(m]/xrB��%r�Common/Exceptions/UserUpdateError.phpnu&1i�PK(m]��<��-�Common/Exceptions/MisMatchedChecksumError.phpnu&1i�PK(m]
�J���)��Common/Exceptions/DatabaseCreateError.phpnu&1i�PK(m]-����+��Common/Exceptions/UnknownParameterError.phpnu&1i�PK(m]t6u(��!ʫCommon/Exceptions/VolumeError.phpnu&1i�PK(m]�@���'ϮCommon/Exceptions/MissingValueError.phpnu&1i�PK(m]��Hg��#�Common/Exceptions/MetadataError.phpnu&1i�PK(m]z���#�Common/Exceptions/EndpointError.phpnu&1i�PK(m]��׻�(�Common/Exceptions/HttpForbiddenError.phpnu&1i�PK(m]\P��)�Common/Exceptions/InstanceDeleteError.phpnu&1i�PK(m]:?a`��$�Common/Exceptions/ServerUrlError.phpnu&1i�PK(m]��-��%%�Common/Exceptions/IdRequiredError.phpnu&1i�PK(m]}3eָ�%2�Common/Exceptions/ObjectCopyError.phpnu&1i�PK(m]��3D��?�Common/Exceptions/HttpError.phpnu&1i�PK(m]n�J��)@�Common/Exceptions/MetadataCreateError.phpnu&1i�PK(m]�@��U�Common/Exceptions/.htaccessnu��6�$PK(m]����&��Common/Exceptions/LoggingException.phpnu&1i�PK(m]�#Y��,��Common/Exceptions/ContainerNotFoundError.phpnu&1i�PK(m]��a��(��Common/Exceptions/NoContentTypeError.phpnu&1i�PK(m]�
Ȼ�(�Common/Exceptions/NetworkUpdateError.phpnu&1i�PK(m]�o���)�Common/Exceptions/MetadataPrefixError.phpnu&1i�PK(m]_�+��'(�Common/Exceptions/ServerDeleteError.phpnu&1i�PK(m]�G���#9�Common/Exceptions/InstanceError.phpnu&1i�PK(m]߹����,B�Common/Exceptions/ContainerNotEmptyError.phpnu&1i�PK(m]��$��#]�Common/Exceptions/SnapshotError.phpnu&1i�PK(m]pC�3��(f�Common/Exceptions/HttpOverLimitError.phpnu&1i�PK(m]��BV��.y�Common/Exceptions/UnrecognizedServiceError.phpnu&1i�PK(m]�踼�)��Common/Exceptions/MetadataDeleteError.phpnu&1i�PK(m]ff��'��Common/Exceptions/ServerActionError.phpnu&1i�PK(m]��ٺ�'��Common/Exceptions/ServerCreateError.phpnu&1i�PK(m]���5��%�Common/Exceptions/VolumeTypeError.phpnu&1i�PK(m]�����)�Common/Exceptions/CollectionException.phpnu&1i�PK(m]�����)�Common/Exceptions/InstanceCreateError.phpnu&1i�PK(m]�I6Ĺ�&Common/Exceptions/InstanceNotFound.phpnu&1i�PK(m]��ʚ��!Common/Exceptions/FlavorError.phpnu&1i�PK(m]�^�3��)	Common/Exceptions/DatabaseDeleteError.phpnu&1i�PK(m]6���LL+/Common/Exceptions/HttpResponseException.phpnu&1i�PK(m],ڏ�1�Common/Exceptions/ForbiddenOperationException.phpnu&1i�PK(m]BD���&�Common/Exceptions/MetadataKeyError.phpnu&1i�PK(m]j��ǽ�*�Common/Exceptions/CdnNotAvailableError.phpnu&1i�PK(m]�����"�Common/Exceptions/CdnHttpError.phpnu&1i�PK(m]��6��#�Common/Exceptions/UserNameError.phpnu&1i�PK(m]p���(�Common/Exceptions/InvalidIpTypeError.phpnu&1i�PK(m]�!���%#Common/Exceptions/RecordTypeError.phpnu&1i�PK(m]�'v۵�"&Common/Exceptions/HttpUrlError.phpnu&1i�PK(m]
C����'#)Common/Exceptions/CreateUpdateError.phpnu&1i�PK(m]�s���*4,Common/Exceptions/ContainerDeleteError.phpnu&1i�PK(m]�DL��%K/Common/Exceptions/UserDeleteError.phpnu&1i�PK(m]+R����-X2Common/Exceptions/UnsupportedVersionError.phpnu&1i�PK)m]:�Ĵ�!u5Common/Exceptions/NoNameError.phpnu&1i�PK)m]���-��z8Common/Exceptions/UrlError.phpnu&1i�PK)m]=F>S��#y;Common/Exceptions/DocumentError.phpnu&1i�PK)m]�����%�>Common/Exceptions/ServerJsonError.phpnu&1i�PK)m]�'�>��!�ACommon/Exceptions/DomainError.phpnu&1i�PK)m]ھ:���#�DCommon/Exceptions/BaseException.phpnu&1i�PK)m]���&�GCommon/Exceptions/RuntimeException.phpnu&1i�PK)m]~t�9��1�JCommon/Exceptions/UnsupportedFeatureExtension.phpnu&1i�PK)m]����)�MCommon/Exceptions/InvalidRequestError.phpnu&1i�PK)m]��v��$�PCommon/Exceptions/HttpRetryError.phpnu&1i�PK)m]�;Z��!�SCommon/Exceptions/DeleteError.phpnu&1i�PK)m]�U��%�VCommon/Exceptions/NetworkUrlError.phpnu&1i�PK)m]�ɳͽ�*ZCommon/Exceptions/InvalidArgumentError.phpnu&1i�PK)m]YV��(]Common/Exceptions/InvalidIdTypeError.phpnu&1i�PK)m]�5ݳ� -`Common/Exceptions/AsyncError.phpnu&1i�PK)m]�Q���/0cCommon/Exceptions/ResourceNotFoundException.phpnu&1i�PK)m]��<ƻ�(5fCommon/Exceptions/NetworkDeleteError.phpnu&1i�PK)m]��/�� HiCommon/Exceptions/ImageError.phpnu&1i�PK)m]b3%��'KlCommon/Exceptions/ServerUpdateError.phpnu&1i�PK)m]4%���$\oCommon/Exceptions/ServerIpsError.phpnu&1i�PK)m]a�,^��)grCommon/Exceptions/InstanceUpdateError.phpnu&1i�PK)m]��-u��(|uCommon/Exceptions/ContainerNameError.phpnu&1i�PK)m]J�)���!�xCommon/Exceptions/ObjectError.phpnu&1i�PK)m]��"��(�{Common/Exceptions/TempUrlMethodError.phpnu&1i�PK)m]�ػw��'�~Common/Exceptions/DatabaseListError.phpnu&1i�PK)m]�aq���)��Common/Exceptions/AuthenticationError.phpnu&1i�PK)m]�0����%̈́Common/Exceptions/CredentialError.phpnu&1i�PK)m]�|�m��$ڇCommon/Exceptions/AsyncHttpError.phpnu&1i�PK)m]���u��#�Common/Exceptions/ObjFetchError.phpnu&1i�PK)m]��tɱ��Common/Exceptions/CdnError.phpnu&1i�PK)m]6���"�Common/Exceptions/RebuildError.phpnu&1i�PK)m]����+�Common/Exceptions/HttpUnauthorizedError.phpnu&1i�PK)m]q��
��'
�Common/Exceptions/DatabaseNameError.phpnu&1i�PK)m]CG$K��*�Common/Exceptions/InvalidTemplateError.phpnu&1i�PK)m]�S����/5�Common/Exceptions/UnsupportedExtensionError.phpnu&1i�PK)m]���E��V�Common/Exceptions/NameError.phpnu&1i�PK)m]l�H��$W�Common/Exceptions/ContainerError.phpnu&1i�PK)m]��޶��)b�Common/Exceptions/MetadataUpdateError.phpnu&1i�PK)m]+y����'w�Common/Exceptions/MetadataJsonError.phpnu&1i�PK)m]�4��(��Common/Exceptions/NetworkCreateError.phpnu&1i�PK)m]I���!��Common/Exceptions/CreateError.phpnu&1i�PK)m]+��ռ�)��Common/Exceptions/InstanceFlavorError.phpnu&1i�PK)m]���=��)��Common/Exceptions/DatabaseUpdateError.phpnu&1i�PK)m]t�'��*ʸCommon/Exceptions/ContainerCreateError.phpnu&1i�PK)m]�^��.�Common/Exceptions/ServerImageScheduleError.phpnu&1i�PK)m]�t����%�Common/Exceptions/UserCreateError.phpnu&1i�PK)m] mS���!
�Common/Exceptions/CdnTtlError.phpnu&1i�PK)m]�  ��&�Common/Exceptions/ServiceException.phpnu&1i�PK)m]	y�ڲ�!�Common/Exceptions/JsonError.phpnu&1i�PK)m]��xF��+"�Common/Exceptions/InvalidParameterError.phpnu&1i�PK)m]�H�,,;�Common/PersistentObject.phpnu&1i�PK)m]`�]cc ��Common/Resource/NovaResource.phpnu&1i�PK)m]l��UU$e�Common/Resource/ReadOnlyResource.phpnu&1i�PK)m]�@���Common/Resource/.htaccessnu��6�$PK)m]?V(y		 k�Common/Resource/BaseResource.phpnu&1i�PK)m]9f(++++&�Common/Resource/PersistentResource.phpnu&1i�PK)m]+��
E(Rackspace.phpnu&1i�PK)m]�F;�VV�AObjectStore/Enum/ReturnType.phpnu&1i�PK)m]�@��+EObjectStore/Enum/.htaccessnu��6�$PK)m]f۸�� �FObjectStore/Constants/Header.phpnu&1i�PK)m]�@���JObjectStore/Constants/.htaccessnu��6�$PK)m]񴌑��!LObjectStore/Constants/UrlType.phpnu&1i�PK)m]9�y�**'
PObjectStore/Upload/AbstractTransfer.phpnu&1i�PK)m]�@���gObjectStore/Upload/.htaccessnu��6�$PK)m]��Y�GG)�hObjectStore/Upload/ContainerMigration.phpnu&1i�PK)m]J$�]��#�ObjectStore/Upload/TransferPart.phpnu&1i�PK)m]f��		*אObjectStore/Upload/ConsecutiveTransfer.phpnu&1i�PK)m]X]�l@@$F�ObjectStore/Upload/DirectorySync.phpnu&1i�PK)m]Kf����$ڴObjectStore/Upload/TransferState.phpnu&1i�PK)m]� �ճ�&��ObjectStore/Upload/TransferBuilder.phpnu&1i�PK)m]"�*�
�
)�ObjectStore/Upload/ConcurrentTransfer.phpnu&1i�PK)m]���TTA�ObjectStore/CDNService.phpnu&1i�PK)m]
Jwͅ�1��ObjectStore/Exception/ObjectNotFoundException.phpnu&1i�PK)m]-�����,��ObjectStore/Exception/ContainerException.phpnu&1i�PK)m]�X���)��ObjectStore/Exception/StreamException.phpnu&1i�PK)m]��t<<)��ObjectStore/Exception/UploadException.phpnu&1i�PK)m]�6{��0��ObjectStore/Exception/BulkOperationException.phpnu&1i�PK)m]�@����ObjectStore/Exception/.htaccessnu��6�$PK)m]��[�
�
 G�ObjectStore/Resource/Account.phpnu&1i�PK)m]\��%%ObjectStore/Resource/CDNContainer.phpnu&1i�PK)m]
*���*�
ObjectStore/Resource/ContainerMetadata.phpnu&1i�PK)m]�@���ObjectStore/Resource/.htaccessnu��6�$PK)m]ɤ�Q�Q"ObjectStore/Resource/Container.phpnu&1i�PK)m]
��``)dObjectStore/Resource/AbstractResource.phpnu&1i�PK)m]FX�*�~ObjectStore/Resource/AbstractContainer.phpnu&1i�PK)m])L r�,�,#8�ObjectStore/Resource/DataObject.phpnu&1i�PK)m]�@��a�ObjectStore/.htaccessnu��6�$PK)m]"0�A����ObjectStore/AbstractService.phpnu&1i�PK)m]ߋ+""��ObjectStore/Service.phpnu&1i�PK)m]�N	��?�?
��OpenStack.phpnu&1i�PK)m]�@��	�$.htaccessnu��6�$PK)m]GuYv��+&Identity/Constants/User.phpnu&1i�PK)m]�@��i)Identity/Constants/.htaccessnu��6�$PK)m])��::�*Identity/Service.phpnu&1i�PK)m]�@��GBIdentity/.htaccessnu��6�$PK)m]
R�pp�CIdentity/Resource/Token.phpnu&1i�PK)m]/c�ͭ#�#XKIdentity/Resource/User.phpnu&1i�PK)m]�̦�	�	OoIdentity/Resource/Tenant.phpnu&1i�PK)m]���	�	�yIdentity/Resource/Role.phpnu&1i�PK)m]�@����Identity/Resource/.htaccessnu��6�$PK��@J�

Al-HUWAITI Shell