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; }
public function getCsvReport($productList, $startDate, $endDate, $source) { echo "\nRequesting a csv report for the given time period\n"; $headers = ['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8', 'Accept' => '*/*']; $path = "/billing-usage/v1/contractUsageData/csv"; $parameters = ["reportSources" => [$source], "products" => $productList, "startDate" => $startDate, "endDate" => $endDate]; $parameters = array_map('json_encode', $parameters); $response = $this->client->post($path, ['form_params' => $parameters, 'headers' => $headers]); $products = (string) $response->getBody(); return $products; }
/** * @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; }
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; }