Skip to content

Commit acb0a2f

Browse files
committed
Merge branch 'working'
2 parents 9c0ade2 + 8105fa1 commit acb0a2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+312
-8169
lines changed

doc/auth.rst

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Authentication
2+
==============
3+
4+
The client does not automatically authenticate against the API when it is
5+
instantiated - it waits for an API call. When this happens, it checks
6+
whether the current “token” has expired, and (re-)authenticates if
7+
necessary.
8+
9+
You can force authentication, by calling:
10+
11+
.. code-block:: php
12+
13+
$client->authenticate();
14+
15+
If the credentials are incorrect, a ``401`` error will be returned. If
16+
credentials are correct, a ``200`` status is returned with your Service
17+
Catalog.
18+
19+
20+
Service Catalog
21+
---------------
22+
23+
The Service Catalog is returned on successful authentication, and is
24+
composed of all the different API services available to the current
25+
tenant. All of this functionality is encapsulated in the ``Catalog``
26+
object, which allows you greater control and interactivity.
27+
28+
.. code-block:: php
29+
30+
/** @var OpenCloud\Common\Service\Catalog */
31+
$catalog = $client->getCatalog();
32+
33+
// Return a list of OpenCloud\Common\Service\CatalogItem objects
34+
foreach ($catalog->getItems() as $catalogItem) {
35+
36+
$name = $catalogItem->getName();
37+
$type = $catalogItem->getType();
38+
39+
if ($name == 'cloudServersOpenStack' && $type == 'compute') {
40+
break;
41+
}
42+
43+
// Array of OpenCloud\Common\Service\Endpoint objects
44+
$endpoints = $catalogItem->getEndpoints();
45+
foreach ($endpoints as $endpoint) {
46+
if ($endpoint->getRegion() == 'DFW') {
47+
echo $endpoint->getPublicUrl();
48+
}
49+
}
50+
}
51+
52+
As you can see, you have access to each Service’s name, type and list of
53+
endpoints. Each endpoint provides access to the specific region, along
54+
with its public and private endpoint URLs.

doc/http-clients.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
HTTP Clients
2+
============
3+
4+
Default HTTP headers
5+
--------------------
6+
7+
To set default HTTP headers:
8+
9+
.. code-block:: php
10+
11+
$client->setDefaultOption('headers/X-Custom-Header', 'FooBar');
12+
13+
14+
User agents
15+
-----------
16+
17+
php-opencloud will send a default ``User-Agent`` header for every HTTP
18+
request, unless a custom value is provided by the end-user. The default
19+
header will be in this format:
20+
21+
User-Agent: OpenCloud/xxx cURL/yyy PHP/zzz
22+
23+
where ``xxx`` is the current version of the SDK, ``yyy`` is the current
24+
version of cURL, and ``zzz`` is the current PHP version. To override
25+
this default, you must run:
26+
27+
.. code-block:: php
28+
29+
$client->setUserAgent('MyCustomUserAgent');
30+
31+
which will result in:
32+
33+
User-Agent: MyCustomUserAgent
34+
35+
If you want to set a *prefix* for the user agent, but retain the default
36+
``User-Agent`` as a suffix, you must run:
37+
38+
.. code-block:: php
39+
40+
$client->setUserAgent('MyPrefix', true);
41+
42+
which will result in:
43+
44+
User-Agent: MyPrefix OpenCloud/xxx cURL/yyy PHP/zzz
45+
46+
where ``$client`` is an instance of ``OpenCloud\OpenStack`` or
47+
``OpenCloud\Rackspace``.
48+
49+
50+
Other functionality
51+
-------------------
52+
53+
For a full list of functionality provided by Guzzle, please consult the
54+
`official documentation`_.
55+
56+
.. _official documentation: http://docs.guzzlephp.org/en/latest/http-client/client.html

doc/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ Usage tips
5050
iterators
5151
regions
5252
url-types
53+
logging
54+
http-clients
55+
auth
5356

5457
Help and support
5558
----------------

doc/logging.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Logging
2+
=======
3+
4+
Logger injection
5+
----------------
6+
7+
As the ``Rackspace`` client extends the ``OpenStack`` client, they both support
8+
passing ``$options`` as an array via the constructor's third parameter. The
9+
options are passed as a config to the `Guzzle` client, but also allow to inject
10+
your own logger.
11+
12+
Your logger should implement the ``Psr\Log\LoggerInterface`` `as defined in
13+
PSR-3 <https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md>`_.
14+
One example of a compatible logger is `Monolog <https://github.com/Seldaek/monolog>`_.
15+
When the client does create a service, it will inject the logger if one is
16+
available.
17+
18+
To inject a ``LoggerInterface`` compatible logger into a new client:
19+
20+
.. code-block:: php
21+
22+
use Monolog\Logger;
23+
use OpenCloud\OpenStack;
24+
25+
// create a log channel
26+
$logger = new Logger('name');
27+
28+
$client = new OpenStack('http://identity.my-openstack.com/v2.0', array(
29+
'username' => 'foo',
30+
'password' => 'bar'
31+
), array(
32+
'logger' => $logger,
33+
));

doc/services/compute/servers.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,42 @@ Updatable attributes
204204
| accessIPv6 | The IP version 6 address. |
205205
+--------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
206206

207+
208+
Updating the access IP address(es)
209+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
210+
211+
For example, you may have a private cloud with internal addresses in the
212+
10.1.x range. However, you can access a server via a firewall device at
213+
address 50.57.94.244. In this case, you can change the ``accessIPv4``
214+
attribute to point to the firewall:
215+
216+
.. code-block:: php
217+
218+
$server->update(array('accessIPv4' => '50.57.94.244'));
219+
220+
When a client application retrieves the server’s information, it will
221+
know that it needs to use the ``accessIPv4`` address to connect to the
222+
server, and *not* the IP address assigned to one of the network
223+
interfaces.
224+
225+
226+
Retrieving the server’s IP address
227+
----------------------------------
228+
229+
The ``Server::ip()`` method is used to retrieve the server’s IP address.
230+
It has one optional parameter: the format (either IPv4 or IPv6) of the
231+
address to return (by default, it returns the IPv4 address):
232+
233+
.. code-block:: php
234+
235+
// IPv4
236+
echo $server->ip();
237+
echo $server->ip(4);
238+
239+
// IPv6
240+
echo $server->ip(6);
241+
242+
207243
Delete server
208244
-------------
209245

0 commit comments

Comments
 (0)