import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { ResourceCreate, ResourceRead, ResourceReplace, ResourceUpdate } from '../openapi'; import { BasePermitApi, IPagination } from './base'; export { ResourceCreate, ResourceRead, ResourceReplace, ResourceUpdate } from '../openapi'; export interface IListResourceUsers extends IPagination { resourceKey: string; } export interface IResourcesApi { /** * Retrieves a list of resources. * * @param pagination The pagination options, @see {@link IPagination} * @returns A promise that resolves to an array of resources. * @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 resource by its key. * * @param resourceKey The key of the resource. * @returns A promise that resolves to the resource. * @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): Promise; /** * Retrieves a resource by its key. * Alias for the {@link get} method. * * @param resourceKey The key of the resource. * @returns A promise that resolves to the resource. * @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): Promise; /** * Retrieves a resource by its ID. * Alias for the {@link get} method. * * @param resourceId The ID of the resource. * @returns A promise that resolves to the resource. * @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): Promise; /** * Creates a new resource. * * @param resourceData The data for the new resource. * @returns A promise that resolves to the created resource. * @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(resourceData: ResourceCreate): Promise; /** * Creates a resource if such a resource does not exists, otherwise completely replaces the resource configuration. * * @param resourceKey The key of the resource. * @param resourceData The updated data for the resource. * @returns A promise that resolves to the updated resource. * @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. */ replace(resourceKey: string, resourceData: ResourceReplace): Promise; /** * Updates a resource. * * @param resourceKey The key of the resource. * @param resourceData The updated data for the resource. * @returns A promise that resolves to the updated resource. * @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, resourceData: ResourceUpdate): Promise; /** * Deletes a resource. * * @param resourceKey The key of the resource to delete. * @returns A promise that resolves when the resource 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): Promise; } /** * The ResourcesApi class provides methods for interacting with Permit Resources. */ export declare class ResourcesApi extends BasePermitApi implements IResourcesApi { private resources; /** * Creates an instance of the ResourcesApi. * @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 resources. * * @param pagination The pagination options, @see {@link IPagination} * @returns A promise that resolves to an array of resources. * @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 resource by its key. * * @param resourceKey The key of the resource. * @returns A promise that resolves to the resource. * @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): Promise; /** * Retrieves a resource by its key. * Alias for the {@link get} method. * * @param resourceKey The key of the resource. * @returns A promise that resolves to the resource. * @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): Promise; /** * Retrieves a resource by its ID. * Alias for the {@link get} method. * * @param resourceId The ID of the resource. * @returns A promise that resolves to the resource. * @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): Promise; /** * Creates a new resource. * * @param resourceData The data for the new resource. * @returns A promise that resolves to the created resource. * @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(resourceData: ResourceCreate): Promise; /** * Creates a resource if such a resource does not exists, otherwise completely replaces the resource configuration. * * @param resourceKey The key of the resource. * @param resourceData The updated data for the resource. * @returns A promise that resolves to the updated resource. * @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. */ replace(resourceKey: string, resourceData: ResourceReplace): Promise; /** * Updates a resource. * * @param resourceKey The key of the resource. * @param resourceData The updated data for the resource. * @returns A promise that resolves to the updated resource. * @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, resourceData: ResourceUpdate): Promise; /** * Deletes a resource. * * @param resourceKey The key of the resource to delete. * @returns A promise that resolves when the resource 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): Promise; }