DefaultClient.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License").
  6. * You may not use this file except in compliance with the License.
  7. * A copy of the License is located at
  8. *
  9. * http://aws.amazon.com/apache2.0
  10. *
  11. * or in the "license" file accompanying this file. This file is distributed
  12. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied. See the License for the specific language governing
  14. * permissions and limitations under the License.
  15. */
  16. namespace Aws\Common\Client;
  17. use Aws\Common\Enum\ClientOptions as Options;
  18. use Guzzle\Common\Collection;
  19. /**
  20. * Generic client for interacting with an AWS service
  21. */
  22. class DefaultClient extends AbstractClient
  23. {
  24. /**
  25. * Factory method to create a default client using an array of configuration options.
  26. *
  27. * The following array keys and values are available options:
  28. *
  29. * Credential options ((`key`, `secret`, and optional `token`) OR `credentials` is required):
  30. *
  31. * - key: AWS Access Key ID
  32. * - secret: AWS secret access key
  33. * - credentials: You can optionally provide a custom `Aws\Common\Credentials\CredentialsInterface` object
  34. * - token: Custom AWS security token to use with request authentication. Please note that not all services accept temporary credentials. See http://docs.aws.amazon.com/STS/latest/UsingSTS/UsingTokens.html
  35. * - token.ttd: UNIX timestamp for when the custom credentials expire
  36. * - credentials.cache.key: Optional custom cache key to use with the credentials
  37. * - credentials.client: Pass this option to specify a custom `Guzzle\Http\ClientInterface` to use if your credentials require a HTTP request (e.g. RefreshableInstanceProfileCredentials)
  38. *
  39. * Region and endpoint options (Some services do not require a region while others do. Check the service specific user guide documentation for details):
  40. *
  41. * - region: Region name (e.g. 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', etc...)
  42. * - scheme: URI Scheme of the base URL (e.g. 'https', 'http') used when base_url is not supplied
  43. * - base_url: Allows you to specify a custom endpoint instead of building one from the region and scheme
  44. *
  45. * Generic client options:
  46. *
  47. * - signature: Overrides the signature used by the client. Clients will always choose an appropriate default signature. However, it can be useful to override this with a custom setting. This can be set to "v4", "v3https", "v2" or an instance of Aws\Common\Signature\SignatureInterface.
  48. * - ssl.certificate_authority: Set to true to use the bundled CA cert or pass the full path to an SSL certificate bundle
  49. * - curl.options: Associative of CURLOPT_* cURL options to add to each request
  50. * - client.backoff.logger: `Guzzle\Log\LogAdapterInterface` object used to log backoff retries. Use 'debug' to emit PHP warnings when a retry is issued.
  51. * - client.backoff.logger.template: Optional template to use for exponential backoff log messages. See `Guzzle\Plugin\Backoff\BackoffLogger` for formatting information.
  52. *
  53. * @param array|Collection $config Client configuration data
  54. *
  55. * @return self
  56. */
  57. public static function factory($config = array())
  58. {
  59. return ClientBuilder::factory()
  60. ->setConfig($config)
  61. ->setConfigDefaults(array(Options::SCHEME => 'https'))
  62. ->build();
  63. }
  64. }