Skip to content

Commit 519a6d3

Browse files
committed
Merge pull request #583 from rackspace/working
Merging working into master in preparation for minor version bump
2 parents acb0a2f + 853dd17 commit 519a6d3

34 files changed

+763
-94
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ php:
33
- "5.6"
44
- "5.5"
55
- "5.4"
6-
- "5.3"
76
- hhvm
87

98
sudo: false
@@ -33,4 +32,4 @@ notifications:
3332
3433

3534
env:
36-
- secure: "bdrUeYb3nSGgBB+QtDZxUHVPw6B/wjb3KXLm8TgonWrQm4GPeWKK29qhmDnFZmQjwQPfuebe7wAk1ZxGoZKbEiELVpJJ+8XYVOt6W/6V53H31JL6FqiIE5+7qBwDe+9ziveM6GcTXHT1GI5mUeACIbeBDPZaNubIJH3U6MPim64="
35+
- secure: "bdrUeYb3nSGgBB+QtDZxUHVPw6B/wjb3KXLm8TgonWrQm4GPeWKK29qhmDnFZmQjwQPfuebe7wAk1ZxGoZKbEiELVpJJ+8XYVOt6W/6V53H31JL6FqiIE5+7qBwDe+9ziveM6GcTXHT1GI5mUeACIbeBDPZaNubIJH3U6MPim64="

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PHP SDK for OpenStack/Rackspace APIs
44

55
[![Latest Stable Version](https://poser.pugx.org/rackspace/php-opencloud/v/stable.png)](https://packagist.org/packages/rackspace/php-opencloud) [![Travis CI](https://secure.travis-ci.org/rackspace/php-opencloud.png)](https://travis-ci.org/rackspace/php-opencloud) [![Total Downloads](https://poser.pugx.org/rackspace/php-opencloud/downloads.png)](https://packagist.org/packages/rackspace/php-opencloud)
66

7-
For SDKs in different languages, see http://developer.rackspace.com.
7+
Our official documentation is now available on http://docs.php-opencloud.com. For SDKs in different languages, see http://developer.rackspace.com.
88

99
The PHP SDK should work with most OpenStack-based cloud deployments,
1010
though it specifically targets the Rackspace public cloud. In
@@ -16,9 +16,11 @@ so that you can still use the SDK with a pure OpenStack instance
1616

1717
Requirements
1818
------------
19-
* PHP >=5.3.3
19+
* PHP >=5.4
2020
* cURL extension for PHP
2121

22+
**Note**: Since PHP 5.3 has reached [end of life](http://php.net/eol.php) and is no longer officially supported, we are moving to 5.4 as a minimum requirement. If upgrading is not an option and you still need a stable version of the SDK for 5.3, please follow [this guide](http://docs.php-opencloud.com/en/latest/using-php-5.3).
23+
2224
Installation
2325
------------
2426
You must install this library through Composer:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727
},
2828
"require": {
29-
"php" : ">=5.3.3",
29+
"php" : ">=5.4",
3030
"guzzle/guzzle" : "~3.8",
3131
"psr/log": "~1.0"
3232
},
@@ -35,6 +35,6 @@
3535
"satooshi/php-coveralls": "0.6.*@dev",
3636
"jakub-onderka/php-parallel-lint": "0.*",
3737
"fabpot/php-cs-fixer": "1.0.*@dev",
38-
"apigen/apigen": "~2.8"
38+
"apigen/apigen": "~4.0"
3939
}
4040
}

doc/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Read the :doc:`getting-started-with-openstack` or
3030
:doc:`getting-started-with-rackspace` to help you get started with basic
3131
Compute operations.
3232

33+
.. note::
34+
35+
If you are running PHP 5.3, please see our :doc:`using-php-5.3` guide.
36+
3337
Services
3438
--------
3539

doc/services/common/service-args.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
default will be provided if you pass in ``null``.
44

55
* ``{region}`` is the region the service will operate in. For Rackspace
6-
users, you can select one of the following from the `supported regions page
7-
</regions>`_.
6+
users, you can select one of the following from the :doc:`supported regions page
7+
</regions>`.
88

9-
* ``{urlType}`` is the `type of URL </url-types>`_ to use, depending on which
9+
* ``{urlType}`` is the :doc:`type of URL </url-types>` to use, depending on which
1010
endpoints your catalog provides. If omitted, it will default to the public
1111
network.

doc/services/dns/domains.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ Modify domain
268268

269269
Only the TTL, email address and comment attributes of a domain can be modified.
270270
Records cannot be added, modified, or removed through this API operation - you
271-
will need to use the `add records <records#add-record>`__, `modify records
272-
<records#modify-record>`__ or `remove records <records#delete-record>`__
271+
will need to use the `add records <records.html#add-record>`__, `modify records
272+
<records.html#modify-record>`__ or `remove records <records.html#delete-record>`__
273273
operations respectively.
274274

275275
.. code-block:: php

doc/services/object-store/migrating-containers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ You can access all this functionality by executing:
6868
6969
7070
It's advisable to do this process in a Cloud Server in one of the two
71-
regions you're migrating to/from. This allows you to use ``privateURL``
71+
regions you're migrating to/from. This allows you to use ``internalURL``
7272
as the third argument in the ``objectStoreService`` methods like this:
7373

7474
.. code-block:: php
7575
76-
$client->objectStoreService('cloudFiles', 'IAD', 'privateURL');
76+
$client->objectStoreService('cloudFiles', 'IAD', 'internalURL');
7777
7878
7979
This will ensure that traffic between your server and your new IAD

doc/services/object-store/objects.rst

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,42 @@ docs <http://docs.openstack.org/api/openstack-object-storage/1.0/content/list-ob
177177
`Get the executable PHP script for this example <https://raw.githubusercontent.com/rackspace/php-opencloud/master/samples/ObjectStore/list-objects.php>`_
178178

179179

180+
List over 10,000 objects
181+
------------------------
182+
183+
To retrieve more than 10,000 objects (the default limit), you'll need to use
184+
the built-in paging which uses a 'marker' parameter to fetch the next page of data.
185+
186+
.. code-block:: php
187+
188+
$containerObjects = array();
189+
$marker = '';
190+
191+
while ($marker !== null) {
192+
$params = array(
193+
'marker' => $marker,
194+
);
195+
196+
$objects = $container->objectList($params);
197+
$total = $objects->count();
198+
$count = 0;
199+
200+
if ($total == 0) {
201+
break;
202+
}
203+
204+
foreach ($objects as $object) {
205+
/** @var $object OpenCloud\ObjectStore\Resource\DataObject **/
206+
$containerObjects[] = $object->getName();
207+
$count++;
208+
209+
$marker = ($count == $total) ? $object->getName() : null;
210+
}
211+
}
212+
213+
`Get the executable PHP script for this example <https://raw.githubusercontent.com/rackspace/php-opencloud/master/samples/ObjectStore/list-objects-over-10000.php>`_
214+
215+
180216
Get object
181217
----------
182218

@@ -204,8 +240,8 @@ Get file name
204240

205241
.. code-block:: php
206242
207-
/** @param $container OpenCloud\ObjectStore\Resource\Container */
208-
$container = $object->getContainer();
243+
/** @param $name string */
244+
$name = $object->getName();
209245
210246
211247
Get file size
@@ -326,6 +362,41 @@ the name of the object inside the container that does not exist yet.
326362
`Get the executable PHP script for this example <https://raw.githubusercontent.com/rackspace/php-opencloud/master/samples/ObjectStore/copy-object.php>`_
327363

328364

365+
Symlinking to this object from another location
366+
-----------------------------------------------
367+
368+
To create a symlink to this file in another location you need to specify
369+
a string-based source
370+
371+
.. code-block:: php
372+
373+
$object->createSymlinkFrom('/container_2/new_object_name');
374+
375+
Where ``container_2`` is the name of the container, and ``new_object_name`` is
376+
the name of the object inside the container that either does not exist yet or
377+
is an empty file.
378+
379+
`Get the executable PHP script for this example <https://raw.githubusercontent.com/rackspace/php-opencloud/master/samples/ObjectStore/symlink-object.php>`_
380+
381+
382+
Setting this object to symlink to another location
383+
--------------------------------------------------
384+
385+
To set this file to symlink to another location you need to specify
386+
a string-based destination
387+
388+
.. code-block:: php
389+
390+
$object->createSymlinkTo('/container_2/new_object_name');
391+
392+
Where ``container_2`` is the name of the container, and ``new_object_name`` is
393+
the name of the object inside the container.
394+
395+
The object must be an empty file.
396+
397+
`Get the executable PHP script for this example <https://raw.githubusercontent.com/rackspace/php-opencloud/master/samples/ObjectStore/symlink-object.php>`_
398+
399+
329400
Get object metadata
330401
-------------------
331402

doc/using-php-5.3.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Using the SDK with PHP v5.3
2+
===========================
3+
4+
Since PHP 5.3 has entered EOL and no longer receives security updates, we have bumped the minimum requirement to 5.4. Using 5.3 is still possible, however, but you will need to use an older stable version of the SDK. There are two ways to do this.
5+
6+
The first way is by requiring it through the command line:
7+
8+
.. code-block:: bash
9+
10+
composer require rackspace/php-opencloud:1.12
11+
12+
The second way is by updating your composer.json file, and specifying the appropriate version of the SDK:
13+
14+
.. code-block:: json
15+
16+
"require": {
17+
"rackspace/php-opencloud": "~1.12"
18+
}
19+
20+
Note that **1.12** is the last minor release supporting PHP 5.3. Version 1.13 and above has shifted to PHP 5.4.

docs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Documentation
2+
3+
Our official docs are hosted on http://docs.php-opencloud.com.

lib/OpenCloud/Common/Constants/Header.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@ class Header
7070
const USER_AGENT = 'User-Agent';
7171
const VARY = 'Vary';
7272
const VIA = 'Via';
73+
const X_OBJECT_MANIFEST = 'X-Object-Manifest';
7374
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright 2012-2014 Rackspace US, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace OpenCloud\Common\Exceptions;
19+
20+
class DomainNotFoundException extends \Exception
21+
{
22+
}

lib/OpenCloud/Compute/Resource/Server.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ class Server extends NovaResource implements HasPtrRecordsInterface
172172
*/
173173
public $powerStatus;
174174

175+
/**
176+
* @link http://developer.openstack.org/api-ref-compute-v2-ext.html#ext-os-ext-az
177+
* @var string Availability zone of the VM
178+
*/
179+
public $availabilityZone;
180+
175181
protected static $json_name = 'server';
176182
protected static $url_resource = 'servers';
177183

@@ -206,6 +212,7 @@ class Server extends NovaResource implements HasPtrRecordsInterface
206212
'OS-EXT-STS:vm_state' => 'extendedStatus',
207213
'OS-EXT-STS:task_state' => 'taskStatus',
208214
'OS-EXT-STS:power_state' => 'powerStatus',
215+
'OS-EXT-AZ:availability_zone' => 'availabilityZone'
209216
);
210217

211218
/**
@@ -729,6 +736,12 @@ protected function createJson()
729736
$server->user_data = $this->user_data;
730737
}
731738

739+
// Availability zone
740+
if (!empty($this->availabilityZone)) {
741+
$this->checkExtension('OS-EXT-AZ');
742+
$server->availability_zone = $this->availabilityZone;
743+
}
744+
732745
return (object) array('server' => $server);
733746
}
734747

lib/OpenCloud/Compute/Service.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function __construct(Client $client, $type = null, $name = null, $region
8181
*
8282
* @api
8383
* @param string $id - if specified, the server with the ID is retrieved
84-
* @returns Resource\Server object
84+
* @return Resource\Server object
8585
*/
8686
public function server($id = null)
8787
{
@@ -102,7 +102,7 @@ public function server($id = null)
102102
* not having all the information you need.
103103
* @param array $filter - a set of key/value pairs that is passed to the
104104
* servers list for filtering
105-
* @returns \OpenCloud\Common\Collection
105+
* @return \OpenCloud\Common\Collection\PaginatedIterator
106106
*/
107107
public function serverList($details = true, array $filter = array())
108108
{
@@ -128,7 +128,7 @@ public function network($id = null)
128128
*
129129
* @api
130130
* @param array $filter array of filter key/value pairs
131-
* @return \OpenCloud\Common\Collection
131+
* @return \OpenCloud\Common\Collection\PaginatedIterator
132132
*/
133133
public function networkList($filter = array())
134134
{

lib/OpenCloud/DNS/Resource/Domain.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function record($info = null)
7676
* returns a Collection of Record objects
7777
*
7878
* @param array $filter query-string parameters
79-
* @return \OpenCloud\Collection
79+
* @return OpenCloud\DNS\Collection\DnsIterator
8080
*/
8181
public function recordList($filter = array())
8282
{
@@ -107,6 +107,7 @@ public function subdomain($info = array())
107107
*
108108
* @param array $filter key/value pairs for query string parameters
109109
* return \OpenCloud\Collection
110+
* @return OpenCloud\DNS\Collection\DnsIterator
110111
*/
111112
public function subdomainList($filter = array())
112113
{

lib/OpenCloud/DNS/Service.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
use OpenCloud\Common\Http\Message\Formatter;
2121
use OpenCloud\Common\Service\CatalogService;
22+
use OpenCloud\Common\Exceptions\DomainNotFoundException;
2223
use OpenCloud\DNS\Collection\DnsIterator;
2324
use OpenCloud\DNS\Resource\AsyncResponse;
2425
use OpenCloud\DNS\Resource\Domain;
@@ -55,11 +56,29 @@ public function domain($info = null)
5556
return $this->resource('Domain', $info);
5657
}
5758

59+
/**
60+
* Returns a domain, given a domain name
61+
*
62+
* @param string $domainName Domain name
63+
* @return Domain the domain object
64+
*/
65+
public function domainByName($domainName)
66+
{
67+
$domainList = $this->domainList(array("name" => $domainName));
68+
69+
if (count($domainList) != 1) {
70+
throw new DomainNotFoundException();
71+
}
72+
73+
return $this->resource('Domain', $domainList[0]);
74+
}
75+
76+
5877
/**
5978
* Returns a collection of domains
6079
*
6180
* @param array $filter key/value pairs to use as query strings
62-
* @return \OpenCloud\Common\Collection
81+
* @return OpenCloud\DNS\Collection\DnsIterator
6382
*/
6483
public function domainList($filter = array())
6584
{
@@ -85,7 +104,7 @@ public function ptrRecord($info = null)
85104
*
86105
* @param \OpenCloud\Compute\Resource\Server $server the server for which to
87106
* retrieve the PTR records
88-
* @return \OpenCloud\Common\Collection
107+
* @return OpenCloud\DNS\Collection\DnsIterator
89108
*/
90109
public function ptrRecordList(HasPtrRecordsInterface $parent)
91110
{
@@ -181,6 +200,13 @@ public function limitTypes()
181200
return $body->limitTypes;
182201
}
183202

203+
/**
204+
* List asynchronous responses' statuses.
205+
* @see http://docs.rackspace.com/cdns/api/v1.0/cdns-devguide/content/viewing_status_all_asynch_jobs.html
206+
*
207+
* @param array $query Any query parameters. Optional.
208+
* @return OpenCloud\DNS\Collection\DnsIterator
209+
*/
184210
public function listAsyncJobs(array $query = array())
185211
{
186212
$url = clone $this->getUrl();

0 commit comments

Comments
 (0)