Skip to content

Commit

Permalink
feat: qlik api updates
Browse files Browse the repository at this point in the history
  • Loading branch information
qlikossbuild authored and github-actions[bot] committed Sep 27, 2024
1 parent d4175dc commit 0309118
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
31 changes: 30 additions & 1 deletion docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const { data: mySpaces } = spaces.getSpaces();
console.log(mySpaces);
```

A host config can also be passed in to every single api request which then will override any default host config previously set.
A host config can also be passed in to every single api request which then will override any default host config previously set. This way multiple host configs can be used if needed.

```ts
import spaces from "@qlik/api/spaces";
Expand All @@ -45,6 +45,35 @@ const { data: mySpaces } = spaces.getSpaces({}, {
console.log(mySpaces);
```

### Binding an instance of `@qlik/api` to a specific host config

As an alternative to the methods above it is also possible to create an instance of `@qlik/api` bound to a specific host config. This allows users to use several host configs in their solutions and easily separate them by having seperate `@qlik/api` instances.

Example:

```ts
import { createQlikApi } from "@qlik-trial/qmfe-api";

const api = createQlikApi({
authType: "apikey"
host: "my-org.region.qlikcloud.com", // a qlikcloud tenant
apiKey: "<api-key>",
});

// "api" now has the full @qlik/api bound to one specific hostconfig
const { data: mySpaces } = api.spaces.getSpaces();

// create another api with a different auth mechanism
const apiToOtherTenant = createQlikApi({
authType: "oauth2"
host: "my-other-tenant.region.qlikcloud.com", // a qlikcloud tenant
clientId: "<client-id>",
});

// "apiToOtherTenant" is now bound to another hostconfig
const { data: myOtherSpaces } = apiToOtherTenant.spaces.getSpaces();
```

## The Auth Module

An auth module in `@qlik/api` is an object with a few implemented methods. When connecting to Qlik Cloud Services (or Qlik Sense Enterprise for Windows) with `@qlik/api` or with `@qlik/embed` libraries an auth module is used for configuring the communication.
Expand Down
12 changes: 10 additions & 2 deletions groups.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ type Group = {
assignedRoles?: AssignedRoles;
/** The timestamp for when the group record was created. */
createdAt: string;
/** Id of user that created role. */
readonly createdBy?: string;
/** A description of a custom group. */
description?: string;
/** The unique identifier for the group */
readonly id: string;
/** The timestamp for when the group record was last updated. */
Expand All @@ -93,15 +97,17 @@ type Group = {
status: "active" | "disabled";
/** The tenant identifier associated with the given group */
tenantId: string;
/** Id of user that last updated this role. */
readonly updatedBy?: string;
};
/**
* A JSON Patch document.
*/
type GroupPatch = {
/** The operation to be performed. Currently "replace" is the only supported operation. */
op: "replace";
/** Attribute name of a field of the Groups entity. */
path: "assignedRoles";
/** Attribute name of a field of the Groups entity. "Name" and "description" is only available for custom groups. */
path: "assignedRoles" | "name" | "description";
/** The roles to assign to the group (limit of 100 roles per group). */
value: AssignedRolesRefIDs | AssignedRolesRefNames;
};
Expand All @@ -112,6 +118,8 @@ type GroupPatchSchema = GroupPatch[];
type GroupPostSchema = {
/** The roles to assign to the group (limit of 100 roles per group). */
assignedRoles?: AssignedRolesRefIDs | AssignedRolesRefNames;
/** The description of the group. */
description?: string;
/** The name of the group (maximum length of 256 characters). */
name: string;
/** The type of group provider. Must be "idp" or "custom". Defaults to "idp" if not provided. */
Expand Down
2 changes: 1 addition & 1 deletion licenses.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type AssignmentsActionsUpdateResponse = {
sourceSubject?: string;
/** Current allotment type. */
sourceType?: string;
/** Response status */
/** HTTP status code indicating the result of the individual assignment operation. A value of 200 represents a successful update, while 201 indicates a new resource was created due to a subject update. Any 400-level status codes indicate an error. */
status: number;
/** Target subject. */
subject?: string;
Expand Down

0 comments on commit 0309118

Please # to comment.