/** * Creates invalidation bath * * @static * @param integer $distributionId * @param array $paths * @return array|bool */ public static function createInvalidation($distributionId, $paths) { self::$use_ssl = true; // CloudFront requires SSL $rest = new S3Request('POST', '', '2010-11-01/distribution/' . $distributionId . '/invalidation', 'cloudfront.amazonaws.com'); $rest->data = self::__getCloudFrontInvalidationBath($paths); $rest->size = strlen($rest->data); $rest->setHeader('Content-Type', 'application/xml'); $rest = self::__getCloudFrontResponse($rest); if ($rest->error === false && $rest->code !== 201) { $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status'); } if ($rest->error !== false) { trigger_error(sprintf("S3::createInvalidation(%d, '%s'): [%s] %s", $distributionId, implode(', ', $paths), $rest->error['code'], $rest->error['message']), E_USER_WARNING); return false; } elseif ($rest->body instanceof SimpleXMLElement) { return self::__parseCloudFrontInvalidation($rest->body); } return false; }
/** * Get a list of CloudFront distributions * * @return array */ public static function listDistributions() { self::$use_ssl = true; // CloudFront requires SSL $rest = new S3Request('GET', '', '2008-06-30/distribution', 'cloudfront.amazonaws.com'); $rest = self::__getCloudFrontResponse($rest); if ($rest->error === false && $rest->code !== 200) { $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status'); } if ($rest->error !== false) { trigger_error(sprintf("S3::listDistributions(): [%s] %s", $rest->error['code'], $rest->error['message']), E_USER_WARNING); return false; } elseif ($rest->body instanceof SimpleXMLElement && isset($rest->body->DistributionSummary)) { $list = array(); if (isset($rest->body->Marker, $rest->body->MaxItems, $rest->body->IsTruncated)) { //$info['marker'] = (string)$rest->body->Marker; //$info['maxItems'] = (int)$rest->body->MaxItems; //$info['isTruncated'] = (string)$rest->body->IsTruncated == 'true' ? true : false; } foreach ($rest->body->DistributionSummary as $summary) { $list[(string) $summary->Id] = self::__parseCloudFrontDistributionConfig($summary); } return $list; } return array(); }