private function makeUrl($params = null) { $url = $this->restUrl2 . '/jobs'; if (!empty($params)) { $url .= '?' . Util::query_suffix($params); } return $url; }
/** * Update or Create new Report Options. * * The argument $controlOptions must be an array in the following form: * * array('key' => array('value1', 'value2'), 'key2' => array('value1-2', 'value2-2')) * * Note that even when there is only one value, it must be encapsulated within an array. * * @param string $uri * @param array $controlOptions * @param string $label * @param boolean $overwrite * @throws \Jaspersoft\Exception\RESTRequestException * @return \Jaspersoft\Dto\Options\ReportOptions */ public function updateReportOptions($uri, $controlOptions, $label, $overwrite) { $url = $this->restUrl2 . '/reports' . $uri . '/options'; $url .= '?' . Util::query_suffix(array('label' => utf8_encode($label), 'overwrite' => $overwrite)); $body = json_encode($controlOptions); $data = $this->service->prepAndSend($url, array(200), 'POST', $body, true, 'application/json', 'application/json'); $data_array = json_decode($data, true); return new ReportOptions($data_array['uri'], $data_array['id'], $data_array['label']); }
/** * Obtain the permissions of a resource on the server * * @param string $uri * @param boolean $effectivePermissions Show all permissions affected by URI? * @param string $recipientType Type of permission (e.g: user/role) * @param string $recipientId the id of the recipient (requires recipientType) * @param boolean $resolveAll Resolve for all matched recipients? * @return array A resultant set of RepositoryPermission */ public function searchRepositoryPermissions($uri, $effectivePermissions = null, $recipientType = null, $recipientId = null, $resolveAll = null) { $url = $this->restUrl2 . '/permissions' . $uri; $url .= '?' . Util::query_suffix(array("effectivePermissions" => $effectivePermissions, "recipientType" => $recipientType, "recipientId" => $recipientId, "resolveAll" => $resolveAll)); $data = $this->service->prepAndSend($url, array(200, 204), 'GET', null, true, 'application/json', 'application/json'); if (empty($data)) { return array(); } return self::batchDataToArray($data); }
/** * This function runs and retrieves the binary data of a report. * * @param string $uri URI for the report you wish to run * @param string $format The format you wish to receive the report in (default: pdf) * @param string $pages Request a specific page, or range of pages. Separate multiple pages or ranges by commas. * (e.g: "1,4-22,42,55-100") * @param string $attachmentsPrefix a URI to prefix all image attachment sources with * (must include trailing slash if needed) * @param array $inputControls associative array of key => value for any input controls * @param boolean $interactive Should reports using Highcharts be interactive? * @param boolean $onePagePerSheet Produce paginated XLS or XLSX? * @param boolean $freshData * @param boolean $saveDataSnapshot * @param string $transformerKey For use when running a report as a JasperPrint. Specifies print element transformers * @return string Binary data of report */ public function runReport($uri, $format = 'pdf', $pages = null, $attachmentsPrefix = null, $inputControls = null, $interactive = true, $onePagePerSheet = false, $freshData = true, $saveDataSnapshot = false, $transformerKey = null) { $url = $this->restUrl2 . '/reports' . $uri . '.' . $format; if (empty($inputControls)) { $url .= '?' . Util::query_suffix(compact("pages", "attachmentsPrefix", "interactive", "onePagePerSheet", "freshData", "saveDataSnapshot", "transformerKey")); } else { $url .= '?' . Util::query_suffix(array_merge(compact("pages", "attachmentsPrefix", "interactive", "onePagePerSheet", "freshData", "saveDataSnapshot", "transformerKey"), $inputControls)); } $binary = $this->service->prepAndSend($url, array(200), 'GET', null, true); return $binary; }
private function makeUrl($organization = null, $params = null) { $url = $this->restUrl2 . '/organizations'; if (!empty($organization)) { $url .= '/' . $organization; return $url; } if (!empty($params)) { $url .= '?' . Util::query_suffix($params); } return $url; }
/** * Obtain a set of ResourceThumbnail objects representing the thumbnails for several reports, * these ResourceThumbnail objects will contain the image data as a Base64 String only * * @param array $uris * @param bool $defaultAllowed * @return array */ public function getResourceThumbnails(array $uris, $defaultAllowed = false) { $result = array(); $url = self::makeUrl(); $postString = Util::query_suffix(array("uri" => $uris, "defaultAllowed" => $defaultAllowed)); $response = $this->service->makeRequest($url, array(200), 'POST', $postString, true, 'application/x-www-form-urlencoded'); $data = json_decode($response['body']); if (isset($data)) { foreach ($data as $thumbnail) { $result[] = ResourceThumbnail::createFromJSON($thumbnail); } } return $result; }
private function makeUrl($organization = null, $roleName = null, $params = null) { if (!empty($organization)) { $url = $this->restUrl2 . '/organizations/' . $organization . '/roles'; } else { $url = $this->restUrl2 . '/roles'; } if (!empty($roleName)) { $url .= '/' . $roleName; } else { if (!empty($params)) { $url .= '?' . Util::query_suffix($params); } } return $url; }
/** * Remove all attributes, or specific attributes from an organization. * * @param Organization $organization * @param array $attributes * @return bool */ public function deleteAttributes(Organization $organization, $attributes = null) { $url = self::makeAttributeUrl($organization->id); if (!empty($attributes)) { $url .= '?' . Util::query_suffix(array('name' => $attributes)); } return $this->service->prepAndSend($url, array(204), 'DELETE', null, false); }
public function toQueryParams() { return Util::query_suffix($this->toArray()); }
/** * Remove resource(s) from the repository * * @param string|array $uris URI(s) of resources to remove */ public function deleteResources($uris) { if (is_array($uris)) { $url = self::makeUrl() . '?' . Util::query_suffix(array("resourceUri" => $uris)); } else { $url = self::makeUrl(null, $uris); } $this->service->prepAndSend($url, array(204), 'DELETE', null, false); }
/** * Remove all attributes, or specific attributes from a user. * * @param \Jaspersoft\Dto\User\User $user * @param array $attributes * @return bool */ public function deleteAttributes(User $user, $attributes = null) { $url = self::makeAttributeUrl($user->username, $user->tenantId); if (!empty($attributes)) { $url .= '?' . Util::query_suffix(array('name' => $attributes)); } return $this->service->prepAndSend($url, array(204), 'DELETE', null, false); }
/** * Create or Update a calendar * * @param BaseCalendar $calendar A DTO representing the new or altered calendar * @param string $calendarName Name of the calendar to create or update * @param bool $replace Should an existing calendar of the same name be overwritten? * @param bool $updateTriggers Should an existing jobs using this calendar adhere to the changes made? */ public function createOrUpdateCalendar(BaseCalendar $calendar, $calendarName, $replace = false, $updateTriggers = false) { $url = $this->service_url . '/jobs/calendars/' . rawurlencode($calendarName) . '?' . Util::query_suffix(array("replace" => $replace, "updateTriggers" => $updateTriggers)); $body = $calendar->toJSON(); $this->service->prepAndSend($url, array(200), 'PUT', $body, false); }
/** * Re-run the report using new report parameters * * @param string $executionId * @param array<Jaspersoft\Dto\ReportExecution\Parameter> $newParameters An array of new reportParameters * @param bool $freshData Should fresh data be fetched? (Default: true) * @throws DtoException */ public function updateReportExecutionParameters($executionId, array $newParameters, $freshData = true) { $url = $this->makeUrl($executionId, false, true); if (is_bool($freshData)) { $url .= '?' . Util::query_suffix(array("freshData" => $freshData)); } $parameters = array(); foreach ($newParameters as $p) { if ($p instanceof Parameter) { $parameters[] = $p->jsonSerialize(); } else { throw new DtoException(get_called_class() . ": The parameter field must contain\n only Jaspersoft\\DTO\\ReportExecution\\Parameter item(s)"); } } $this->service->prepAndSend($url, array(204), 'POST', json_encode($parameters), true); }
/** * Begin an import task * * @param \Jaspersoft\Dto\Importexport\ImportTask $it * @param string $file_data Raw binary data of import zip * @return \Jaspersoft\Dto\ImportExport\TaskState */ public function startImportTask(ImportTask $it, $file_data) { $url = $this->restUrl2 . '/import' . '?' . Util::query_suffix($it->queryData()); $data = $this->service->prepAndSend($url, array(200, 201), 'POST', $file_data, true, 'application/zip', 'application/json'); return TaskState::createFromJSON(json_decode($data)); }