QlikElixir.REST.ReportTemplates (qlik_elixir v0.4.0)

View Source

Qlik Cloud Report Templates REST API client.

Report templates are the stored Excel, Word, PowerPoint or pixel-perfect files that QlikElixir.REST.Reports renders against an app. Unlike the report requests themselves, templates are stored resources: they can be listed, updated and deleted.

A template is created from a file previously uploaded as temporary content, which is why create/2 takes a temporaryContentId rather than a path.

Examples

{:ok, %{"data" => templates}} = ReportTemplates.list(name: "ventas", config: config)
{:ok, template} = ReportTemplates.get(id, config: config)
{:ok, xlsx} = ReportTemplates.download(id, config: config)

API reference: https://qlik.dev/apis/rest/report-templates/

Summary

Functions

Creates a report template from a file held as temporary content.

Deletes a report template.

Downloads the template file.

Gets a report template by ID.

Lists report templates.

Patches a report template with a JSON Patch document (RFC 6902).

Replaces a report template.

Functions

create(params, opts \\ [])

@spec create(
  map(),
  keyword()
) :: {:ok, map()} | {:error, QlikElixir.Error.t()}

Creates a report template from a file held as temporary content.

Parameters

  • :name - Required. 1..255 characters.
  • :temporary_content_id - Required. The uploaded template file.
  • :description - Up to 255 characters.
  • :source_app_id - The app the template reports on.
  • :source_app_action - "validate" (default) or "replace".

Examples

iex> ReportTemplates.create(%{name: "Ventas", temporary_content_id: "653bb4ac..."})
{:ok, %{"id" => "223940f7-...", "name" => "Ventas"}}

delete(template_id, opts \\ [])

@spec delete(
  String.t(),
  keyword()
) :: :ok | {:error, QlikElixir.Error.t()}

Deletes a report template.

download(template_id, opts \\ [])

@spec download(
  String.t(),
  keyword()
) :: {:ok, binary()} | {:error, QlikElixir.Error.t()}

Downloads the template file.

Returns the raw bytes of the stored Office document.

get(template_id, opts \\ [])

@spec get(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, QlikElixir.Error.t()}

Gets a report template by ID.

list(opts \\ [])

@spec list(keyword()) :: {:ok, map()} | {:error, QlikElixir.Error.t()}

Lists report templates.

This endpoint pages by offset, not by cursor: use :skip, not a next token.

Options

  • :limit - Page size, 1..100 (default: 20)
  • :skip - Number of templates to skip (default: 0)
  • :name - Case-insensitive wildcard search on the name
  • :owner_id - Filter by owner
  • :source_app_id - Filter by the app the template was built from
  • :sort - name, createdAt, updatedAt or type, optionally prefixed with +/-; a list is accepted
  • :config - Custom configuration

Examples

iex> QlikElixir.REST.ReportTemplates.list(limit: 50, sort: "-updatedAt")
{:ok, %{"data" => [...]}}

patch(template_id, operations, opts \\ [])

@spec patch(String.t(), [map()], keyword()) :: :ok | {:error, QlikElixir.Error.t()}

Patches a report template with a JSON Patch document (RFC 6902).

Examples

iex> ReportTemplates.patch(id, [%{op: "replace", path: "/name", value: "Ventas 2026"}])
:ok

update(template_id, params, opts \\ [])

@spec update(String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, QlikElixir.Error.t()}

Replaces a report template.

Takes the same fields as create/2 except :source_app_id, which cannot be changed once the template exists.