示例#1
0
 public function postPurgeRequest()
 {
     $purge_body = ["objects" => ["https://developer.akamai.com/stuff/Akamai_Time_Reference/AkamaiTimeReference.html"]];
     printf("Adding %s to queue\n", json_encode($purge_body, JSON_UNESCAPED_SLASHES));
     $response = $this->client->post('/ccu/v2/queues/default', ['body' => json_encode($purge_body), 'headers' => ['Content-Type' => 'application/json']]);
     return $response;
 }
示例#2
0
 /**
  * @action = invalidate, delete
  * @type = url, cpcode
  * @network = production, staging
  * @objects = array of objects
  */
 public function postRequest($action, $type, $network, $object)
 {
     if (count($object['objects']) < 1) {
         throw new Exception("Object is empty");
     }
     $_body = json_encode($object);
     $_bodyLength = mb_strlen($_body);
     if ($_bodyLength >= self::MAX_REQUEST_BODY) {
         throw new Exception("Body message is longer than maximum limit of " . self::MAX_REQUEST_BODY . ": {$_bodyLength}");
     }
     if ($action != 'invalidate' && $action != 'delete') {
         throw new Exception("Invalid action {$action}");
     }
     if ($type != 'url' && $type != 'cpcode') {
         throw new Exception("Invalid type {$type}");
     }
     if ($network != 'production' && $network != 'staging') {
         throw new Exception("Invalid network {$network}");
     }
     $_URL = self::BASE_URL . "/{$action}/{$type}/{$network}";
     $response = $this->client->post($_URL, ['body' => $_body, 'headers' => ['Content-Type' => 'application/json']]);
     return $response;
 }
function clean_challenge()
{
    global $argv, $zone;
    $client = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile();
    $response = $client->get("/config-dns/v1/zones/{$zone}");
    $dns = json_decode($response->getBody());
    $dns->zone->soa->serial++;
    $domain = str_replace(".{$zone}", '', $argv[2]);
    foreach ($dns->zone->txt as $k => $txt) {
        if ($txt->name == "_acme-challenge.{$domain}") {
            array_splice($dns->zone->txt, $k, 1);
            break;
        }
    }
    $json = json_encode($dns);
    try {
        $client->post("/config-dns/v1/zones/{$zone}", ['body' => $json, 'headers' => ['Content-Type' => 'application/json']]);
    } catch (GuzzleHttp\Exception\ServerException $e) {
        echo "An error occurred: " . $e->getMessage() . "\n";
    }
}
示例#4
0
<?php

# This file is _only_ used to setup and run these command line examples.
include __DIR__ . '/composer.php';
$cli = new League\CLImate\CLImate();
$cli->arguments->add(['debug' => ['prefix' => 'd', 'longPrefix' => 'debug', 'description' => 'Enable Debug Mode: Output HTTP traffic to STDOUT', 'defaultValue' => false, 'noValue' => true], 'verbose' => ['prefix' => 'v', 'longPrefix' => 'verbose', 'description' => 'Enable Verbose Mode: Output response bodies (JSON) to STDOUT', 'defaultValue' => false, 'noValue' => true], 'file' => ['prefix' => 'e', 'longPrefix' => 'edgerc', 'description' => 'Path to .edgerc file', 'defaultValue' => null], 'section' => ['prefix' => 's', 'longPrefix' => 'section', 'description' => '.edgerc section to use', 'defaultValue' => 'default'], 'help' => ['prefix' => 'h', 'longPrefix' => 'help', 'description' => 'Show this help', 'defaultValue' => false, 'noValue' => true]]);
$cli->arguments->parse($_SERVER['argv']);
if ($cli->arguments->get('help')) {
    $cli->usage();
    exit;
}
if ($cli->arguments->get('debug')) {
    \Akamai\Open\EdgeGrid\Client::setDebug(true);
}
if ($cli->arguments->get('verbose')) {
    \Akamai\Open\EdgeGrid\Client::setVerbose(true);
}
$configFile = $cli->arguments->get('config');
$configSection = $cli->arguments->get('section');
if (!extension_loaded('curl')) {
    $cli->whisper("PHP curl extension not enabled. Output from --debug may be less useful.");
}
示例#5
0
 public function postPurgeRequest($hostname, $objects)
 {
     $purge_body = ['hostname' => $hostname, 'objects' => $objects];
     $response = $this->client->post('/ccu/v3/invalidate/url', ['body' => json_encode($purge_body), 'headers' => ['Content-Type' => 'application/json']]);
     return $response;
 }
示例#6
0
 public function getMonthlyReport($product, $startDate, $statisticType, $source)
 {
     $path = implode('/', ['/billing-usage/v1/contractUsageData/monthly', $product, $source['type'], $source['id'], $statisticType, $startDate['month'], $startDate['year'], $startDate['month'], $startDate['year']]);
     $report = $this->client->get($path);
     return (string) $report->getBody();
 }