From 0309118a746dd71696a6dd9524d679d4922ba923 Mon Sep 17 00:00:00 2001 From: qlikossbuild Date: Fri, 27 Sep 2024 13:55:38 +0000 Subject: [PATCH] feat: qlik api updates --- docs/authentication.md | 31 ++++++++++++++++++++++++++++++- groups.d.ts | 12 ++++++++++-- licenses.d.ts | 2 +- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/docs/authentication.md b/docs/authentication.md index 78eb432..32a9885 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -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"; @@ -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" 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: "", +}); + +// "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. diff --git a/groups.d.ts b/groups.d.ts index 6feb87b..08aacb7 100644 --- a/groups.d.ts +++ b/groups.d.ts @@ -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. */ @@ -93,6 +97,8 @@ 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. @@ -100,8 +106,8 @@ type Group = { 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; }; @@ -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. */ diff --git a/licenses.d.ts b/licenses.d.ts index 10f05ac..bee2623 100644 --- a/licenses.d.ts +++ b/licenses.d.ts @@ -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;