import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { PaginatedResultUserRead, TenantCreate, TenantRead, TenantUpdate } from '../openapi'; import { BasePermitApi, IPagination } from './base'; export { PaginatedResultUserRead, TenantCreate, TenantRead, TenantUpdate } from '../openapi'; export interface IListTenantUsers extends IPagination { tenantKey: string; } export interface ITenantsApi { /** * Retrieves a list of tenants. * * @param pagination The pagination options, @see {@link IPagination} * @returns A promise that resolves to an array of tenants. * @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 list of users for a given tenant. * * @param params - pagination and filtering params. * @returns A promise that resolves to a PaginatedResultUserRead object containing the list of tenant users. * @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. */ listTenantUsers(params: IListTenantUsers): Promise; /** * Retrieves a tenant by its key. * * @param tenantKey The key of the tenant. * @returns A promise that resolves to the tenant. * @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(tenantKey: string): Promise; /** * Retrieves a tenant by its key. * Alias for the {@link get} method. * * @param tenantKey The key of the tenant. * @returns A promise that resolves to the tenant. * @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(tenantKey: string): Promise; /** * Retrieves a tenant by its ID. * Alias for the {@link get} method. * * @param tenantId The ID of the tenant. * @returns A promise that resolves to the tenant. * @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(tenantId: string): Promise; /** * Creates a new tenant. * * @param tenantData The data for the new tenant. * @returns A promise that resolves to the created tenant. * @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(tenantData: TenantCreate): Promise; /** * Updates a tenant. * * @param tenantKey The key of the tenant. * @param tenantData The updated data for the tenant. * @returns A promise that resolves to the updated tenant. * @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(tenantKey: string, tenantData: TenantUpdate): Promise; /** * Deletes a tenant. * * @param tenantKey The key of the tenant to delete. * @returns A promise that resolves when the tenant 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(tenantKey: string): Promise; /** * Deletes a user from a given tenant (also removes all roles granted to the user in that tenant). * * @param tenantKey - The key of the tenant from which the user will be deleted. * @param userKey - The key of the user to be deleted. * @returns A promise that resolves when the user 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. */ deleteTenantUser(tenantKey: string, userKey: string): Promise; } /** * The TenantsApi class provides methods for interacting with Permit Tenants. */ export declare class TenantsApi extends BasePermitApi implements ITenantsApi { private tenants; /** * Creates an instance of the TenantsApi. * @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 tenants. * * @param pagination The pagination options, @see {@link IPagination} * @returns A promise that resolves to an array of tenants. * @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 list of users for a given tenant. * * @param params - pagination and filtering params. * @returns A promise that resolves to a PaginatedResultUserRead object containing the list of tenant users. * @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. */ listTenantUsers({ tenantKey, page, perPage, }: IListTenantUsers): Promise; /** * Retrieves a tenant by its key. * * @param tenantKey The key of the tenant. * @returns A promise that resolves to the tenant. * @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(tenantKey: string): Promise; /** * Retrieves a tenant by its key. * Alias for the {@link get} method. * * @param tenantKey The key of the tenant. * @returns A promise that resolves to the tenant. * @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(tenantKey: string): Promise; /** * Retrieves a tenant by its ID. * Alias for the {@link get} method. * * @param tenantId The ID of the tenant. * @returns A promise that resolves to the tenant. * @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(tenantId: string): Promise; /** * Creates a new tenant. * * @param tenantData The data for the new tenant. * @returns A promise that resolves to the created tenant. * @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(tenantData: TenantCreate): Promise; /** * Updates a tenant. * * @param tenantKey The key of the tenant. * @param tenantData The updated data for the tenant. * @returns A promise that resolves to the updated tenant. * @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(tenantKey: string, tenantData: TenantUpdate): Promise; /** * Deletes a tenant. * * @param tenantKey The key of the tenant to delete. * @returns A promise that resolves when the tenant 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(tenantKey: string): Promise; /** * Deletes a user from a given tenant (also removes all roles granted to the user in that tenant). * * @param tenantKey - The key of the tenant from which the user will be deleted. * @param userKey - The key of the user to be deleted. * @returns A promise that resolves when the user 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. */ deleteTenantUser(tenantKey: string, userKey: string): Promise; }