import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { RoleCreate, RoleRead, RoleUpdate } from '../openapi'; import { BasePermitApi, IPagination } from './base'; export { RoleCreate, RoleRead, RoleUpdate } from '../openapi'; export interface IRolesApi { /** * Retrieves a list of roles. * * @param pagination The pagination options, @see {@link IPagination} * @returns A promise that resolves to an array of roles. * @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(pagination?: IPagination): Promise; /** * Retrieves a role by its key. * * @param roleKey The key of the role. * @returns A promise that resolves to the 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. */ get(roleKey: string): Promise; /** * Retrieves a role by its key. * Alias for the {@link get} method. * * @param roleKey The key of the role. * @returns A promise that resolves to the 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. */ getByKey(roleKey: string): Promise; /** * Retrieves a role by its ID. * Alias for the {@link get} method. * * @param roleId The ID of the role. * @returns A promise that resolves to the 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. */ getById(roleId: string): Promise; /** * Creates a new role. * * @param roleData The data for the new role. * @returns A promise that resolves to the created 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. */ create(roleData: RoleCreate): Promise; /** * Updates a role. * * @param roleKey The key of the role. * @param roleData The updated data for the role. * @returns A promise that resolves to the updated 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. */ update(roleKey: string, roleData: RoleUpdate): Promise; /** * Deletes a role. * * @param roleKey The key of the role to delete. * @returns A promise that resolves when the role is deleted. * @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. */ delete(roleKey: string): Promise; /** * Assigns permissions to a role. * @param roleKey - The key of the role. * @param permissions - An array of permission keys () to be assigned to the role. * @returns A promise that resolves to a RoleRead object representing the updated 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. */ assignPermissions(roleKey: string, permissions: string[]): Promise; /** * Removes permissions from a role. * @param roleKey - The key of the role. * @param permissions - An array of permission keys () to be removed from the role. * @returns A promise that resolves to a RoleRead object representing the updated 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. */ removePermissions(roleKey: string, permissions: string[]): Promise; } /** * The RolesApi class provides methods for interacting with Permit Roles. */ export declare class RolesApi extends BasePermitApi implements IRolesApi { private roles; /** * Creates an instance of the RolesApi. * @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 roles. * * @param pagination The pagination options, @see {@link IPagination} * @returns A promise that resolves to an array of roles. * @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(pagination?: IPagination): Promise; /** * Retrieves a role by its key. * * @param roleKey The key of the role. * @returns A promise that resolves to the 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. */ get(roleKey: string): Promise; /** * Retrieves a role by its key. * Alias for the {@link get} method. * * @param roleKey The key of the role. * @returns A promise that resolves to the 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. */ getByKey(roleKey: string): Promise; /** * Retrieves a role by its ID. * Alias for the {@link get} method. * * @param roleId The ID of the role. * @returns A promise that resolves to the 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. */ getById(roleId: string): Promise; /** * Creates a new role. * * @param roleData The data for the new role. * @returns A promise that resolves to the created 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. */ create(roleData: RoleCreate): Promise; /** * Updates a role. * * @param roleKey The key of the role. * @param roleData The updated data for the role. * @returns A promise that resolves to the updated 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. */ update(roleKey: string, roleData: RoleUpdate): Promise; /** * Deletes a role. * * @param roleKey The key of the role to delete. * @returns A promise that resolves when the role is deleted. * @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. */ delete(roleKey: string): Promise; /** * Assigns permissions to a role. * @param roleKey - The key of the role. * @param permissions - An array of permission keys () to be assigned to the role. * @returns A promise that resolves to a RoleRead object representing the updated 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. */ assignPermissions(roleKey: string, permissions: string[]): Promise; /** * Removes permissions from a role. * @param roleKey - The key of the role. * @param permissions - An array of permission keys () to be removed from the role. * @returns A promise that resolves to a RoleRead object representing the updated 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. */ removePermissions(roleKey: string, permissions: string[]): Promise; }