QlikElixir.REST.APIKeys (qlik_elixir v0.3.5)

View Source

REST API client for Qlik Cloud API Keys.

Provides functions to manage API keys for programmatic access to Qlik Cloud.

Examples

# List all API keys
{:ok, %{"data" => keys}} = APIKeys.list(config: config)

# Create a new API key
{:ok, key} = APIKeys.create(%{description: "My API Key"}, config: config)
# key["token"] contains the generated JWT token (only shown once)

# Delete an API key
:ok = APIKeys.delete("key-123", config: config)

# Get tenant configuration (requires tenant ID from Tenants.me)
{:ok, tenant} = Tenants.me(config: config)
{:ok, config} = APIKeys.get_config(tenant["id"], config: config)

Summary

Functions

Creates a new API key.

Deletes an API key.

Gets an API key by ID.

Gets the API keys configuration for a tenant.

Lists all API keys.

Updates the API keys configuration for a tenant.

Functions

create(params, opts \\ [])

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

Creates a new API key.

Parameters

  • params - Map with key details:
    • :description - Required. Description of the key.
    • :expiry - Optional. Expiration timestamp (ISO 8601).
    • :sub - Optional. Subject to generate key for (admin only).

Returns

The response includes a token field containing the JWT token. This token is only shown once and cannot be retrieved again.

delete(key_id, opts \\ [])

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

Deletes an API key.

get(key_id, opts \\ [])

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

Gets an API key by ID.

get_config(tenant_id, opts \\ [])

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

Gets the API keys configuration for a tenant.

Parameters

  • tenant_id - The tenant ID. Use Tenants.me/1 to get the current tenant ID.

Examples

{:ok, tenant} = Tenants.me(config: config)
{:ok, config} = APIKeys.get_config(tenant["id"], config: config)

list(opts \\ [])

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

Lists all API keys.

Options

  • :config - Required. The configuration struct.
  • :limit - Maximum number of results per page.
  • :next - Cursor for pagination.
  • :owner_id - Filter by owner ID.
  • :status - Filter by status ("active", "expired", "revoked").
  • :sort - Sort field and direction (e.g., "-createdAt").

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

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

Updates an API key.

Parameters

  • key_id - The API key ID.
  • params - Map with fields to update:
    • :description - New description.

update_config(tenant_id, params, opts \\ [])

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

Updates the API keys configuration for a tenant.

Parameters

  • tenant_id - The tenant ID.
  • params - Map with configuration fields:
    • :api_keys_enabled - Enable/disable API keys.
    • :max_api_key_expiry - Maximum expiry duration.
    • :max_keys_per_user - Maximum keys per user.