本文整理汇总了PHP中Aws\Common\Client\ClientBuilder::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientBuilder::factory方法的具体用法?PHP ClientBuilder::factory怎么用?PHP ClientBuilder::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\Common\Client\ClientBuilder
的用法示例。
在下文中一共展示了ClientBuilder::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: factory
/**
* Factory method to create a new Amazon STS client using an array of configuration options:
*
* @param array|Collection $config Client configuration data
*
* @return self
* @throws InvalidArgumentException
* @link http://docs.aws.amazon.com/aws-sdk-php/guide/latest/configuration.html#client-configuration-options
*/
public static function factory($config = array())
{
// Always need long term credentials
if (!isset($config[Options::CREDENTIALS]) && isset($config[Options::TOKEN])) {
throw new InvalidArgumentException('You must use long-term credentials with Amazon STS');
}
// Construct the STS client with the client builder
$client = ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/sts-%s.php'))->build();
// Attach a listener to prevent AssumeRoleWithWebIdentity requests from being signed
$client->getEventDispatcher()->addListener('command.before_send', function (Event $event) {
/** @var AbstractCommand $command */
$command = $event['command'];
if ($command->getName() === 'AssumeRoleWithWebIdentity') {
/** @var EventDispatcher $dispatcher */
$dispatcher = $command->getRequest()->getEventDispatcher();
foreach ($dispatcher->getListeners('request.before_send') as $listener) {
if (is_array($listener) && $listener[0] instanceof SignatureListener) {
$dispatcher->removeListener('request.before_send', $listener);
break;
}
}
}
});
return $client;
}
示例2: factory
/**
* Factory method to create a new Amazon Simple Queue Service client using an array of configuration options.
*
* @param array|Collection $config Client configuration data
*
* @return self
* @see \Aws\Common\Client\DefaultClient for a list of available configuration options
*/
public static function factory($config = array())
{
$client = ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/sqs-%s.php'))->build();
$client->addSubscriber(new QueueUrlListener());
$client->addSubscriber(new Md5ValidatorListener());
return $client;
}
示例3: factory
/**
* Factory method to create a new Amazon CloudFront client using an array of configuration options.
*
* CloudFront specific options (in addition to the default client configuration options):
* - key_pair_id: The ID of the key pair used to sign CloudFront URLs for private distributions.
* - private_key: The filepath ot the private key used to sign CloudFront URLs for private distributions.
*
* @param array|Collection $config Client configuration data
*
* @return self
* @link http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
*/
public static function factory($config = array())
{
// Decide which signature to use
if (isset($config[Options::VERSION]) && $config[Options::VERSION] < self::LATEST_API_VERSION) {
$config[Options::SIGNATURE] = new CloudFrontSignature();
}
// Instantiate the CloudFront client
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/cloudfront-%s.php'))->setExceptionParser(new DefaultXmlExceptionParser())->build();
}
示例4: factory
/**
* Factory method to create a new Amazon DynamoDB Streams client using an array of configuration options.
*
* See http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
*
* @param array|Collection $config Client configuration data
*
* @return self
* @link http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
*/
public static function factory($config = array())
{
// Configure the custom exponential backoff plugin for DynamoDB throttling
$exceptionParser = new JsonQueryExceptionParser();
if (!isset($config[Options::BACKOFF])) {
$config[Options::BACKOFF] = new BackoffPlugin(DynamoDbClient::createDynamoDbBackoffStrategy($exceptionParser));
}
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/dynamodbstreams-%s.php'))->setExceptionParser($exceptionParser)->build();
}
示例5: factory
/**
* Factory method to create a new Amazon CloudFront client using an array of configuration options.
*
* CloudFront specific options (in addition to the default client configuration options):
* - key_pair_id: The ID of the key pair used to sign CloudFront URLs for private distributions.
* - private_key: The filepath ot the private key used to sign CloudFront URLs for private distributions.
*
* @param array|Collection $config Client configuration data
*
* @return self
* @see \Aws\Common\Client\DefaultClient for a list of other available configuration options
*/
public static function factory($config = array())
{
// Decide which signature to use
if (isset($config[Options::VERSION]) && $config[Options::VERSION] < self::LATEST_API_VERSION) {
$config[Options::SIGNATURE] = new CloudFrontSignature();
}
// Instantiate the CloudFront client
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/cloudfront-%s.php'))->setExceptionParser(new DefaultXmlExceptionParser())->setIteratorsConfig(array('token_param' => 'Marker', 'token_key' => 'NextMarker', 'more_key' => 'IsTruncated', 'result_key' => 'Items', 'operations' => array('ListCloudFrontOriginAccessIdentities', 'ListDistributions', 'ListInvalidations', 'ListStreamingDistributions')))->build();
}
示例6: factory
/**
* Factory method to create a new Amazon DynamoDB client using an array of configuration options.
*
* @param array|Collection $config Client configuration data
*
* @return self
* @see \Aws\Common\Client\DefaultClient for a list of available configuration options
*/
public static function factory($config = array())
{
// Configure the custom exponential backoff plugin for DynamoDB throttling
$exceptionParser = new JsonQueryExceptionParser();
if (!isset($config[Options::BACKOFF])) {
$config[Options::BACKOFF] = new BackoffPlugin(new Crc32ErrorChecker(new TruncatedBackoffStrategy(11, new ThrottlingErrorChecker($exceptionParser, new HttpBackoffStrategy(null, new CurlBackoffStrategy(null, new ExpiredCredentialsChecker($exceptionParser, new CallbackBackoffStrategy(__CLASS__ . '::calculateRetryDelay', false))))))));
}
// Construct the DynamoDB client with the client builder
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(self::DISABLE_REDIRECTS => true, Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/dynamodb-%s.php', self::COMMAND_PARAMS => array(Cmd::RESPONSE_PROCESSING => Cmd::TYPE_NO_TRANSLATION)))->setExceptionParser($exceptionParser)->setIteratorsConfig(array('result_key' => 'Items', 'token_param' => 'ExclusiveStartKey', 'token_key' => 'LastEvaluatedKey', 'operations' => array('BatchGetItem' => array('token_param' => 'RequestItems', 'token_key' => 'UnprocessedKeys', 'result_key' => 'Responses/*'), 'ListTables' => array('result_key' => 'TableNames', 'token_param' => 'ExclusiveStartTableName', 'token_key' => 'LastEvaluatedTableName'), 'Query', 'Scan')))->build();
}
示例7: factory
/**
* Factory method to create a new Amazon STS client using an array of configuration options:
*
* Credential options (`key`, `secret`, and optional `token` OR `credentials` is required)
*
* - key: AWS Access Key ID
* - secret: AWS secret access key
* - credentials: You can optionally provide a custom `Aws\Common\Credentials\CredentialsInterface` object
* - token: Custom AWS security token to use with request authentication
* - token.ttd: UNIX timestamp for when the custom credentials expire
* - credentials.cache: Used to cache credentials when using providers that require HTTP requests. Set the true
* to use the default APC cache or provide a `Guzzle\Cache\CacheAdapterInterface` object.
* - credentials.cache.key: Optional custom cache key to use with the credentials
* - credentials.client: Pass this option to specify a custom `Guzzle\Http\ClientInterface` to use if your
* credentials require a HTTP request (e.g. RefreshableInstanceProfileCredentials)
*
* Region and Endpoint options (a `region` and optional `scheme` OR a `base_url` is required)
*
* - region: Region name (e.g. 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', etc...)
* - scheme: URI Scheme of the base URL (e.g. 'https', 'http').
* - base_url: Instead of using a `region` and `scheme`, you can specify a custom base URL for the client
* - endpoint_provider: Optional `Aws\Common\Region\EndpointProviderInterface` used to provide region endpoints
*
* Generic client options
*
* - ssl.certificate_authority: Set to true to use the bundled CA cert (default), system to use the certificate
* bundled with your system, or pass the full path to an SSL certificate bundle. This option should be used when
* you encounter curl error code 60.
* - curl.options: Array of cURL options to apply to every request.
* See http://www.php.net/manual/en/function.curl-setopt.php for a list of available options
* - signature: You can optionally provide a custom signature implementation used to sign requests
* - signature.service: Set to explicitly override the service name used in signatures
* - signature.region: Set to explicitly override the region name used in signatures
* - client.backoff.logger: `Guzzle\Log\LogAdapterInterface` object used to log backoff retries. Use
* 'debug' to emit PHP warnings when a retry is issued.
* - client.backoff.logger.template: Optional template to use for exponential backoff log messages. See
* `Guzzle\Plugin\Backoff\BackoffLogger` for formatting information.
*
* @param array|Collection $config Client configuration data
*
* @return self
*/
public static function factory($config = array())
{
// Construct the STS client with the client builder
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/sts-2011-06-15.php'))->setCredentialsResolver(new CredentialsOptionResolver(function (Collection $config) {
// Always need long term credentials
if ($config->get(Options::KEY) && $config->get(Options::SECRET) && !$config->get(Options::TOKEN)) {
return Credentials::factory($config->getAll(array_keys(Credentials::getConfigDefaults())));
}
}))->build();
}
示例8: factory
/**
* Factory method to create a new Amazon STS client using an array of configuration options:
*
* Credential options (`key`, `secret`, and optional `token` OR `credentials` is required)
*
* - key: AWS Access Key ID
* - secret: AWS secret access key
* - credentials: You can optionally provide a custom `Aws\Common\Credentials\CredentialsInterface` object
* - token: Custom AWS security token to use with request authentication
* - token.ttd: UNIX timestamp for when the custom credentials expire
* - credentials.cache: Used to cache credentials when using providers that require HTTP requests. Set the true
* to use the default APC cache or provide a `Guzzle\Cache\CacheAdapterInterface` object.
* - credentials.cache.key: Optional custom cache key to use with the credentials
* - credentials.client: Pass this option to specify a custom `Guzzle\Http\ClientInterface` to use if your
* credentials require a HTTP request (e.g. RefreshableInstanceProfileCredentials)
*
* Region and Endpoint options (a `region` and optional `scheme` OR a `base_url` is required)
*
* - region: Region name (e.g. 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', etc...)
* - scheme: URI Scheme of the base URL (e.g. 'https', 'http').
* - base_url: Instead of using a `region` and `scheme`, you can specify a custom base URL for the client
* - endpoint_provider: Optional `Aws\Common\Region\EndpointProviderInterface` used to provide region endpoints
*
* Generic client options
*
* - ssl.cert: Set to true to use the bundled CA cert or pass the full path to an SSL certificate bundle. This
* option should be used when you encounter curl error code 60.
* - curl.options: Array of cURL options to apply to every request.
* See http://www.php.net/manual/en/function.curl-setopt.php for a list of available options
* - signature: You can optionally provide a custom signature implementation used to sign requests
* - signature.service: Set to explicitly override the service name used in signatures
* - signature.region: Set to explicitly override the region name used in signatures
* - client.backoff.logger: `Guzzle\Log\LogAdapterInterface` object used to log backoff retries. Use
* 'debug' to emit PHP warnings when a retry is issued.
* - client.backoff.logger.template: Optional template to use for exponential backoff log messages. See
* `Guzzle\Plugin\Backoff\BackoffLogger` for formatting information.
*
* @param array|Collection $config Client configuration data
*
* @return self
*/
public static function factory($config = array())
{
// Construct the STS client with the client builder
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::SERVICE => 'sts', Options::SCHEME => 'https', Options::REGION => 'us-east-1'))->setCredentialsResolver(new CredentialsOptionResolver(function (Collection $config) {
// Always need long term credentials
if ($config->get(Options::KEY) && $config->get(Options::SECRET) && !$config->get(Options::TOKEN)) {
return Credentials::factory($config->getAll(array_keys(Credentials::getConfigDefaults())));
}
}))->setSignature(new SignatureV4())->build();
}
示例9: factory
/**
* Factory method to create a new Amazon DynamoDB client using an array of configuration options.
*
* @param array|Collection $config Client configuration data
*
* @return self
* @link http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
*/
public static function factory($config = array())
{
// Configure the custom exponential backoff plugin for DynamoDB throttling
$exceptionParser = new JsonQueryExceptionParser();
if (!isset($config[Options::BACKOFF])) {
$config[Options::BACKOFF] = new BackoffPlugin(new Crc32ErrorChecker(self::createDynamoDbBackoffStrategy($exceptionParser)));
}
// Construct the DynamoDB client with the client builder
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(self::DISABLE_REDIRECTS => true, Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/dynamodb-%s.php', self::COMMAND_PARAMS => array(Cmd::RESPONSE_PROCESSING => Cmd::TYPE_NO_TRANSLATION)))->setExceptionParser($exceptionParser)->build();
}
示例10: factory
/**
* Factory method to create a new AWS Import/Export client using an array of configuration options.
*
* @param array|Collection $config Client configuration data
*
* @return self
* @see \Aws\Common\Client\DefaultClient for a list of available configuration options
*/
public static function factory($config = array())
{
$client = ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/importexport-%s.php'))->build();
// If the Symfony YAML component is installed, add a listener that will convert arrays to proper YAML in when
// specifying the "Manifest" parameter of the "CreateJob" operation
if (class_exists('Symfony\\Component\\Yaml\\Yaml')) {
$client->addSubscriber(new JobManifestListener());
}
return $client;
}
示例11: factory
/**
* Factory method to create a new Amazon Glacier client using an array of configuration options.
*
* @param array|Collection $config Client configuration data
*
* @return GlacierClient
* @link http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
*/
public static function factory($config = array())
{
// Setup the Glacier client
$client = ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/glacier-%s.php', 'command.params' => array('accountId' => '-', Options::MODEL_PROCESSING => true)))->setExceptionParser(new JsonRestExceptionParser())->build();
// Add the Glacier version header required for all operations
$client->getConfig()->setPath('request.options/headers/x-amz-glacier-version', $client->getDescription()->getApiVersion());
// Allow for specifying bodies with file paths and file handles
$uploadOperations = array('UploadArchive', 'UploadMultipartPart');
$client->addSubscriber(new UploadBodyListener($uploadOperations, 'body', 'sourceFile'));
// Listen for upload operations and make sure the required hash headers are added
$client->addSubscriber(new GlacierUploadListener());
return $client;
}
示例12: getClientFactoryInterfaceMock
protected function getClientFactoryInterfaceMock()
{
$mock = new \mock\LLS\Bundle\AWSBundle\Interfaces\ClientFactoryInterface();
$config = $this->config;
$mock->getMockController()->createClient = function ($type, IdentityInterface $identity) use($config) {
$reflection = new \ReflectionClass("Aws\\Sqs\\SqsClient");
$file = $reflection->getFileName();
$client = ClientBuilder::factory("mock\\Aws\\Sqs")->setConfig($config)->setConfigDefaults(array(Options::VERSION => \Aws\Sqs\SqsClient::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => dirname($file) . '/Resources/sqs-%s.php'))->build();
$client->addSubscriber(new QueueUrlListener());
$client->addSubscriber(new Md5ValidatorListener());
return $client;
};
return $mock;
}
示例13: factory
/**
* Factory method to create a new Amazon Cognito Identity client using an array of configuration options.
*
* See http://docs.aws.amazon.com/aws-sdk-php/guide/latest/configuration.html#client-configuration-options
*
* @param array|Collection $config Client configuration data
*
* @return self
* @link http://docs.aws.amazon.com/aws-sdk-php/guide/latest/configuration.html#client-configuration-options
*/
public static function factory($config = array())
{
$client = ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/cognitoidentity-%s.php'))->setExceptionParser(new JsonQueryExceptionParser())->build();
// Attach a listener to prevent some requests from being signed
$client->getEventDispatcher()->addListener('command.before_send', function (Event $event) {
/** @var AbstractCommand $command */
$command = $event['command'];
if (in_array($command->getName(), array('GetId', 'GetOpenIdToken', 'UnlinkIdentity'))) {
/** @var EventDispatcher $dispatcher */
$dispatcher = $command->getRequest()->getEventDispatcher();
foreach ($dispatcher->getListeners('request.before_send') as $listener) {
if (is_array($listener) && $listener[0] instanceof SignatureListener) {
$dispatcher->removeListener('request.before_send', $listener);
break;
}
}
}
});
return $client;
}
示例14: factory
/**
* Factory method to create a new AWS Config client using an array of configuration options.
*
* See http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
*
* @param array|Collection $config Client configuration data
*
* @return self
* @link http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
*/
public static function factory($config = array())
{
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/configservice-%s.php'))->setExceptionParser(new JsonQueryExceptionParser())->build();
}
示例15: factory
/**
* Factory method to create a new Amazon Simple Workflow Service client using an array of configuration options.
*
* The following array keys and values are available options:
*
* - Credential options (`key`, `secret`, and optional `token` OR `credentials` is required)
* - key: AWS Access Key ID
* - secret: AWS secret access key
* - credentials: You can optionally provide a custom `Aws\Common\Credentials\CredentialsInterface` object
* - token: Custom AWS security token to use with request authentication
* - token.ttd: UNIX timestamp for when the custom credentials expire
* - credentials.cache.key: Optional custom cache key to use with the credentials
* - Region and Endpoint options (a `region` and optional `scheme` OR a `base_url` is required)
* - region: Region name (e.g. 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', etc...)
* - scheme: URI Scheme of the base URL (e.g. 'https', 'http').
* - base_url: Instead of using a `region` and `scheme`, you can specify a custom base URL for the client
* - endpoint_provider: Optional `Aws\Common\Region\EndpointProviderInterface` used to provide region endpoints
* - Generic client options
* - ssl.cert: Set to true to use the bundled CA cert or pass the full path to an SSL certificate bundle. This
* option should be used when you encounter curl error code 60.
* - curl.CURLOPT_VERBOSE: Set to true to output curl debug information during transfers
* - curl.*: Prefix any available cURL option with `curl.` to add cURL options to each request.
* See: http://www.php.net/manual/en/function.curl-setopt.php
* - service.description.cache.ttl: Optional TTL used for the service description cache
* - Signature options
* - signature: You can optionally provide a custom signature implementation used to sign requests
* - signature.service: Set to explicitly override the service name used in signatures
* - signature.region: Set to explicitly override the region name used in signatures
* - Exponential backoff options
* - client.backoff.logger: `Guzzle\Common\Log\LogAdapterInterface` object used to log backoff retries. Use
* 'debug' to emit PHP warnings when a retry is issued.
* - client.backoff.logger.template: Optional template to use for exponential backoff log messages. See
* `Guzzle\Http\Plugin\ExponentialBackoffLogger` for formatting information.
*
* @param array|Collection $config Client configuration data
*
* @return self
*/
public static function factory($config = array())
{
return ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/swf-2012-01-25.php'))->setExceptionParser(new JsonQueryExceptionParser())->build();
}