You are here

class Ccu3Client in Akamai 7.3

Hierarchy

Expanded class hierarchy of Ccu3Client

2 files declare their use of Ccu3Client
BatcherTest.php in tests/BatcherTest.php
Unit tests for the Drupal\akamai\Batcher class.
Ccu3ClientTest.php in tests/Ccu3ClientTest.php
Unit tests for the Drupal\akamai\Ccu3Client class.

File

src/Ccu3Client.php, line 12
Contains the Drupal\akamai\Ccu3Client class.

Namespace

Drupal\akamai
View source
class Ccu3Client extends BaseCcuClient implements CcuClientInterface {

  /**
   * The version of the CCU API.
   *
   * @var string
   */
  protected $version = 'v3';

  /**
   * The string used when removing objects.
   */
  const OPERATION_DELETE = 'delete';

  /**
   * Implements CcuClientInterface::getPurgeApiEndpoint().
   */
  public function getPurgeApiEndpoint() {
    return "/ccu/{$this->version}/{$this->operation}/url/{$this->network}";
  }

  /**
   * Implements CcuClientInterface::getPurgeBody().
   */
  public function getPurgeBody($hostname, array $paths) {

    // Strip whitespace from paths and ensure each path begins with a '/'.
    foreach ($paths as $key => $path) {
      $paths[$key] = rtrim(preg_match("/^\\//", $path) ? $path : "/{$path}");
    }
    $purge_body = array(
      'hostname' => $hostname,
      'objects' => array_unique($paths),
    );

    // Ensure a non-associative array for json_encode() so it will output an
    // array instead of an object.
    $purge_body['objects'] = array_values($purge_body['objects']);

    // Use JSON_UNESCAPED_SLASHES to reduce amount of data in request body.
    return json_encode($purge_body, JSON_UNESCAPED_SLASHES);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BaseCcuClient::$client protected property An instance of an OPEN EdgeGrid Client.
BaseCcuClient::$network protected property The network to use when issuing purge requests.
BaseCcuClient::$operation protected property The operation to use when issuing purge requests.
BaseCcuClient::bodyIsBelowLimit public function Implements CcuClientInterface::bodyIsBelowLimit(). Overrides CcuClientInterface::bodyIsBelowLimit
BaseCcuClient::checkProgress public function Implements CcuClientInterface::checkProgress(). Overrides CcuClientInterface::checkProgress
BaseCcuClient::OPERATION_INVALIDATE constant The string used when invalidating objects.
BaseCcuClient::postPurgeRequest public function Implements CcuClientInterface::postPurgeRequest(). Overrides CcuClientInterface::postPurgeRequest
BaseCcuClient::setNetwork public function Implements CcuClientInterface::setNetwork(). Overrides CcuClientInterface::setNetwork
BaseCcuClient::setOperation public function Implements CcuClientInterface::setOperation(). Overrides CcuClientInterface::setOperation
BaseCcuClient::__construct public function Implements CcuClientInterface::__construct(). Overrides CcuClientInterface::__construct
Ccu3Client::$version protected property The version of the CCU API.
Ccu3Client::getPurgeApiEndpoint public function Implements CcuClientInterface::getPurgeApiEndpoint(). Overrides CcuClientInterface::getPurgeApiEndpoint
Ccu3Client::getPurgeBody public function Implements CcuClientInterface::getPurgeBody(). Overrides CcuClientInterface::getPurgeBody
Ccu3Client::OPERATION_DELETE constant The string used when removing objects. Overrides BaseCcuClient::OPERATION_DELETE
CcuClientInterface::MAX_BODY_SIZE constant The maximum size, in bytes, of a request body allowed by the API.
CcuClientInterface::NETWORK_PRODUCTION constant String constant for the production network.
CcuClientInterface::NETWORK_STAGING constant String constant for the staging network.