You are here

protected function AkamaiClientV3::purgeRequest in Akamai 8.3

Ask the API to purge an object.

@link https://developer.akamai.com/api/purge/ccu/reference.html @link https://github.com/akamai-open/api-kickstart/blob/master/examples/php/cc...

Parameters

string[] $objects: A non-associative array of Akamai objects to clear.

Return value

\GuzzleHttp\Psr7\Response|bool Response to purge request, or FALSE on failure.

File

src/Plugin/Client/AkamaiClientV3.php, line 59

Class

AkamaiClientV3
Defines the CCUv3 client version for Akamai.

Namespace

Drupal\akamai\Plugin\Client

Code

protected function purgeRequest(array $objects) {
  try {
    $response = $this->client
      ->request('POST', "{$this->apiBaseUrl}{$this->action}/{$this->type}/{$this->domain}", [
      'json' => $this
        ->createPurgeBody($objects),
    ]);

    // Note that the response has useful data that we need to record.
    // Example response body:
    // @code
    // {
    //   "httpStatus": 201,
    //   "detail": "Request accepted.",
    //   "estimatedSeconds": 5,
    //   "purgeId": "043f-4af0-843f-aaf0043faaf0",
    //   "supportId": "17PY1321286429616716-211907680"
    // }.
    // @endcode
    return $response;
  } catch (RequestException $e) {
    $this->logger
      ->error($this
      ->formatExceptionMessage($e));
    return FALSE;

    // @todo better error handling
    // Throw $e;.
  }
}