import { GraphqlClient } from './../common/GraphqlClient'; import { ManagementTokenProvider } from './ManagementTokenProvider'; import { ManagementClientOptions } from './types'; import { CommonMessage, PaginatedAuthorizedResources, PaginatedPolicyAssignments, PaginatedRoles, PaginatedUsers, ResourceType, Role } from '../../types/graphql.v2'; import { DeepPartial, KeyValuePair } from '../../types/index'; /** * @class RolesManagementClient manage roles * @description This module is used to manage Approw roles, and can perform operations such as adding, deleting, modifying, and checking roles, adding/deleting users, and adding/deleting roles. * * @example * * Please use the module in the following way instead of initializing the module directly: * \`\`\`javascript * import { ManagementClient } from "approw-js-sdk" * const managementClient = new ManagementClient({ * userPoolId: "YOUR_USERPOOL_ID", * secret: "YOUR_USERPOOL_SECRET", * }) * managementClient.roles.list // Get role list * managementClient.roles.create // Create users * managementClient.roles.listUsers // Get the list of role users * \`\`\` * * @name RolesManagementClient */ export declare class RolesManagementClient { options: ManagementClientOptions; graphqlClient: GraphqlClient; tokenProvider: ManagementTokenProvider; constructor(options: ManagementClientOptions, graphqlClient: GraphqlClient, tokenProvider: ManagementTokenProvider); /** * @name create * @name_zh Create roles * @description Create roles * * @param {string} code Character unique identifier * @param {string} [options.description] 描述 * @param {string} [options.namespace] 该角色所在的 namespace,默认为 default * * @example * managementClient.roles.create('rolea', 'RoleA') * * @returns {Promise>} * @memberof RolesManagementClient */ create(code: string, description?: string, namespace?: string): Promise>; /** * @name delete * @name_zh 删除角色 * @description 删除角色 * * @param {string} code Character unique identifier * @param {string} [namespace] Namespace code to which the role belongs, the default value is'default' * * @example * managementClient.roles.delete('rolea') * * @returns {Promise} * @memberof RolesManagementClient */ delete(code: string, namespace?: string): Promise; /** * @name deleteMany * @name_zh Delete roles in bulk * @description Delete roles in bulk * * @param {string[]} codeList Character unique identifier list * @param {string} [namespace] Namespace to which the role belongs, the default value is'default' * * @example * managementClient.roles.delete(['rolea']) * * @returns {Promise} * @memberof RolesManagementClient */ deleteMany(codeList: string[], namespace?: string): Promise; /** * @name update * @name_zh Update roles * @description Update roles * * @param {string} code Character unique identifier * @param {Object} options * @param {string} options.description Description * @param {string} options.newCode new unique identifier * @param {string} options.namespace Namespace to which the role belongs, the default value is'default' * * @example * managementClient.roles.update('rolea', {newCode: 'newcode'}) * * * @returns {Promise>} * @memberof RolesManagementClient */ update(code: string, options: { description?: string; newCode?: string; namespace?: string; }): Promise>; /** * @deprecated Obsolete, not recommended */ detail(code: string, namespace?: string): Promise>; /** * * @name findByCode * @name_zh Find roles' information * @description Find roles' information * * @param {string} code Character unique identifier * @param {string} [namespace] Namespace to which the role belongs, the default value is'default' * * @example` * managementClient.roles.detail('manager') * * @returns {Promise>} role detail * @memberof RolesManagementClient */ findByCode(code: string, namespace?: string): Promise>; /** * @name list * @name_zh Get a list of roles * @description Get a list of roles * * @param {Object} [options] * @param {number} [options.page=1] Number of pages * @param {number} [options.limit=10] Number per page * @param {string} [options.namespace] Namespace to which the role belongs, the default value is'default' * * @example * managementClient.roles.list(2, 10) * * @returns {Promise>} * @memberof RolesManagementClient */ list(options?: { page?: number; limit?: number; namespace?: string; }): Promise>; /** * @name listUsers * @name_zh Get the list of role users * @description Get the list of role users * * @param {string} code Character unique identifier * * @param {string} [namespace] Namespace to which the role belongs, the default value is'default' * * @example * managementClient.roles.listUsers(code) * * @returns {Promise>} * @memberof RolesManagementClient */ listUsers(code: string, namespace?: string): Promise>; /** * @name addUsers * @name_zh Add users * @description Add users * * @param {string} code Character unique identifier * @param {string[]} userIds user ID list * @param {string} [namespace] Namespace to which the role belongs, the default value is'default' * * @example * managementClient.roles.addUsers(code, ['USERID1', 'USERID2']) * * @returns {Promise} * @memberof RolesManagementClient */ addUsers(code: string, userIds: string[], namespace?: string): Promise; /** * @name removeUsers * @name_zh Remove users * * @description Remove users * * @param {string} code Character unique identifier * @param {string[]} userIds user ID list * @param {string} [namespace] Namespace to which the role belongs, the default value is'default' * * @example * managementClient.roles.removeUsers(code, ['USERID1', 'USERID2']) * * @returns {Promise} * @memberof RolesManagementClient */ removeUsers(code: string, userIds: string[], namespace?: string): Promise; /** * @name listPolicies * @name_zh Get a list of role policies * * @description Get a list of role policies * * @param {string} code Character unique identifier * @param {number} [page=1] Number of pages * @param {number} [limit=10] Number per page * @example * managementClient.roles.listPolicies('codea', 1, 10) * * @returns {Promise} * @memberof RolesManagementClient */ listPolicies(code: string, page?: number, limit?: number): Promise; /** * @name addPolicies * @name_zh Authorize strategy * * @description Authorize strategy to users * * @param {string} code Character unique identifier * @param {string[]} policies Strategy list * @example * managementClient.roles.addPolicies('rolea', ['PolicyA', 'PolicyB']) * * @returns {Promise} * @memberof RolesManagementClient */ addPolicies(code: string, policies: string[]): Promise; /** * @name removePolicies * @name_zh Remove policies * * @description Remove policies * * @param {string} code Character unique identifier * @param {string[]} policies Policies list * @example * managementClient.roles.removePolicies('rolea', ['PolicyA', 'PolicyB']) * * @returns {Promise} * @memberof RolesManagementClient */ removePolicies(code: string, policies: string[]): Promise; /** * @description Get all resources authorized by the role * * @param code: role code * @param namespace: role authrization group namespace code * @param options.resourceType resource type */ listAuthorizedResources(code: string, namespace: string, options?: { resourceType?: ResourceType; }): Promise; /** * Get a list of role extension fields * @param roleId role ID * @returns Promise<{ [key: string]: any }> */ getUdfValue(roleId: string): Promise<{ [key: string]: any; }>; /** * Get an extension field of a role * @param roleId user ID * @param udfKey extension field Key * @returns Promise<{ [key: string]: any }> */ getSpecificUdfValue(roleId: string, udfKey: string): Promise<{ [key: string]: any; }>; /** * Get a list of multiple role extension fields * @param roleId role ID list * @returns Promise<{ [x: string]: KeyValuePair }> */ getUdfValueBatch(roleIds: string[]): Promise<{ [x: string]: KeyValuePair; }>; /** * Set a list of role extension fields * @param roleId role ID list * @param data extension fields */ setUdfValue(roleId: string, data: KeyValuePair): Promise; /** * Set multiple role extension field lists * @param input.roleId role ID list * @param input.data extension field */ setUdfValueBatch(input: { roleId: string; data: KeyValuePair; }[]): Promise; /** * Delete user's extension field * @param input.roleId role ID list * @param input.key name of extension field */ removeUdfValue(roleId: string, key: string): Promise; }