/usr/share/php/Aws/CloudSearchDomain/CloudSearchDomainClientBuilder.php is in php-aws-sdk 2.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | <?php
namespace Aws\CloudSearchDomain;
use Aws\Common\Client\ClientBuilder;
use Aws\Common\Client\ThrottlingErrorChecker;
use Aws\Common\Client\UserAgentListener;
use Aws\Common\Credentials\Credentials;
use Aws\Common\Enum\ClientOptions as Options;
use Aws\Common\Exception\ExceptionListener;
use Aws\Common\Exception\InvalidArgumentException;
use Aws\Common\Exception\NamespaceExceptionFactory;
use Aws\Common\Exception\Parser\JsonQueryExceptionParser;
use Aws\Common\Signature\SignatureV4;
use Guzzle\Common\Collection;
use Guzzle\Http\Url;
use Guzzle\Plugin\Backoff\BackoffPlugin;
use Guzzle\Plugin\Backoff\CurlBackoffStrategy;
use Guzzle\Plugin\Backoff\ExponentialBackoffStrategy;
use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
use Guzzle\Plugin\Backoff\TruncatedBackoffStrategy;
use Guzzle\Service\Description\ServiceDescription;
/**
* Builder for creating CloudSearchDomain clients
*
* @internal
*/
class CloudSearchDomainClientBuilder extends ClientBuilder
{
protected static $commonConfigDefaults = array(
Options::SCHEME => 'https',
);
public function build()
{
// Resolve configuration
$config = Collection::fromConfig(
$this->config,
array_merge(self::$commonConfigDefaults, $this->configDefaults),
$this->configRequirements
);
// Make sure base_url is correctly set
if (!($baseUrl = $config->get(Options::BASE_URL))) {
throw new InvalidArgumentException('You must provide the endpoint for the CloudSearch domain.');
} elseif (strpos($baseUrl, 'http') !== 0) {
$config->set(Options::BASE_URL, Url::buildUrl(array(
'scheme' => $config->get(Options::SCHEME),
'host' => $baseUrl,
)));
}
// Determine the region from the endpoint
$endpoint = Url::factory($config->get(Options::BASE_URL));
list(,$region) = explode('.', $endpoint->getHost());
$config[Options::REGION] = $config[Options::SIGNATURE_REGION] = $region;
// Create dependencies
$exceptionParser = new JsonQueryExceptionParser();
$description = ServiceDescription::factory(sprintf(
$config->get(Options::SERVICE_DESCRIPTION),
$config->get(Options::VERSION)
));
$signature = $this->getSignature($description, $config);
$credentials = $this->getCredentials($config);
// Resolve backoff strategy
$backoff = $config->get(Options::BACKOFF);
if ($backoff === null) {
$backoff = new BackoffPlugin(
// Retry failed requests up to 3 times if it is determined that the request can be retried
new TruncatedBackoffStrategy(3,
// Retry failed requests with 400-level responses due to throttling
new ThrottlingErrorChecker($exceptionParser,
// Retry failed requests due to transient network or cURL problems
new CurlBackoffStrategy(null,
// Retry failed requests with 500-level responses
new HttpBackoffStrategy(array(500, 503, 509),
new ExponentialBackoffStrategy()
)
)
)
)
);
$config->set(Options::BACKOFF, $backoff);
}
if ($backoff) {
$this->addBackoffLogger($backoff, $config);
}
// Create client
$client = new CloudSearchDomainClient($credentials, $signature, $config);
$client->setDescription($description);
// Add exception marshaling so that more descriptive exception are thrown
$client->addSubscriber(new ExceptionListener(new NamespaceExceptionFactory(
$exceptionParser,
__NAMESPACE__ . '\\Exception',
__NAMESPACE__ . '\\Exception\\CloudSearchDomainException'
)));
// Add the UserAgentPlugin to append to the User-Agent header of requests
$client->addSubscriber(new UserAgentListener);
// Filters used for the cache plugin
$client->getConfig()->set(
'params.cache.key_filter',
'header=date,x-amz-date,x-amz-security-token,x-amzn-authorization'
);
// Disable parameter validation if needed
if ($config->get(Options::VALIDATION) === false) {
$params = $config->get('command.params') ?: array();
$params['command.disable_validation'] = true;
$config->set('command.params', $params);
}
return $client;
}
}
|