示例#1
0
 /**
  * @param $fileConfiguration
  * @return array
  */
 public function getFiles($fileConfiguration)
 {
     $options = new ListFilesOptions();
     if (empty($fileConfiguration['tags']) && empty($fileConfiguration['query'])) {
         throw new InvalidInputException("Invalid file mapping, both 'tags' and 'query' are empty.");
     }
     if (!empty($fileConfiguration['filter_by_run_id'])) {
         $options->setRunId($this->getParentRunId());
     }
     if (isset($fileConfiguration["tags"]) && count($fileConfiguration["tags"])) {
         $options->setTags($fileConfiguration["tags"]);
     }
     if (isset($fileConfiguration["query"])) {
         $options->setQuery($fileConfiguration["query"]);
     }
     $files = $this->getClient()->listFiles($options);
     // a little sanity check, otherwise it may easily happen that a wrong ES query would fill up the server
     if (empty($fileConfiguration["limit"])) {
         $fileConfiguration["limit"] = 10;
     }
     if (count($files) > $fileConfiguration["limit"]) {
         throw new InvalidInputException("File input mapping downloads more than {$fileConfiguration['limit']} files, this seems like a mistake.");
     }
     return $files;
 }