import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { RelationCreate, RelationRead } from '../openapi'; import { BasePermitApi, IPagination } from './base'; export { RelationCreate, RelationRead } from '../openapi'; export interface IListRelations extends IPagination { resourceKey: string; } /** * Interface representing the Resource Relations API. */ export interface IResourceRelationsApi { /** * Retrieves a list of all resource relations that are defined for a given resource. * @param params - pagination and filtering params, @see {@link IListRelations} * @returns A promise that resolves to an array of RelationRead objects representing the relations. * @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: IListRelations): Promise; /** * Retrieves a resource relation based on the resource key and the relation key. * * @param resourceKey - The resource key. * @param relationKey - The relation key. * @returns A promise that resolves to a RelationRead object representing the relation. * @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, relationKey: string): Promise; /** * Retrieves an relation based on the resource key and the relation key. * Alias for the {@link get} method. * * @param resourceKey - The resource key. * @param relationKey - The relation key. * @returns A promise that resolves to a RelationRead object representing the relation. * @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, relationKey: string): Promise; /** * Retrieves an relation based on the resource ID and the relation ID. * Alias for the {@link get} method. * * @param resourceId - The resource ID. * @param relationId - The relation ID. * @returns A promise that resolves to a RelationRead object representing the relation. * @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, relationId: string): Promise; /** * Creates a new resource relation. * * @param resourceKey - The resource key. * @param RelationData - The relation data. * @returns A promise that resolves to a RelationRead object representing the created relation. * @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, RelationData: RelationCreate): Promise; /** * Deletes a relation based on the resource key and relation key. * @param resourceKey - The resource key. * @param relationKey - The relation key. * @returns A promise that resolves when the relation is successfully 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, relationKey: string): Promise; } /** * API client for interacting with the Resource Relations API. */ export declare class ResourceRelationsApi extends BasePermitApi implements IResourceRelationsApi { private relationsApi; /** * Creates an instance of the ResourceRelationsApi. * @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 all resource relations that are defined for a given resource. * @param params - pagination and filtering params, @see {@link IListRelations} * @returns A promise that resolves to an array of RelationRead objects representing the relations. * @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: IListRelations): Promise; /** * Retrieves a resource relation based on the resource key and the relation key. * * @param resourceKey - The resource key. * @param relationKey - The relation key. * @returns A promise that resolves to a RelationRead object representing the relation. * @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, relationKey: string): Promise; /** * Retrieves an relation based on the resource key and the relation key. * Alias for the {@link get} method. * * @param resourceKey - The resource key. * @param relationKey - The relation key. * @returns A promise that resolves to a RelationRead object representing the relation. * @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, relationKey: string): Promise; /** * Retrieves an relation based on the resource ID and the relation ID. * Alias for the {@link get} method. * * @param resourceId - The resource ID. * @param relationId - The relation ID. * @returns A promise that resolves to a RelationRead object representing the relation. * @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, relationId: string): Promise; /** * Creates a new resource relation. * * @param resourceKey - The resource key. * @param RelationData - The relation data. * @returns A promise that resolves to a RelationRead object representing the created relation. * @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, RelationData: RelationCreate): Promise; /** * Deletes a relation based on the resource key and relation key. * @param resourceKey - The resource key. * @param relationKey - The relation key. * @returns A promise that resolves when the relation is successfully 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, relationKey: string): Promise; }