Ejemplo n.º 1
0
 /**
  * Creates credentials from the result of an STS operations
  *
  * @param Result $result Result of an STS operation
  *
  * @return Credentials
  * @throws \InvalidArgumentException if the result contains no credentials
  */
 public function createCredentials(Result $result)
 {
     if (!$result->hasKey('Credentials')) {
         throw new \InvalidArgumentException('Result contains no credentials');
     }
     $c = $result['Credentials'];
     return new Credentials($c['AccessKeyId'], $c['SecretAccessKey'], isset($c['SessionToken']) ? $c['SessionToken'] : null, isset($c['Expiration']) && $c['Expiration'] instanceof \DateTimeInterface ? (int) $c['Expiration']->format('U') : null);
 }
Ejemplo n.º 2
0
 /**
  * Creates credentials from the result of an STS operations
  *
  * @param Result $result Result of an STS operation
  *
  * @return Credentials
  * @throws \InvalidArgumentException if the result contains no credentials
  */
 public function createCredentials(Result $result)
 {
     if (!$result->hasKey('Credentials')) {
         throw new \InvalidArgumentException('Result contains no credentials');
     }
     $c = $result['Credentials'];
     return new Credentials($c['AccessKeyId'], $c['SecretAccessKey'], isset($c['SessionToken']) ? $c['SessionToken'] : null, isset($c['Expiration']) ? $c['Expiration'] : null);
 }
Ejemplo n.º 3
0
 protected function getRows(\Aws\Result $changeSetResult)
 {
     $rows = [];
     foreach ($changeSetResult->search('Changes[]') as $change) {
         $resourceChange = $change['ResourceChange'];
         $rows[] = [$this->decorateChangesetAction($resourceChange['Action']), $resourceChange['LogicalResourceId'], isset($resourceChange['PhysicalResourceId']) ? $resourceChange['PhysicalResourceId'] : '', $resourceChange['ResourceType'], isset($resourceChange['Replacement']) ? Decorator::decorateChangesetReplacement($resourceChange['Replacement']) : ''];
     }
     return $rows;
 }
Ejemplo n.º 4
0
 /**
  * @Then /^the topic "([^"]*)" should not exist$/
  */
 public function theTopicShouldNotExist($name)
 {
     PHPUnit_Framework_Assert::assertTrue($this->result->hasKey('Topics'));
     $topics = $this->result->get('Topics');
     PHPUnit_Framework_Assert::assertTrue(is_array($topics));
     PHPUnit_Framework_Assert::assertNotEmpty($topics);
     $arn = $this->getArnByName($name);
     $filtered = array_filter($topics, function ($topic) use($arn) {
         return $topic['TopicArn'] === $arn;
     });
     PHPUnit_Framework_Assert::assertEmpty($filtered);
 }
Ejemplo n.º 5
0
 /**
  * Creates credentials from the result of an STS operations
  *
  * @param Result $result Result of an STS operation
  *
  * @return Credentials
  * @throws \InvalidArgumentException if the result contains no credentials
  */
 public function createCredentials(Result $result)
 {
     if (!$result->hasKey('Credentials')) {
         throw new \InvalidArgumentException('Result contains no credentials');
     }
     return new Credentials($result->getPath('Credentials/AccessKeyId'), $result->getPath('Credentials/SecretAccessKey'), $result->getPath('Credentials/SessionToken'), $result->getPath('Credentials/Expiration'));
 }
Ejemplo n.º 6
0
 private function determineNextToken(Result $result)
 {
     if (!$this->config['output_token']) {
         return null;
     }
     if ($this->config['more_results'] && !$result->search($this->config['more_results'])) {
         return null;
     }
     $nextToken = is_array($this->config['output_token']) ? array_filter($result->search(json_encode($this->config['output_token']))) : $result->search($this->config['output_token']);
     return $nextToken;
 }
 /**
  * @param Result $awsResult
  * @param        $resultDocument
  * @return CloudSearchResult
  * @throws \Exception
  */
 private function convertResult(Result $awsResult, $resultDocument)
 {
     $time = $awsResult->getPath('status/timems');
     $amountOfHits = $awsResult->getPath('hits/found');
     $start = $awsResult->getPath('hits/start');
     $cursor = $awsResult->getPath('hits/cursor');
     $facets = $awsResult->getPath('facets');
     $result = new CloudSearchResult($amountOfHits, $start, $time, $facets, $cursor);
     $result->fillWithHits($awsResult->getPath('hits/hit'), $resultDocument);
     return $result;
 }
Ejemplo n.º 8
0
 private function determineNextToken(Result $result)
 {
     if (!$this->config['output_token']) {
         return null;
     }
     if ($this->config['more_results'] && !$result->search($this->config['more_results'])) {
         return null;
     }
     $nextToken = is_scalar($this->config['output_token']) ? [$this->config['input_token'] => $this->config['output_token']] : array_combine($this->config['input_token'], $this->config['output_token']);
     return array_filter(array_map(function ($outputToken) use($result) {
         return $result->search($outputToken);
     }, $nextToken));
 }