Documentation

OpenStack extends Client
in package

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.

Table of Contents

CURL_OPTIONS  = 'curl.options'
DEFAULT_SELECT_TIMEOUT  = 1.0
DISABLE_REDIRECTS  = GuzzleHttpRedirectPlugin::DISABLE
MAX_HANDLES  = 3
REQUEST_OPTIONS  = 'request.options'
REQUEST_PARAMS  = 'request.params'
SSL_CERT_AUTHORITY  = 'ssl.certificate_authority'
$defaultHeaders  : Collection
$eventDispatcher  : EventDispatcherInterface
$requestFactory  : RequestFactoryInterface
$userAgent  : string
$authUrl  : string
$baseUrl  : Url
$catalog  : Catalog
$config  : Collection
$curlMulti  : CurlMultiInterface
$logger  : LoggerInterface
$secret  : array<string|int, mixed>
$tenant  : string
$token  : string
$uriTemplate  : UriTemplateInterface
$user  : User
__construct()  : mixed
addSubscriber()  : self
Add an event subscriber to the dispatcher
authenticate()  : void
Authenticate the tenant using the supplied credentials
cdnService()  : Service
Creates a new CDN (Poppy) service object
computeService()  : Service
Creates a new Compute object (Nova/Cloud Servers)
createRequest()  : RequestInterface
Create and return a new {@see RequestInterface} configured for the client.
delete()  : EntityEnclosingRequestInterface
Create a DELETE request for the client
dispatch()  : Event
Helper to dispatch Guzzle events and set the event name on the event
exportCredentials()  : array<string|int, mixed>
Convenience method for exporting current credentials. Useful for local caching.
extractPharCacert()  : string
Copies the phar cacert from a phar into the temp directory.
get()  : RequestInterface
Create a GET request for the client
getAllEvents()  : array<string|int, mixed>
Get a list of all of the events emitted from the class
getAuthUrl()  : Url
getBaseUrl()  : string|null
Get the client's base URL as either an expanded or raw URI template
getCatalog()  : array<string|int, mixed>
Get the service catalog.
getConfig()  : mixed|Collection
Get a configuration setting or all of the configuration settings. The Collection result of this method can be modified to change the configuration settings of a client.
getCredentials()  : string
Formats the credentials array (as a string) for authentication
getCurlMulti()  : CurlMultiInterface|CurlMultiProxy
getDefaultHeaders()  : mixed
getDefaultOption()  : mixed|null
Retrieve a default request option from the client
getDefaultUserAgent()  : string
Get the default User-Agent string to use with Guzzle
getEventDispatcher()  : EventDispatcherInterface
Get the EventDispatcher of the request
getExpiration()  : mixed
getLogger()  : LoggerInterface
getSecret()  : array<string|int, mixed>
Get the secret.
getTenant()  : string
Returns the tenant ID only (backwards compatibility).
getTenantObject()  : Tenant
Get the full Tenant object for this client.
getToken()  : string
Get the token ID for this client.
getTokenObject()  : mixed
Get the full token object.
getUrl()  : mixed
getUser()  : User
getUserAgent()  : mixed
hasExpired()  : mixed
hasLogger()  : bool
head()  : RequestInterface
Create a HEAD request for the client
identityService()  : Service
Creates a new Rackspace "Cloud Identity" service.
imageService()  : ServiceInterface
Creates a new Glance service
importCredentials()  : mixed
Convenience method for importing credentials. Useful for local caching because it reduces HTTP traffic.
networkingService()  : Service
Creates a new Networking (Neutron) service object
objectStoreService()  : Service
Creates a new ObjectStore object (Swift/Cloud Files)
options()  : RequestInterface
Create an OPTIONS request for the client
orchestrationService()  : Service
Creates a new Orchestration (Heat) service object
patch()  : EntityEnclosingRequestInterface
Create a PATCH request for the client
post()  : EntityEnclosingRequestInterface
Create a POST request for the client
preparePharCacert()  : mixed
put()  : EntityEnclosingRequestInterface
Create a PUT request for the client
send()  : Response|array<string|int, mixed>
Sends a single request or an array of requests in parallel
setAuthUrl()  : $this
setBaseUrl()  : self
Set the base URL of the client
setCatalog()  : $this
Set the service catalog.
setConfig()  : self
Set the configuration object to use with the client
setCurlMulti()  : self
Set a curl multi object to be used internally by the client for transferring requests.
setDefaultHeaders()  : mixed
setDefaultOption()  : $this
Set a default request option on the client that will be used as a default for each request
setEventDispatcher()  : self
Set the EventDispatcher of the request
setExpiration()  : mixed
setLogger()  : $this
setRequestFactory()  : mixed
setSecret()  : $this
Set the credentials for the client
setSslVerification()  : self
Set SSL verification options.
setTenant()  : $this
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.
setTenantObject()  : mixed
Set the full Tenant object for this client.
setToken()  : $this
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.
setTokenObject()  : mixed
Set the full token object
setUriTemplate()  : self
Set the URI template expander to use with the client
setUser()  : mixed
Sets the current user based on the generated token.
setUserAgent()  : self
Set the User-Agent header to be used on all requests from the client
volumeService()  : Service
Creates a new Volume (Cinder) service object
expandTemplate()  : string
Expand a URI template while merging client config settings into the template variables
getUriTemplate()  : UriTemplateInterface
Get the URI template expander used by the client
initSsl()  : mixed
Initializes SSL settings
prepareRequest()  : RequestInterface
Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.
sendMultiple()  : array<string|int, mixed>
Send multiple requests in parallel
updateTokenHeader()  : void
Sets the X-Auth-Token header. If no value is explicitly passed in, the current token is used.

Constants

CURL_OPTIONS

public mixed CURL_OPTIONS = 'curl.options'

DEFAULT_SELECT_TIMEOUT

public mixed DEFAULT_SELECT_TIMEOUT = 1.0

DISABLE_REDIRECTS

public mixed DISABLE_REDIRECTS = GuzzleHttpRedirectPlugin::DISABLE

MAX_HANDLES

public mixed MAX_HANDLES = 3

REQUEST_OPTIONS

public mixed REQUEST_OPTIONS = 'request.options'

REQUEST_PARAMS

public mixed REQUEST_PARAMS = 'request.params'
Tags
deprecated

Use [request.options][params]

SSL_CERT_AUTHORITY

public mixed SSL_CERT_AUTHORITY = 'ssl.certificate_authority'

Properties

$defaultHeaders

protected Collection $defaultHeaders

Default HTTP headers to set on each request

$userAgent

protected string $userAgent

The user agent string to set on each request

$authUrl

private string $authUrl

The endpoint URL used for authentication

$baseUrl

private Url $baseUrl

Base URL of the client

$catalog

private Catalog $catalog

The catalog of services which are provided by the API

$secret

private array<string|int, mixed> $secret = array()

Credentials passed in by the user

$tenant

private string $tenant

The unique identifier for who's accessing the API

$token

private string $token

The token produced by the API

Methods

__construct()

public __construct(mixed $url, array<string|int, mixed> $secret[, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$url : mixed
$secret : array<string|int, mixed>
$options : array<string|int, mixed> = array()
Return values
mixed

authenticate()

Authenticate the tenant using the supplied credentials

public authenticate() : void
Tags
throws
AuthenticationError
Return values
void

cdnService()

Creates a new CDN (Poppy) service object

public cdnService([string $name = null ][, string $region = null ][, string $urltype = null ]) : Service
Parameters
$name : string = null

The name of the service as it appears in the Catalog

$region : string = null

The region (DFW, IAD, ORD, LON, SYD)

$urltype : string = null

The URL type ("publicURL" or "internalURL")

Tags
codeCoverageIgnore
Return values
Service

computeService()

Creates a new Compute object (Nova/Cloud Servers)

public computeService([string $name = null ][, string $region = null ][, string $urltype = null ]) : Service
Parameters
$name : string = null

The name of the service as it appears in the Catalog

$region : string = null

The region (DFW, IAD, ORD, LON, SYD)

$urltype : string = null

The URL type ("publicURL" or "internalURL")

Return values
Service

createRequest()

Create and return a new {@see RequestInterface} configured for the client.

public createRequest([mixed $method = 'GET' ][, mixed $uri = null ][, mixed $headers = null ][, mixed $body = null ][, array<string|int, mixed> $options = array() ]) : RequestInterface

Use an absolute path to override the base path of the client, or a relative path to append to the base path of the client. The URI can contain the query string as well. Use an array to provide a URI template and additional variables to use in the URI template expansion.

Parameters
$method : mixed = 'GET'

HTTP method. Defaults to GET

$uri : mixed = null

Resource URI.

$headers : mixed = null

HTTP headers

$body : mixed = null

Entity body of request (POST/PUT) or response (GET)

$options : array<string|int, mixed> = array()

Array of options to apply to the request

Return values
RequestInterface

delete()

Create a DELETE request for the client

public delete([mixed $uri = null ][, mixed $headers = null ][, mixed $body = null ][, array<string|int, mixed> $options = array() ]) : EntityEnclosingRequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$body : mixed = null

Body to send in the request

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
EntityEnclosingRequestInterface

dispatch()

Helper to dispatch Guzzle events and set the event name on the event

public dispatch(mixed $eventName[, array<string|int, mixed> $context = array() ]) : Event
Parameters
$eventName : mixed

Name of the event to dispatch

$context : array<string|int, mixed> = array()

Context of the event

Return values
Event

Returns the created event object

exportCredentials()

Convenience method for exporting current credentials. Useful for local caching.

public exportCredentials() : array<string|int, mixed>
Return values
array<string|int, mixed>

extractPharCacert()

Copies the phar cacert from a phar into the temp directory.

public static extractPharCacert(string $pharCacertPath) : string
Parameters
$pharCacertPath : string

Path to the phar cacert. For example: 'phar://aws.phar/Guzzle/Http/Resources/cacert.pem'

Tags
throws
RuntimeException

Throws if the phar cacert cannot be found or the file cannot be copied to the temp dir.

Return values
string

Returns the path to the extracted cacert file.

get()

Create a GET request for the client

public get([mixed $uri = null ][, mixed $headers = null ][, mixed $options = array() ]) : RequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$options : mixed = array()

Options to apply to the request. For BC compatibility, you can also pass a string to tell Guzzle to download the body of the response to a particular location. Use the 'body' option instead for forward compatibility.

Return values
RequestInterface

getAllEvents()

Get a list of all of the events emitted from the class

public static getAllEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

getBaseUrl()

Get the client's base URL as either an expanded or raw URI template

public getBaseUrl([mixed $expand = true ]) : string|null
Parameters
$expand : mixed = true

Set to FALSE to get the raw base URL without URI template expansion

Return values
string|null

getCatalog()

Get the service catalog.

public getCatalog() : array<string|int, mixed>
Return values
array<string|int, mixed>

getConfig()

Get a configuration setting or all of the configuration settings. The Collection result of this method can be modified to change the configuration settings of a client.

public final getConfig([mixed $key = false ]) : mixed|Collection

A client should honor the following special values:

  • request.options: Associative array of default RequestFactory options to apply to each request
  • request.params: Associative array of request parameters (data values) to apply to each request
  • curl.options: Associative array of cURL configuration settings to apply to each request
  • ssl.certificate_authority: Path a CAINFO, CAPATH, true to use strict defaults, or false to disable verification
  • redirect.disable: Set to true to disable redirects
Parameters
$key : mixed = false

Configuration value to retrieve. Set to FALSE to retrieve all values of the client. The object return can be modified, and modifications will affect the client's config.

Return values
mixed|Collection

getCredentials()

Formats the credentials array (as a string) for authentication

public getCredentials() : string
Tags
throws
CredentialError
Return values
string

getDefaultHeaders()

public getDefaultHeaders() : mixed
Tags
deprecated
Return values
mixed

getDefaultOption()

Retrieve a default request option from the client

public getDefaultOption(string $keyOrPath) : mixed|null
Parameters
$keyOrPath : string

request.options key (e.g. allow_redirects) or path to a nested key (e.g. headers/foo)

Return values
mixed|null

getDefaultUserAgent()

Get the default User-Agent string to use with Guzzle

public getDefaultUserAgent() : string
Return values
string

getExpiration()

public getExpiration() : mixed
Tags
deprecated
Return values
mixed

getSecret()

Get the secret.

public getSecret() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTenant()

Returns the tenant ID only (backwards compatibility).

public getTenant() : string
Return values
string

getTenantObject()

Get the full Tenant object for this client.

public getTenantObject() : Tenant
Return values
Tenant

getToken()

Get the token ID for this client.

public getToken() : string
Return values
string

getTokenObject()

Get the full token object.

public getTokenObject() : mixed
Return values
mixed

getUrl()

public getUrl() : mixed
Tags
deprecated
Return values
mixed

getUserAgent()

public getUserAgent() : mixed
Return values
mixed

hasExpired()

public hasExpired() : mixed
Tags
deprecated
Return values
mixed

hasLogger()

public hasLogger() : bool
Return values
bool

head()

Create a HEAD request for the client

public head([mixed $uri = null ][, mixed $headers = null ][, array<string|int, mixed> $options = array() ]) : RequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
RequestInterface

identityService()

Creates a new Rackspace "Cloud Identity" service.

public identityService() : Service
Return values
Service

imageService()

Creates a new Glance service

public imageService([string $name = null ][, string $region = null ][, string $urltype = null ]) : ServiceInterface
Parameters
$name : string = null

The name of the service as it appears in the Catalog

$region : string = null

The region (DFW, IAD, ORD, LON, SYD)

$urltype : string = null

The URL type ("publicURL" or "internalURL")

Return values
ServiceInterface

importCredentials()

Convenience method for importing credentials. Useful for local caching because it reduces HTTP traffic.

public importCredentials(array<string|int, mixed> $values) : mixed
Parameters
$values : array<string|int, mixed>
Return values
mixed

networkingService()

Creates a new Networking (Neutron) service object

public networkingService([string $name = null ][, string $region = null ][, string $urltype = null ]) : Service
Parameters
$name : string = null

The name of the service as it appears in the Catalog

$region : string = null

The region (DFW, IAD, ORD, LON, SYD)

$urltype : string = null

The URL type ("publicURL" or "internalURL")

Tags
codeCoverageIgnore
Return values
Service

objectStoreService()

Creates a new ObjectStore object (Swift/Cloud Files)

public objectStoreService([string $name = null ][, string $region = null ][, string $urltype = null ]) : Service
Parameters
$name : string = null

The name of the service as it appears in the Catalog

$region : string = null

The region (DFW, IAD, ORD, LON, SYD)

$urltype : string = null

The URL type ("publicURL" or "internalURL")

Return values
Service

options()

Create an OPTIONS request for the client

public options([mixed $uri = null ][, array<string|int, mixed> $options = array() ]) : RequestInterface
Parameters
$uri : mixed = null

Resource URI

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
RequestInterface

orchestrationService()

Creates a new Orchestration (Heat) service object

public orchestrationService([string $name = null ][, string $region = null ][, string $urltype = null ]) : Service
Parameters
$name : string = null

The name of the service as it appears in the Catalog

$region : string = null

The region (DFW, IAD, ORD, LON, SYD)

$urltype : string = null

The URL type ("publicURL" or "internalURL")

Tags
codeCoverageIgnore
Return values
Service

patch()

Create a PATCH request for the client

public patch([mixed $uri = null ][, mixed $headers = null ][, mixed $body = null ][, array<string|int, mixed> $options = array() ]) : EntityEnclosingRequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$body : mixed = null

Body to send in the request

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
EntityEnclosingRequestInterface

post()

Create a POST request for the client

public post([mixed $uri = null ][, mixed $headers = null ][, mixed $postBody = null ][, array<string|int, mixed> $options = array() ]) : EntityEnclosingRequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$postBody : mixed = null

POST body. Can be a string, EntityBody, or associative array of POST fields to send in the body of the request. Prefix a value in the array with the @ symbol to reference a file.

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
EntityEnclosingRequestInterface

preparePharCacert()

public preparePharCacert([mixed $md5Check = true ]) : mixed
Parameters
$md5Check : mixed = true
Tags
deprecated
Return values
mixed

put()

Create a PUT request for the client

public put([mixed $uri = null ][, mixed $headers = null ][, mixed $body = null ][, array<string|int, mixed> $options = array() ]) : EntityEnclosingRequestInterface
Parameters
$uri : mixed = null

Resource URI

$headers : mixed = null

HTTP headers

$body : mixed = null

Body to send in the request

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
EntityEnclosingRequestInterface

send()

Sends a single request or an array of requests in parallel

public send(mixed $requests) : Response|array<string|int, mixed>
Parameters
$requests : mixed

One or more RequestInterface objects to send

Return values
Response|array<string|int, mixed>

Returns a single Response or an array of Response objects

setAuthUrl()

public setAuthUrl( $url) : $this
Parameters
$url :
Return values
$this

setBaseUrl()

Set the base URL of the client

public setBaseUrl(mixed $url) : self
Parameters
$url : mixed

The base service endpoint URL of the webservice

Return values
self

setCatalog()

Set the service catalog.

public setCatalog(mixed $catalog) : $this
Parameters
$catalog : mixed
Return values
$this

setConfig()

Set the configuration object to use with the client

public final setConfig(mixed $config) : self
Parameters
$config : mixed

Parameters that define how the client behaves

Return values
self

setCurlMulti()

Set a curl multi object to be used internally by the client for transferring requests.

public setCurlMulti(CurlMultiInterface $curlMulti) : self
Parameters
$curlMulti : CurlMultiInterface

Multi object

Return values
self

setDefaultHeaders()

public setDefaultHeaders(mixed $headers) : mixed
Parameters
$headers : mixed
Tags
deprecated
Return values
mixed

setDefaultOption()

Set a default request option on the client that will be used as a default for each request

public setDefaultOption(string $keyOrPath, mixed $value) : $this
Parameters
$keyOrPath : string

request.options key (e.g. allow_redirects) or path to a nested key (e.g. headers/foo)

$value : mixed

Value to set

Return values
$this

setExpiration()

public setExpiration(mixed $expiration) : mixed
Parameters
$expiration : mixed
Tags
deprecated
Return values
mixed

setSecret()

Set the credentials for the client

public setSecret([array<string|int, mixed> $secret = array() ]) : $this
Parameters
$secret : array<string|int, mixed> = array()
Return values
$this

setSslVerification()

Set SSL verification options.

public final setSslVerification([mixed $certificateAuthority = true ][, mixed $verifyPeer = true ][, mixed $verifyHost = 2 ]) : self

Setting $certificateAuthority to TRUE will result in the bundled cacert.pem being used to verify against the remote host.

Alternate certificates to verify against can be specified with the $certificateAuthority option set to the full path to a certificate file, or the path to a directory containing certificates.

Setting $certificateAuthority to FALSE will turn off peer verification, unset the bundled cacert.pem, and disable host verification. Please don't do this unless you really know what you're doing, and why you're doing it.

Parameters
$certificateAuthority : mixed = true

bool, file path, or directory path

$verifyPeer : mixed = true

FALSE to stop from verifying the peer's certificate.

$verifyHost : mixed = 2

Set to 1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that it matches the hostname provided.

Return values
self

setTenant()

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.

public setTenant(mixed $tenant) : $this
Parameters
$tenant : mixed
Return values
$this

setTenantObject()

Set the full Tenant object for this client.

public setTenantObject(Tenant $tenant) : mixed
Parameters
$tenant : Tenant
Return values
mixed

setToken()

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.

public setToken(string $token) : $this

This ambiguity arises due to backwards compatibility.

Parameters
$token : string
Return values
$this

setTokenObject()

Set the full token object

public setTokenObject(Token $token) : mixed
Parameters
$token : Token
Return values
mixed

setUser()

Sets the current user based on the generated token.

public setUser(User $user) : mixed
Parameters
$user : User
Return values
mixed

setUserAgent()

Set the User-Agent header to be used on all requests from the client

public setUserAgent(mixed $userAgent[, mixed $includeDefault = false ]) : self
Parameters
$userAgent : mixed

User agent string

$includeDefault : mixed = false

Set to true to prepend the value to Guzzle's default user agent string

Return values
self

volumeService()

Creates a new Volume (Cinder) service object

public volumeService([string $name = null ][, string $region = null ][, string $urltype = null ]) : Service
Parameters
$name : string = null

The name of the service as it appears in the Catalog

$region : string = null

The region (DFW, IAD, ORD, LON, SYD)

$urltype : string = null

The URL type ("publicURL" or "internalURL")

Return values
Service

expandTemplate()

Expand a URI template while merging client config settings into the template variables

protected expandTemplate(string $template[, array<string|int, mixed> $variables = null ]) : string
Parameters
$template : string

Template to expand

$variables : array<string|int, mixed> = null

Variables to inject

Return values
string

initSsl()

Initializes SSL settings

protected initSsl() : mixed
Return values
mixed

prepareRequest()

Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.

protected prepareRequest(RequestInterface $request[, array<string|int, mixed> $options = array() ]) : RequestInterface
Parameters
$request : RequestInterface

Request to prepare for the client

$options : array<string|int, mixed> = array()

Options to apply to the request

Return values
RequestInterface

sendMultiple()

Send multiple requests in parallel

protected sendMultiple(array<string|int, mixed> $requests) : array<string|int, mixed>
Parameters
$requests : array<string|int, mixed>

Array of RequestInterface objects

Return values
array<string|int, mixed>

Returns an array of Response objects

updateTokenHeader()

Sets the X-Auth-Token header. If no value is explicitly passed in, the current token is used.

private updateTokenHeader(string $token) : void
Parameters
$token : string

Value of header.

Return values
void

Search results