You are here

akamai.drush.inc in Akamai 7.3

Same filename and directory in other branches
  1. 7.2 akamai.drush.inc

Drush commands for interacting with Akamai's CCU API.

File

akamai.drush.inc
View source
<?php

/**
 * @file
 * Drush commands for interacting with Akamai's CCU API.
 */

/**
 * Implements hook_drush_command().
 */
function akamai_drush_command() {
  $items = array();
  $items['akamai-clear-url'] = array(
    'description' => 'Akamai clear url.',
    'arguments' => array(
      'path' => 'A path to clear. You can provide as many paths you like.',
    ),
    'options' => array(
      'action' => 'Clearing action type.',
      'domain' => 'The Akamai domain to use for cache clearing.',
    ),
    'aliases' => array(
      'akcu',
    ),
    'callback' => 'akamai_drush_clear_url',
  );
  return $items;
}

/**
 * Callback function for ak-clear-url command.
 *
 * Runs the akamai clear url command
 */
function akamai_drush_clear_url() {
  $paths = func_get_args();
  $overrides = array();
  if (drush_get_option('action')) {
    $overrides['action'] = drush_get_option('action');
  }
  if (drush_get_option('domain')) {
    $overrides['domain'] = drush_get_option('domain');
  }
  $did_clear = akamai_purge_path($paths, $overrides);
  if ($did_clear) {
    $message = t("Akamai Cache Request has been made successfully, please allow 10 minutes for changes to take effect.\n") . print_r($paths, TRUE);
    drush_print("{$message}\n");
  }
  else {
    drush_set_error(t("There was a problem with your cache control request."));
  }
}

Functions

Namesort descending Description
akamai_drush_clear_url Callback function for ak-clear-url command.
akamai_drush_command Implements hook_drush_command().