import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { BulkRoleAssignmentReport, BulkRoleUnAssignmentReport, RoleAssignmentCreate, RoleAssignmentRead, RoleAssignmentRemove } from '../openapi'; import { BasePermitApi, IPagination } from './base'; export { BulkRoleAssignmentReport, BulkRoleUnAssignmentReport, RoleAssignmentCreate, RoleAssignmentRead, RoleAssignmentRemove, } from '../openapi'; /** * Represents the parameters for listing role assignments. */ export interface IListRoleAssignments extends IPagination { /** * optional user filter, will only return role assignments granted to this user. */ user?: string; /** * optional role filter, will only return role assignments granting this role. */ role?: string; /** * optional tenant filter, will only return role assignments granted in that tenant. */ tenant?: string; /** * optional resource instance filter, will only return (resource) role assignments granted on that resource instance. */ resourceInstance?: string; } /** * API client for managing role assignments. */ export interface IRoleAssignmentsApi { /** * Retrieves a list of role assignments based on the specified filters. * * @param params - The filters and pagination options for listing role assignments. * @returns A promise that resolves with an array of role assignments. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ list(params: IListRoleAssignments): Promise; /** * Assigns a role to a user in the scope of a given tenant. * * @param assignment - The role assignment details. * @returns A promise that resolves with the assigned role. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ assign(assignment: RoleAssignmentCreate): Promise; /** * Unassigns a role from a user in the scope of a given tenant. * * @param unassignment - The role unassignment details. * @returns A promise that resolves when the role is successfully unassigned. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ unassign(unassignment: RoleAssignmentRemove): Promise; /** * Assigns multiple roles in bulk using the provided role assignments data. * Each role assignment is a tuple of (user, role, tenant). * * @param assignments - The role assignments to be performed in bulk. * @returns A promise that resolves with the bulk assignment report. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ bulkAssign(assignments: RoleAssignmentCreate[]): Promise; /** * Removes multiple role assignments in bulk using the provided unassignment data. * Each role to unassign is a tuple of (user, role, tenant). * * @param unassignments - The role unassignments to be performed in bulk. * @returns A promise that resolves with the bulk unassignment report. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ bulkUnassign(unassignments: RoleAssignmentRemove[]): Promise; } /** * The RoleAssignmentsApi class provides methods for interacting with Role Assignments. */ export declare class RoleAssignmentsApi extends BasePermitApi implements IRoleAssignmentsApi { private roleAssignments; /** * Creates an instance of the RoleAssignmentsApi. * @param config - The configuration object for the Permit SDK. * @param logger - The logger instance for logging. */ constructor(config: IPermitConfig, logger: Logger); /** * Retrieves a list of role assignments based on the specified filters. * * @param params - The filters and pagination options for listing role assignments. * @returns A promise that resolves with an array of role assignments. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ list(params: IListRoleAssignments): Promise; /** * Assigns a role to a user in the scope of a given tenant. * * @param assignment - The role assignment details. * @returns A promise that resolves with the assigned role. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ assign(assignment: RoleAssignmentCreate): Promise; /** * Unassigns a role from a user in the scope of a given tenant. * * @param unassignment - The role unassignment details. * @returns A promise that resolves when the role is successfully unassigned. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ unassign(unassignment: RoleAssignmentRemove): Promise; /** * Assigns multiple roles in bulk using the provided role assignments data. * Each role assignment is a tuple of (user, role, tenant). * * @param assignments - The role assignments to be performed in bulk. * @returns A promise that resolves with the bulk assignment report. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ bulkAssign(assignments: RoleAssignmentCreate[]): Promise; /** * Removes multiple role assignments in bulk using the provided unassignment data. * Each role to unassign is a tuple of (user, role, tenant). * * @param unassignments - The role unassignments to be performed in bulk. * @returns A promise that resolves with the bulk unassignment report. * @throws {@link PermitApiError} If the API returns an error HTTP status code. * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context. */ bulkUnassign(unassignments: RoleAssignmentRemove[]): Promise; }