defaultProvider() public static method

This provider is automatically wrapped in a memoize function that caches previously provided credentials.
public static defaultProvider ( array $config = [] ) : callable
$config array Optional array of instance profile credentials provider options.
return callable
Example #1
0
 private function getCredentialProvider()
 {
     $connection = $this->getConnection();
     if ($connection->hasParam('aws_secret_access_key')) {
         return CredentialProvider::fromCredentials(new Credentials($connection->getParam('aws_access_key_id'), $connection->getParam('aws_secret_access_key'), $connection->hasParam('aws_session_token') ? $connection->getParam('aws_session_token') : null));
     }
     return CredentialProvider::defaultProvider();
 }
Example #2
0
 public static function _default_credentials()
 {
     return CredentialProvider::resolve(CredentialProvider::defaultProvider());
 }
 public static function _apply_credentials($value, array &$args)
 {
     if (is_callable($value)) {
         return;
     } elseif ($value instanceof CredentialsInterface) {
         $args['credentials'] = CredentialProvider::fromCredentials($value);
     } elseif (is_array($value) && isset($value['key']) && isset($value['secret'])) {
         $args['credentials'] = CredentialProvider::fromCredentials(new Credentials($value['key'], $value['secret'], isset($value['token']) ? $value['token'] : null, isset($value['expires']) ? $value['expires'] : null));
     } elseif ($value === false) {
         $args['credentials'] = CredentialProvider::fromCredentials(new Credentials('', ''));
         $args['config']['signature_version'] = 'anonymous';
     } elseif ($value instanceof CacheInterface) {
         $args['credentials'] = CredentialProvider::defaultProvider($args);
     } else {
         throw new IAE('Credentials must be an instance of ' . 'Aws\\Credentials\\CredentialsInterface, an associative ' . 'array that contains "key", "secret", and an optional "token" ' . 'key-value pairs, a credentials provider function, or false.');
     }
 }
Example #4
0
 /**
  * Get events by event name
  *
  * @param null $event_name
  * @return array
  * @throws Exception
  */
 public function getEvents($event_name = null)
 {
     if (empty($event_name)) {
         throw new BusAPIException('Event name not specified.');
     }
     $signer = new SignatureV4('execute-api', 'us-west-2');
     $client = new GuzzleClient(['base_uri' => "https://{$this->host}", 'timeout' => 30, 'curl' => [CURLOPT_SSL_VERIFYPEER => false]]);
     $request = new Request('GET', $this->endpoint, ['Host' => $this->host]);
     if ($this->private_key && $this->public_key) {
         $credentials = new Credentials($this->public_key, $this->private_key);
     } else {
         $credentials = call_user_func(CredentialProvider::defaultProvider())->wait();
     }
     $request = $signer->signRequest($request, $credentials);
     $response = $client->send($request);
     return ['response' => $response, 'results' => json_decode($response->getBody())];
 }