abstract class BaseCcuClient in Akamai 7.3
Hierarchy
- class \Drupal\akamai\BaseCcuClient implements CcuClientInterface
Expanded class hierarchy of BaseCcuClient
File
- src/
BaseCcuClient.php, line 15 - Constains the Drupal\akamai\BaseCcuClient class.
Namespace
Drupal\akamaiView source
abstract class BaseCcuClient implements CcuClientInterface {
/**
* The string used when invalidating objects.
*/
const OPERATION_INVALIDATE = 'invalidate';
/**
* The string used when removing objects.
*/
const OPERATION_DELETE = 'remove';
/**
* An instance of an OPEN EdgeGrid Client.
*
* @var \Akamai\Open\EdgeGrid\Client
*/
protected $client;
/**
* The network to use when issuing purge requests.
*
* @var string
*/
protected $network;
/**
* The operation to use when issuing purge requests.
*
* @var string
*/
protected $operation;
/**
* Implements CcuClientInterface::__construct().
*/
public function __construct(EdgeGridClient $client) {
$this->client = $client;
$this->network = static::NETWORK_PRODUCTION;
$this->operation = static::OPERATION_INVALIDATE;
}
/**
* Implements CcuClientInterface::setNetwork().
*/
public function setNetwork($network) {
if ($network != static::NETWORK_PRODUCTION && $network != static::NETWORK_STAGING) {
throw new InvalidArgumentException('Invalid network supplied.');
}
$this->network = $network;
return $this;
}
/**
* Implements CcuClientInterface::setOperation().
*/
public function setOperation($operation) {
if ($operation != static::OPERATION_INVALIDATE && $operation != static::OPERATION_DELETE) {
throw new InvalidArgumentException('Invalid operation supplied.');
}
$this->operation = $operation;
return $this;
}
/**
* Implements CcuClientInterface::checkProgress().
*/
public function checkProgress($progress_uri) {
$response = $this->client
->get($progress_uri);
return json_decode($response
->getBody());
}
/**
* Implements CcuClientInterface::postPurgeRequest().
*/
public function postPurgeRequest($hostname, array $paths) {
if (empty($hostname)) {
throw new InvalidArgumentException("Expected hostname to be a non-empty string.");
}
$uri = $this
->getPurgeApiEndpoint();
$response = $this->client
->post($uri, [
'body' => $this
->getPurgeBody($hostname, $paths),
'headers' => [
'Content-Type' => 'application/json',
],
]);
return json_decode($response
->getBody());
}
/**
* Implements CcuClientInterface::bodyIsBelowLimit().
*/
public function bodyIsBelowLimit($hostname, array $paths) {
$body = $this
->getPurgeBody($hostname, $paths);
$bytes = mb_strlen($body, '8bit');
return $bytes < static::MAX_BODY_SIZE;
}
}
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:: |
|
CcuClientInterface:: |
public | function | Generates the URL to use when posting a purge request. | 2 |
CcuClientInterface:: |
public | function | Generates a JSON-encoded body for a purge request. | 2 |
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. |