\Qcloud\CosClient

Client object for executing commands on a web service.

Summary

Methods
Properties
Constants
factory()
getAllEvents()
__call()
getCommand()
setCommandFactory()
setResourceIteratorFactory()
getIterator()
execute()
setDescription()
getDescription()
setInflector()
getInflector()
enableMagicMethods()
__construct()
setConfig()
getConfig()
setDefaultOption()
getDefaultOption()
setSslVerification()
createRequest()
getBaseUrl()
setBaseUrl()
setUserAgent()
getDefaultUserAgent()
get()
head()
delete()
put()
patch()
post()
options()
send()
setCurlMulti()
getCurlMulti()
setRequestFactory()
setUriTemplate()
getDefaultHeaders()
setDefaultHeaders()
preparePharCacert()
extractPharCacert()
setEventDispatcher()
getEventDispatcher()
dispatch()
addSubscriber()
set_config()
__destruct()
createAuthorization()
createPresignedUrl()
getObjectUrl()
Upload()
resumeUpload()
Copy()
doesBucketExist()
doesObjectExist()
encodeKey()
explodeKey()
No public properties found
COMMAND_PARAMS
REQUEST_PARAMS
REQUEST_OPTIONS
CURL_OPTIONS
SSL_CERT_AUTHORITY
DISABLE_REDIRECTS
DEFAULT_SELECT_TIMEOUT
MAX_HANDLES
VERSION
prepareCommand()
executeMultiple()
getResourceIteratorFactory()
getCommandFactory()
expandTemplate()
getUriTemplate()
sendMultiple()
prepareRequest()
initSsl()
$serviceDescription
$commandFactory
$resourceIteratorFactory
$inflector
$defaultHeaders
$userAgent
$requestFactory
$eventDispatcher
N/A
No private methods found
$config
$baseUrl
$curlMulti
$uriTemplate
$region
$credentials
$appId
$secretId
$secretKey
$timeout
$connect_timeout
$signature
N/A

Constants

COMMAND_PARAMS

COMMAND_PARAMS = 'command.params'

REQUEST_PARAMS

REQUEST_PARAMS = 'request.params'

REQUEST_OPTIONS

REQUEST_OPTIONS = 'request.options'

CURL_OPTIONS

CURL_OPTIONS = 'curl.options'

SSL_CERT_AUTHORITY

SSL_CERT_AUTHORITY = 'ssl.certificate_authority'

DISABLE_REDIRECTS

DISABLE_REDIRECTS = \Guzzle\Http\RedirectPlugin::DISABLE

DEFAULT_SELECT_TIMEOUT

DEFAULT_SELECT_TIMEOUT = 1.0

MAX_HANDLES

MAX_HANDLES = 3

VERSION

VERSION = '1.3.0'

Properties

$defaultHeaders

$defaultHeaders : \Guzzle\Common\Collection

Type

\Guzzle\Common\Collection — Default HTTP headers to set on each request

$userAgent

$userAgent : string

Type

string — The user agent string to set on each request

$baseUrl

$baseUrl : \Guzzle\Http\Url

Type

\Guzzle\Http\Url — Base URL of the client

$region

$region : 

Type

$credentials

$credentials : 

Type

$appId

$appId : 

Type

$secretId

$secretId : 

Type

$secretKey

$secretKey : 

Type

$timeout

$timeout : 

Type

$connect_timeout

$connect_timeout : 

Type

$signature

$signature : 

Type

Methods

factory()

factory(array|\Guzzle\Common\Collection  $config = array()) : \Guzzle\Service\Client

Basic factory method to create a new client. Extend this method in subclasses to build more complex clients.

Parameters

array|\Guzzle\Common\Collection $config

Configuration data

Returns

\Guzzle\Service\Client

getAllEvents()

getAllEvents() : array

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

Returns

array

__call()

__call(string  $method, array  $args) : mixed

Magic method used to retrieve a command

Parameters

string $method

Name of the command object to instantiate

array $args

Arguments to pass to the command

Returns

mixed —

Returns the result of the command

getCommand()

getCommand(string  $name, array  $args = array()) : \Guzzle\Service\Command\CommandInterface

Get a command by name. First, the client will see if it has a service description and if the service description defines a command by the supplied name. If no dynamic command is found, the client will look for a concrete command class exists matching the name supplied. If neither are found, an InvalidArgumentException is thrown.

Parameters

string $name

Name of the command to retrieve

array $args

Arguments to pass to the command

Returns

\Guzzle\Service\Command\CommandInterface

setCommandFactory()

setCommandFactory(\Guzzle\Service\Command\Factory\FactoryInterface  $factory) : self

Set the command factory used to create commands by name

Parameters

\Guzzle\Service\Command\Factory\FactoryInterface $factory

Command factory

Returns

self

setResourceIteratorFactory()

setResourceIteratorFactory(\Guzzle\Service\Resource\ResourceIteratorFactoryInterface  $factory) : self

Set the resource iterator factory associated with the client

Parameters

\Guzzle\Service\Resource\ResourceIteratorFactoryInterface $factory

Resource iterator factory

Returns

self

getIterator()

getIterator(string|\Guzzle\Service\Command\CommandInterface  $command, array  $commandOptions = null, array  $iteratorOptions = array()) : \Guzzle\Service\Resource\ResourceIteratorInterface

Get a resource iterator from the client.

Parameters

string|\Guzzle\Service\Command\CommandInterface $command

Command class or command name.

array $commandOptions

Command options used when creating commands.

array $iteratorOptions

Iterator options passed to the iterator when it is instantiated.

Returns

\Guzzle\Service\Resource\ResourceIteratorInterface

execute()

execute(\Guzzle\Service\Command\CommandInterface|array|\Guzzle\Service\Traversable  $command) : mixed

Execute one or more commands

Parameters

\Guzzle\Service\Command\CommandInterface|array|\Guzzle\Service\Traversable $command

Command, array of commands or Traversable object containing commands to execute

Returns

mixed —

Returns the result of the executed command or an array of commands if executing multiple commands

setInflector()

setInflector(\Guzzle\Inflection\InflectorInterface  $inflector) : self

Set the inflector used with the client

Parameters

\Guzzle\Inflection\InflectorInterface $inflector

Inflection object

Returns

self

getInflector()

getInflector() : self

Get the inflector used with the client

Returns

self

enableMagicMethods()

enableMagicMethods(  $isEnabled) 

Parameters

$isEnabled

__construct()

__construct(  $config) 

Parameters

$config

setConfig()

setConfig(array|\Guzzle\Common\Collection  $config) : self

Set the configuration object to use with the client

Parameters

array|\Guzzle\Common\Collection $config

Parameters that define how the client behaves

Returns

self

getConfig()

getConfig(boolean|string  $key = false) : mixed|\Guzzle\Common\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.

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

boolean|string $key

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.

Returns

mixed|\Guzzle\Common\Collection

setDefaultOption()

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

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

Parameters

string $keyOrPath

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

mixed $value

Value to set

Returns

$this

getDefaultOption()

getDefaultOption(string  $keyOrPath) : mixed|null

Retrieve a default request option from the client

Parameters

string $keyOrPath

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

Returns

mixed|null

setSslVerification()

setSslVerification(string|boolean  $certificateAuthority = true, boolean  $verifyPeer = true, integer  $verifyHost = 2) : self

Set SSL verification options.

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

string|boolean $certificateAuthority

bool, file path, or directory path

boolean $verifyPeer

FALSE to stop from verifying the peer's certificate.

integer $verifyHost

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.

Returns

self

createRequest()

createRequest(string  $method = 'GET', string|array  $uri = null, array|\Guzzle\Common\Collection  $headers = null, string|resource|array|\Guzzle\Http\EntityBodyInterface  $body = null, array  $options = array()) : \Guzzle\Http\Message\RequestInterface

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

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

string $method

HTTP method. Defaults to GET

string|array $uri

Resource URI.

array|\Guzzle\Common\Collection $headers

HTTP headers

string|resource|array|\Guzzle\Http\EntityBodyInterface $body

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

array $options

Array of options to apply to the request

Returns

\Guzzle\Http\Message\RequestInterface

getBaseUrl()

getBaseUrl(boolean  $expand = true) : string|null

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

Parameters

boolean $expand

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

Returns

string|null

setBaseUrl()

setBaseUrl(string  $url) : self

Set the base URL of the client

Parameters

string $url

The base service endpoint URL of the webservice

Returns

self

setUserAgent()

setUserAgent(string  $userAgent, boolean  $includeDefault = false) : self

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

Parameters

string $userAgent

User agent string

boolean $includeDefault

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

Returns

self

getDefaultUserAgent()

getDefaultUserAgent() : string

Get the default User-Agent string to use with Guzzle

Returns

string

get()

get(string|array  $uri = null, array|\Guzzle\Common\Collection  $headers = null, array  $options = array()) : \Guzzle\Http\Message\RequestInterface

Create a GET request for the client

Parameters

string|array $uri

Resource URI

array|\Guzzle\Common\Collection $headers

HTTP headers

array $options

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.

Returns

\Guzzle\Http\Message\RequestInterface

head()

head(string|array  $uri = null, array|\Guzzle\Common\Collection  $headers = null, array  $options = array()) : \Guzzle\Http\Message\RequestInterface

Create a HEAD request for the client

Parameters

string|array $uri

Resource URI

array|\Guzzle\Common\Collection $headers

HTTP headers

array $options

Options to apply to the request

Returns

\Guzzle\Http\Message\RequestInterface

delete()

delete(string|array  $uri = null, array|\Guzzle\Common\Collection  $headers = null, string|resource|\Guzzle\Http\EntityBodyInterface  $body = null, array  $options = array()) : \Guzzle\Http\Message\EntityEnclosingRequestInterface

Create a DELETE request for the client

Parameters

string|array $uri

Resource URI

array|\Guzzle\Common\Collection $headers

HTTP headers

string|resource|\Guzzle\Http\EntityBodyInterface $body

Body to send in the request

array $options

Options to apply to the request

Returns

\Guzzle\Http\Message\EntityEnclosingRequestInterface

put()

put(string|array  $uri = null, array|\Guzzle\Common\Collection  $headers = null, string|resource|\Guzzle\Http\EntityBodyInterface  $body = null, array  $options = array()) : \Guzzle\Http\Message\EntityEnclosingRequestInterface

Create a PUT request for the client

Parameters

string|array $uri

Resource URI

array|\Guzzle\Common\Collection $headers

HTTP headers

string|resource|\Guzzle\Http\EntityBodyInterface $body

Body to send in the request

array $options

Options to apply to the request

Returns

\Guzzle\Http\Message\EntityEnclosingRequestInterface

patch()

patch(string|array  $uri = null, array|\Guzzle\Common\Collection  $headers = null, string|resource|\Guzzle\Http\EntityBodyInterface  $body = null, array  $options = array()) : \Guzzle\Http\Message\EntityEnclosingRequestInterface

Create a PATCH request for the client

Parameters

string|array $uri

Resource URI

array|\Guzzle\Common\Collection $headers

HTTP headers

string|resource|\Guzzle\Http\EntityBodyInterface $body

Body to send in the request

array $options

Options to apply to the request

Returns

\Guzzle\Http\Message\EntityEnclosingRequestInterface

post()

post(string|array  $uri = null, array|\Guzzle\Common\Collection  $headers = null, array|\Guzzle\Common\Collection|string|\Guzzle\Http\EntityBodyInterface  $postBody = null, array  $options = array()) : \Guzzle\Http\Message\EntityEnclosingRequestInterface

Create a POST request for the client

Parameters

string|array $uri

Resource URI

array|\Guzzle\Common\Collection $headers

HTTP headers

array|\Guzzle\Common\Collection|string|\Guzzle\Http\EntityBodyInterface $postBody

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.

array $options

Options to apply to the request

Returns

\Guzzle\Http\Message\EntityEnclosingRequestInterface

options()

options(string|array  $uri = null, array  $options = array()) : \Guzzle\Http\Message\RequestInterface

Create an OPTIONS request for the client

Parameters

string|array $uri

Resource URI

array $options

Options to apply to the request

Returns

\Guzzle\Http\Message\RequestInterface

send()

send(array|\Guzzle\Http\Message\RequestInterface  $requests) : \Guzzle\Http\Message\Response|array

Sends a single request or an array of requests in parallel

Parameters

array|\Guzzle\Http\Message\RequestInterface $requests

One or more RequestInterface objects to send

Returns

\Guzzle\Http\Message\Response|array —

Returns a single Response or an array of Response objects

setCurlMulti()

setCurlMulti(\Guzzle\Http\Curl\CurlMultiInterface  $curlMulti) : self

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

Parameters

\Guzzle\Http\Curl\CurlMultiInterface $curlMulti

Multi object

Returns

self

setUriTemplate()

setUriTemplate(\Guzzle\Parser\UriTemplate\UriTemplateInterface  $uriTemplate) : self

Set the URI template expander to use with the client

Parameters

\Guzzle\Parser\UriTemplate\UriTemplateInterface $uriTemplate

URI template expander

Returns

self

getDefaultHeaders()

getDefaultHeaders() 

setDefaultHeaders()

setDefaultHeaders(  $headers) 

Parameters

$headers

preparePharCacert()

preparePharCacert(  $md5Check = true) 

Parameters

$md5Check

extractPharCacert()

extractPharCacert(string  $pharCacertPath) : string

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

Parameters

string $pharCacertPath

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

Throws

\RuntimeException

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

Returns

string —

Returns the path to the extracted cacert file.

dispatch()

dispatch(string  $eventName, array  $context = array()) : \Guzzle\Common\Event

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

Parameters

string $eventName

Name of the event to dispatch

array $context

Context of the event

Returns

\Guzzle\Common\Event

Returns the created event object

set_config()

set_config(  $config) 

Parameters

$config

__destruct()

__destruct() 

getObjectUrl()

getObjectUrl(  $bucket,   $key,   $expires = null, array  $args = array()) 

Parameters

$bucket
$key
$expires
array $args

Upload()

Upload(  $bucket,   $key,   $body,   $options = array()) 

Parameters

$bucket
$key
$body
$options

resumeUpload()

resumeUpload(  $bucket,   $key,   $body,   $uploadId,   $options = array()) 

Parameters

$bucket
$key
$body
$uploadId
$options

Copy()

Copy(  $bucket,   $key,   $copysource,   $options = array()) 

Parameters

$bucket
$key
$copysource
$options

doesBucketExist()

doesBucketExist(string  $bucket, boolean  $accept403 = true, array  $options = array()) : boolean

Determines whether or not a bucket exists by name

Parameters

string $bucket

The name of the bucket

boolean $accept403

Set to true if 403s are acceptable

array $options

Additional options to add to the executed command

Returns

boolean

doesObjectExist()

doesObjectExist(string  $bucket, string  $key, array  $options = array()) : boolean

Determines whether or not an object exists by name

Parameters

string $bucket

The name of the bucket

string $key

The key of the object

array $options

Additional options to add to the executed command

Returns

boolean

encodeKey()

encodeKey(  $key) 

Parameters

$key

explodeKey()

explodeKey(  $key) 

Parameters

$key

executeMultiple()

executeMultiple(array|\Guzzle\Service\Traversable  $commands) : array

Execute multiple commands in parallel

Parameters

array|\Guzzle\Service\Traversable $commands

Array of CommandInterface objects to execute

Throws

\Guzzle\Service\Exception\CommandTransferException

Returns

array —

Returns an array of the executed commands

getResourceIteratorFactory()

getResourceIteratorFactory() 

expandTemplate()

expandTemplate(string  $template, array  $variables = null) : string

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

Parameters

string $template

Template to expand

array $variables

Variables to inject

Returns

string

sendMultiple()

sendMultiple(array  $requests) : array

Send multiple requests in parallel

Parameters

array $requests

Array of RequestInterface objects

Returns

array —

Returns an array of Response objects

prepareRequest()

prepareRequest(\Guzzle\Http\Message\RequestInterface  $request, array  $options = array()) : \Guzzle\Http\Message\RequestInterface

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

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request to prepare for the client

array $options

Options to apply to the request

Returns

\Guzzle\Http\Message\RequestInterface

initSsl()

initSsl() 

Initializes SSL settings