/** * @test */ public function testToXml() { $cfg = new DistributionConfigData(); $cfg->setAliases(array(array('cname' => 'cname-1'), new DistributionConfigAliasData('cname-2'))); $cfg->callerReference = 'caller-reference'; $cfg->comment = 'the-comment'; $cfg->enabled = true; $cfg->priceClass = 'price-class'; $cfg->defaultRootObject = 'default-root-object'; $cbd = new CacheBehaviorData(); $cbd->minTtl = 3600; $cbd->pathPattern = 'path-pattern'; $cbd->targetOriginId = 'target-origin-id'; $cbd->viewerProtocolPolicy = 'pp-1'; $cbd->setTrustedSigners(array(array('awsAccountNumber' => 'awsAccountNumber-1'), array('awsAccountNumber' => 'awsAccountNumber-2'))); $fc = new ForwardedValuesCookiesData(); $fc->forward = 'whitelist'; $fc->setWhitelistedNames(array(array('name' => 'cookie-name-1'), array('name' => 'cookie-name-2'))); $fwd = new ForwardedValuesData(); $fwd->queryString = true; $fwd->setCookies($fc); $cbd->setForwardedValues($fwd); $cfg->setCacheBehaviors(array($cbd, $cbd)); $cfg->setDefaultCacheBehavior($cbd); $this->assertEquals($this->getFixtureFileContent('CloudFront/20150727/DistributionConfig1.xml'), $cfg->toXml()); unset($cfg); }
/** * PUT Distribution Config action * * @param string $distributionId ID of the distribution. * @param DistributionConfigData|string $config Config for distribution. It accepts object or xml document. * @param string $eTag ETag that is retrieved from getDistributionConfig request. * @return DistributionData Returns DistributionData object. * @throws CloudFrontException * @throws ClientException */ public function setDistributionConfig($distributionId, $config, $eTag) { $result = null; $options = array('If-Match' => (string) $eTag, '_putData' => $config instanceof DistributionConfigData ? $config->toXml() : (string) $config, 'Expect' => ''); $response = $this->client->call('PUT', $options, sprintf('/distribution/%s/config', self::escape($distributionId))); if ($response->getError() === false) { $sxml = simplexml_load_string($response->getRawContent()); $result = $this->_loadDistributionData($sxml); $result->setOriginalXml($response->getRawContent()); $result->setETag($response->getHeader('ETag')); $result->distributionConfig->setETag($response->getHeader('ETag')); } return $result; }