import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { DerivedRoleRuleCreate, DerivedRoleRuleDelete, DerivedRoleRuleRead, PermitBackendSchemasSchemaDerivedRoleDerivedRoleSettings, ResourceRoleCreate, ResourceRoleRead, ResourceRoleUpdate } from '../openapi'; import { BasePermitApi, IPagination } from './base'; export { ResourceRoleCreate, ResourceRoleRead, ResourceRoleUpdate } from '../openapi'; export interface IListResourceRoles extends IPagination { resourceKey: string; } export interface IResourceRolesApi { /** * Retrieves a list of resource roles. * * @param params - pagination and filtering params, @see {@link IListResourceRoles} * @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(params: IListResourceRoles): Promise; /** * Retrieves a resource role by its key. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleKey: string): Promise; /** * Retrieves a resource role by its key. * Alias for the {@link get} method. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleKey: string): Promise; /** * Retrieves a resource role by its ID. * Alias for the {@link get} method. * * @param resourceId The ID of the resource. * @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(resourceId: string, roleId: string): Promise; /** * Creates a new role. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleData: ResourceRoleCreate): Promise; /** * Updates a resource role. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleKey: string, roleData: ResourceRoleUpdate): Promise; /** * Deletes a resource role. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleKey: string): Promise; /** * Assigns permissions to a resource role. * * @param resourceKey The key of the resource. * @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 ResourceRoleRead 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(resourceKey: string, roleKey: string, permissions: string[]): Promise; /** * Removes permissions from a resource role. * * @param resourceKey The key of the resource. * @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 ResourceRoleRead 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(resourceKey: string, roleKey: string, permissions: string[]): Promise; /** * Creates a new role derivation. * * @param resourceKey The key of the resource. * @param roleKey - The key of the role. * @param derivationData - An object of the derivation data. * @returns A promise that resolves to a DerivedRoleRuleRead object representing the updated derived 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. */ createRoleDerivation(resourceKey: string, roleKey: string, derivationData: DerivedRoleRuleCreate): Promise; /** * Delete a role derivation. * * @param resourceKey The key of the resource. * @param roleKey - The key of the role. * @param derivationRule - An object of the derivation role. * @returns void. * @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. */ deleteRoleDerivation(resourceKey: string, roleKey: string, derivationRule: DerivedRoleRuleDelete): Promise; /** * update conditions to a role derivation. * * @param resourceKey The key of the resource. * @param roleKey - The key of the role. * @param conditions - An array of conditions to be assigned to the role. * @returns A promise that resolves to a PermitBackendSchemasSchemaDerivedRoleDerivedRoleSettings object representing the derived role settings. * @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. */ updateRoleDerivationConditions(resourceKey: string, roleKey: string, conditions: PermitBackendSchemasSchemaDerivedRoleDerivedRoleSettings): Promise; } /** * The ResourceRolesApi class provides methods for interacting with Permit Roles. */ export declare class ResourceRolesApi extends BasePermitApi implements IResourceRolesApi { private resourceRoles; private roleDerivations; /** * Creates an instance of the ResourceRolesApi. * @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 resource roles. * * @param params - pagination and filtering params, @see {@link IListResourceRoles} * @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(params: IListResourceRoles): Promise; /** * Retrieves a resource role by its key. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleKey: string): Promise; /** * Retrieves a resource role by its key. * Alias for the {@link get} method. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleKey: string): Promise; /** * Retrieves a resource role by its ID. * Alias for the {@link get} method. * * @param resourceId The ID of the resource. * @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(resourceId: string, roleId: string): Promise; /** * Creates a new role. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleData: ResourceRoleCreate): Promise; /** * Updates a resource role. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleKey: string, roleData: ResourceRoleUpdate): Promise; /** * Deletes a resource role. * * @param resourceKey The key of the resource. * @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(resourceKey: string, roleKey: string): Promise; /** * Assigns permissions to a resource role. * * @param resourceKey The key of the resource. * @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 ResourceRoleRead 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(resourceKey: string, roleKey: string, permissions: string[]): Promise; /** * Removes permissions from a resource role. * * @param resourceKey The key of the resource. * @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 ResourceRoleRead 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(resourceKey: string, roleKey: string, permissions: string[]): Promise; /** * Create a conditional derivation from another role. * The derivation states that users with some other role on a related object will implicitly also be granted this role. * * @param resourceKey - The key of the resource the role belongs to. * @param roleKey - The key of the role. * @param derivationRule - A rule when to derived this role from another related role. * @returns A DerivedRoleRuleRead object representing the newly created role derivation. * @throws PermitApiError - If the API returns an error HTTP status code. * @throws PermitContextError - If the configured ApiContext does not match the required endpoint context. */ createRoleDerivation(resourceKey: string, roleKey: string, derivationRule: DerivedRoleRuleCreate): Promise; /** * Delete a role derivation. * * @param resourceKey - The key of the resource the role belongs to. * @param roleKey - The key of the role. * @param derivationRule - The details of the derivation rule to delete. * @throws PermitApiError - If the API returns an error HTTP status code. * @throws PermitContextError - If the configured ApiContext does not match the required endpoint context. */ deleteRoleDerivation(resourceKey: string, roleKey: string, derivationRule: DerivedRoleRuleDelete): Promise; /** * Update the optional (ABAC) conditions when to derive this role from other roles. * * @param resourceKey - The key of the resource the role belongs to. * @param roleKey - The key of the role. * @param conditions - The conditions object. * @returns The updated PermitBackendSchemasSchemaDerivedRoleDerivedRoleSettings. * @throws PermitApiError - If the API returns an error HTTP status code. * @throws PermitContextError - If the configured ApiContext does not match the required endpoint context. */ updateRoleDerivationConditions(resourceKey: string, roleKey: string, conditions: PermitBackendSchemasSchemaDerivedRoleDerivedRoleSettings): Promise; }