class Ccu2Client in Akamai 7.3
Hierarchy
- class \Drupal\akamai\BaseCcuClient implements CcuClientInterface
- class \Drupal\akamai\Ccu2Client implements CcuClientInterface
Expanded class hierarchy of Ccu2Client
File
- src/
Ccu2Client.php, line 15 - Contains the Drupal\akamai\Ccu2Client class.
Namespace
Drupal\akamaiView source
class Ccu2Client extends BaseCcuClient implements CcuClientInterface {
/**
* The version of the CCU API.
*
* @var string
*/
protected $version = 'v2';
/**
* The queue to use when issuing a purge request.
*
* @var string
*/
protected $queuename = 'default';
/**
* Sets the queue name.
*
* @param string $queuename
* Valid values are 'default' and 'emergency'.
*/
public function setQueueName($queuename) {
if ($queuename != 'default' && $queuename != 'emergency') {
throw new InvalidArgumentException('Invalid queue name supplied.');
}
$this->queuename = $queuename;
}
/**
* Gets the number of items in the queue.
*
* @return int
* The number of pending purge requests in the queue.
*/
public function getQueueLength() {
$uri = "/ccu/{$this->version}/queues/{$this->queuename}";
$response = $this->client
->get($uri);
return json_decode($response
->getBody())->queueLength;
}
/**
* Implements CcuClientInterface::getPurgeApiEndpoint().
*/
public function getPurgeApiEndpoint() {
return "/ccu/{$this->version}/queues/{$this->queuename}";
}
/**
* Implements CcuClientInterface::getPurgeBody().
*/
public function getPurgeBody($hostname, array $paths) {
// Strip whitespace from paths and ensure each path begins with a '/'.
// CCU API v2 requires absolute URLs, so prepend hostname and schemes.
foreach ($paths as $key => $path) {
$path = rtrim(preg_match("/^\\//", $path) ? $path : "/{$path}");
$paths[$key] = 'http://' . $hostname . $path;
$paths[] = 'https://' . $hostname . $path;
}
$purge_body = array(
'action' => $this->operation,
'objects' => array_unique($paths),
'domain' => $this->network,
);
return json_encode($purge_body);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BaseCcuClient:: |
protected | property | An instance of an OPEN EdgeGrid Client. | |
BaseCcuClient:: |
protected | property | The network to use when issuing purge requests. | |
BaseCcuClient:: |
protected | property | The operation to use when issuing purge requests. | |
BaseCcuClient:: |
public | function |
Implements CcuClientInterface::bodyIsBelowLimit(). Overrides CcuClientInterface:: |
|
BaseCcuClient:: |
public | function |
Implements CcuClientInterface::checkProgress(). Overrides CcuClientInterface:: |
|
BaseCcuClient:: |
constant | The string used when removing objects. | 1 | |
BaseCcuClient:: |
constant | The string used when invalidating objects. | ||
BaseCcuClient:: |
public | function |
Implements CcuClientInterface::postPurgeRequest(). Overrides CcuClientInterface:: |
|
BaseCcuClient:: |
public | function |
Implements CcuClientInterface::setNetwork(). Overrides CcuClientInterface:: |
|
BaseCcuClient:: |
public | function |
Implements CcuClientInterface::setOperation(). Overrides CcuClientInterface:: |
|
BaseCcuClient:: |
public | function |
Implements CcuClientInterface::__construct(). Overrides CcuClientInterface:: |
|
Ccu2Client:: |
protected | property | The queue to use when issuing a purge request. | |
Ccu2Client:: |
protected | property | The version of the CCU API. | |
Ccu2Client:: |
public | function |
Implements CcuClientInterface::getPurgeApiEndpoint(). Overrides CcuClientInterface:: |
|
Ccu2Client:: |
public | function |
Implements CcuClientInterface::getPurgeBody(). Overrides CcuClientInterface:: |
|
Ccu2Client:: |
public | function | Gets the number of items in the queue. | |
Ccu2Client:: |
public | function | Sets the queue name. | |
CcuClientInterface:: |
constant | The maximum size, in bytes, of a request body allowed by the API. | ||
CcuClientInterface:: |
constant | String constant for the production network. | ||
CcuClientInterface:: |
constant | String constant for the staging network. |