예제 #1
0
 /**
  * Do not instantiate this class directly.
  * Please call Splunk_Job::getResults() instead.
  */
 public function __construct($job, $args)
 {
     list($args, $pageMaxSize) = Splunk_Util::extractArgument($args, 'pagesize', -1);
     list($args, $offset) = Splunk_Util::extractArgument($args, 'offset', 0);
     list($args, $count) = Splunk_Util::extractArgument($args, 'count', -1);
     if ($pageMaxSize <= 0 && $pageMaxSize != -1) {
         throw new InvalidArgumentException('Page size must be positive or -1 (infinity).');
     }
     if ($offset < 0) {
         throw new InvalidArgumentException('Offset must be >= 0.');
     }
     if ($count <= 0 && $count != -1) {
         throw new InvalidArgumentException('Count must be positive or -1 (infinity).');
     }
     // (Use PHP_INT_MAX for infinity internally because it works
     //  well with the min() function.)
     if ($pageMaxSize == -1) {
         $pageMaxSize = PHP_INT_MAX;
     }
     // internal infinity value
     if ($count == -1) {
         $count = PHP_INT_MAX;
     }
     // internal infinity value
     $this->job = $job;
     $this->args = $args;
     $this->curPageResults = NULL;
     $this->curOffset = $offset;
     $this->limOffset = $count == PHP_INT_MAX ? PHP_INT_MAX : $offset + $count;
     $this->pageMaxSize = $pageMaxSize;
     $this->fieldOrderWasReturned = FALSE;
     $this->currentElement = $this->readNextElement();
     $this->atStart = TRUE;
 }
예제 #2
0
 /**
  * Sends an HTTP request to the endpoint at the specified path.
  * 
  * @param string $method        the HTTP method (ex: 'GET' or 'POST').
  * @param string $path          relative or absolute URL path.
  * @param array $requestHeaders (optional) dictionary of header names and 
  *                              values.
  * @param string $requestBody   (optional) content to send in the request.
  * @param array $args           (optional) query parameters, merged with 
  * {<br/>
  *     **namespace**: (optional) namespace to use, or NULL to use
  *                    this context's default namespace.<br/>
  * }
  * @return Splunk_HttpResponse
  * @throws Splunk_IOException
  * @see Splunk_Http::request()
  */
 public function sendRequest($method, $path, $requestHeaders = array(), $requestBody = '', $args = array())
 {
     list($params, $namespace) = Splunk_Util::extractArgument($args, 'namespace', NULL);
     $url = $this->url($path, $namespace);
     $fullUrl = count($params) == 0 ? $url : $url . '?' . http_build_query($params);
     $requestHeaders = array_merge($this->getRequestHeaders(), $requestHeaders);
     return $this->http->request($method, $fullUrl, $requestHeaders, $requestBody);
 }