/**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     // Get the list of objects and record the last key
     $objects = $result->get('Contents') ?: array();
     $numObjects = count($objects);
     $lastKey = $numObjects ? $objects[$numObjects - 1]['Key'] : false;
     if ($lastKey && !$result->hasKey($this->get('token_key'))) {
         $result->set($this->get('token_key'), $lastKey);
     }
     // Closure for getting the name of an object or prefix
     $getName = function ($object) {
         return isset($object['Key']) ? $object['Key'] : $object['Prefix'];
     };
     // If common prefixes returned (i.e. a delimiter was set) and they need to be returned, there is more to do
     if ($this->get('return_prefixes') && $result->hasKey('CommonPrefixes')) {
         // Collect and format the prefixes to include with the objects
         $objects = array_merge($objects, $result->get('CommonPrefixes'));
         // Sort the objects and prefixes to maintain alphabetical order, but only if some of each were returned
         if ($this->get('sort_results') && $lastKey && $objects) {
             usort($objects, function ($object1, $object2) use($getName) {
                 return strcmp($getName($object1), $getName($object2));
             });
         }
     }
     // If only the names are desired, iterate through the results and convert the arrays to the object/prefix names
     if ($this->get('names_only')) {
         $objects = array_map($getName, $objects);
     }
     return $objects;
 }
 /**
  * {@inheritdoc}
  */
 protected function determineNextToken(Model $result)
 {
     $this->nextToken = null;
     if ($result->get($this->get('more_key'))) {
         $jobs = $result->get($this->get('result_key')) ?: array();
         $numJobs = count($jobs);
         $this->nextToken = $numJobs ? $jobs[$numJobs - 1]['JobId'] : null;
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     // Get the list of uploads
     $uploads = $result->get('Uploads') ?: array();
     // If there are prefixes and we want them, merge them in
     if ($this->get('return_prefixes') && $result->hasKey('CommonPrefixes')) {
         $uploads = array_merge($uploads, $result->get('CommonPrefixes'));
     }
     return $uploads;
 }
 /**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     // Get the list of object versions
     $versions = $result->get('Versions') ?: array();
     $deleteMarkers = $result->get('DeleteMarkers') ?: array();
     $versions = array_merge($versions, $deleteMarkers);
     // If there are prefixes and we want them, merge them in
     if ($this->get('return_prefixes') && $result->hasKey('CommonPrefixes')) {
         $versions = array_merge($versions, $result->get('CommonPrefixes'));
     }
     return $versions;
 }
Esempio n. 5
0
 public function testOwnsStructure()
 {
     $param = new Parameter(array('type' => 'object'));
     $model = new Model(array('foo' => 'bar'), $param);
     $this->assertSame($param, $model->getStructure());
     $this->assertEquals('bar', $model->get('foo'));
     $this->assertEquals('bar', $model['foo']);
 }
 /**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     // Get the results
     $buckets = $result->get('Buckets') ?: array();
     // If only the names_only set, change arrays to a string
     if ($this->get('names_only')) {
         foreach ($buckets as &$bucket) {
             $bucket = $bucket['Name'];
         }
     }
     return $buckets;
 }
 /**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     $items = array();
     if ($responses = $result->get('Responses')) {
         foreach ($responses as $table) {
             foreach ($table['Items'] as $item) {
                 $items[] = $item;
             }
         }
     }
     return $items;
 }
 /**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     $instances = array();
     // Invert the structure so that instances are yielded and the reservation is exposed as a property
     foreach ($result->get('Reservations') as $reservation) {
         foreach ($reservation['Instances'] as $instance) {
             $instance['Reservation'] = $reservation;
             unset($instance['Reservation']['Instances']);
             $instances[] = $instance;
         }
     }
     return $instances;
 }
Esempio n. 9
0
 /**
  * Hydrate common values from an Guzzle model to an event
  *
  * @param WorkflowEvent $event
  * @param Model         $model
  */
 protected function hydrateWorkflowEvent(WorkflowEvent $event, Model $model)
 {
     $event->setEventId($model->get('startedEventId'));
     $event->setExecutionId($model->get('workflowExecution')['workflowId']);
     $event->setRunId($model->get('workflowExecution')['runId']);
     $event->setToken($model->get('taskToken'));
     $event->setWorkflowName($model->get('workflowType')['name']);
     $event->setWorkflowVersion($model->get('workflowType')['version']);
 }
Esempio n. 10
0
 /**
  * Add history from a Guzzle object to the workflow
  *
  * @param DecisionEvent $event
  * @param Model         $model
  */
 private function addHistory(DecisionEvent $event, Model $model)
 {
     $history = $event->getHistory();
     $items = $model->get('events');
     foreach ($items as $item) {
         $this->parseHistoryItem($history, $item);
     }
 }
Esempio n. 11
0
 /**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     $this->scannedCount += (int) $result->get('ScannedCount');
     return parent::handleResults($result);
 }
 /**
  * {@inheritdoc}
  */
 protected function determineNextToken(Model $result)
 {
     $this->nextToken = $result->get('Marker');
 }
 public function fromModel(Model $model)
 {
     if ($model->hasKey('domainInfo')) {
         $domainInfo = $model->get('domainInfo');
         $this->fromArray($domainInfo);
         if (array_key_exists('name', $domainInfo)) {
             $this->setName($domainInfo['name']);
         }
         if (array_key_exists('status', $domainInfo)) {
             $this->setStatus($domainInfo['status']);
         }
         if (array_key_exists('description', $domainInfo)) {
             $this->setDescription($domainInfo['description']);
         }
     }
     if ($model->hasKey('configuration')) {
         $configuration = $model->get('configuration');
         if (array_key_exists('workflowExecutionRetentionPeriodInDays', $configuration)) {
             $this->setWorkflowExecutionRetentionPeriodInDays($configuration['workflowExecutionRetentionPeriodInDays']);
         }
     }
 }