import { AxiosResponse } from 'axios'; import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { ConditionSetCreate, ConditionSetRead, ConditionSetRuleCreate, ConditionSetRuleRead, ConditionSetRuleRemove, ConditionSetType, ConditionSetUpdate, ResourceCreate, ResourceRead, ResourceUpdate, RoleAssignmentCreate, RoleAssignmentRead, RoleAssignmentRemove, RoleCreate, RoleRead, RoleUpdate, TenantCreate, TenantRead, TenantUpdate, UserCreate, UserRead, UserUpdate } from '../openapi'; import { BasePermitApi } from './base'; /** * This interface contains *read actions* that goes outside * of your local network and queries permit.io cloud api. * You should be aware that these actions incur some cross-cloud latency. * @see {@link DeprecatedApiClient} for implementation and docs. */ export interface IDeprecatedReadApis { listUsers(): Promise; listRoles(): Promise; getUser(userId: string): Promise; getTenant(tenantId: string): Promise; getRole(roleId: string): Promise; getAssignedRoles(user: string, tenant?: string): Promise; listConditionSets(type: string, page: number, per_page: number): Promise; listConditionSetsRules(page: number, per_page: number): Promise; } /** * This interface contains *write actions* (or mutations) that manipulate remote * state by calling the permit.io api. These api calls goes *outside* your local network. * You should be aware that these actions incur some cross-cloud latency. * @see {@link DeprecatedApiClient} for implementation and docs. */ export interface IDeprecatedWriteApis { createUser(user: UserCreate): Promise; updateUser(userId: string, user: UserUpdate): Promise; syncUser(user: UserCreate): Promise; deleteUser(userId: string): Promise>; createTenant(tenant: TenantCreate): Promise; updateTenant(tenantId: string, tenant: TenantUpdate): Promise; deleteTenant(tenantId: string): Promise>; listTenants(page?: number): Promise; createRole(role: RoleCreate): Promise; updateRole(roleId: string, role: RoleUpdate): Promise; deleteRole(roleId: string): Promise>; assignRole(assignedRole: RoleAssignmentCreate): Promise; unassignRole(removedRole: RoleAssignmentRemove): Promise>; createResource(resource: ResourceCreate): Promise; updateResource(resourceId: string, resource: ResourceUpdate): Promise; deleteResource(resourceId: string): Promise>; createConditionSet(conditionSet: ConditionSetCreate): Promise; updateConditionSet(conditionSetId: string, conditionSet: ConditionSetUpdate): Promise; deleteConditionSet(conditionSetId: string): Promise>; assignConditionSetRule(conditionSetRule: ConditionSetRuleCreate): Promise; unassignConditionSetRule(conditionSetRule: ConditionSetRuleRemove): Promise>; } export interface IDeprecatedPermitApi extends IDeprecatedReadApis, IDeprecatedWriteApis { } /** * Contains all the deprecated `permit.api.` methods in one place. * The SDK now replaced all `permit.api.createRole()` with `permit.api.roles.create()` * due to the large number of API endpoints, trying to allow more user-friendly code * autocomplete behavior. */ export declare class DeprecatedApiClient extends BasePermitApi implements IDeprecatedPermitApi { private _users; private _tenants; private _roles; private _conditionSets; private _conditionSetRules; private _roleAssignments; private _resources; /** * Creates an instance of DeprecatedApiClient. * @param config - The configuration object for the Permit SDK. * @param logger - The logger object for logging. */ constructor(config: IPermitConfig, logger: Logger); /** * Retrieves a list of users. * @returns A promise that resolves to an array of UserRead objects representing the 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. * @deprecated replaced with permit.api.users.list() */ listUsers(): Promise; /** * Retrieves a list of roles. * @returns A promise that resolves to an array of RoleRead objects representing the 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. * @deprecated replaced with permit.api.roles.list() */ listRoles(): Promise; /** * Retrieves a list of condition sets. * @param type - The type of the condition set, either `userset` or `resourceset`. * @param page - The page number. * @param perPage - The number of items per page. * @returns A promise that resolves to an array of ConditionSetRead objects representing the condition sets. * @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. * @deprecated replaced with permit.api.conditionSets.list() */ listConditionSets(type: ConditionSetType, page: number, perPage: number): Promise; /** * Retrieves a list of condition set rules. * @param page - The page number. * @param perPage - The number of items per page. * @returns A promise that resolves to an array of ConditionSetRuleRead objects representing the condition set rules. * @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. * @deprecated replaced with permit.api.conditionSetRules.list() */ listConditionSetsRules(page: number, perPage: number): Promise; /** * Retrieves a user by ID or key * @param userId - The ID or the key of the user. * @returns A promise that resolves to a UserRead object representing the user. * @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. * @deprecated replaced with permit.api.users.get() */ getUser(userId: string): Promise; /** * Retrieves a tenant by ID or key. * @param tenantId - The ID or the key of the tenant. * @returns A promise that resolves to a TenantRead object representing 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. * @deprecated replaced with permit.api.tenants.get() */ getTenant(tenantId: string): Promise; /** * Retrieves a list of tenants. * @param page - The page number. * @returns A promise that resolves to an array of TenantRead objects representing the 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. * @deprecated replaced with permit.api.tenants.list() */ listTenants(page?: number): Promise; /** * Retrieves a role by ID or key. * @param roleId - The ID or the key of the role. * @returns A promise that resolves to a RoleRead object representing 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. * @deprecated replaced with permit.api.roles.get() */ getRole(roleId: string): Promise; /** * Retrieves the assigned roles for a user (either in a single tenant or in all tenants). * @param user - The ID or key of the user. * @param tenant - The ID or key of the tenant, optional. If provided, only roles assigned within this tenant will be returned. * @returns A promise that resolves to an array of RoleAssignmentRead objects representing the assigned 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. * @deprecated replaced with permit.api.users.getAssignedRoles() */ getAssignedRoles(user: string, tenant?: string): Promise; /** * Creates a new resource. * @param resource - The resource to create. * @returns A promise that resolves to a ResourceRead object representing 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. * @deprecated replaced with permit.api.resources.create() */ createResource(resource: ResourceCreate): Promise; /** * Updates an existing resource. * @param resourceId - The ID or key of the resource to update. * @param resource - The updated resource data. * @returns A promise that resolves to a ResourceRead object representing 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. * @deprecated replaced with permit.api.resources.update() */ updateResource(resourceId: string, resource: ResourceUpdate): Promise; /** * Deletes a resource. * @param resourceId - The ID or 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. * @deprecated replaced with permit.api.resources.delete() */ deleteResource(resourceId: string): Promise>; /** * Creates a new user. * @param user - The user to create. * @returns A promise that resolves to a UserRead object representing the created user. * @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. * @deprecated replaced with permit.api.users.create() */ createUser(user: UserCreate): Promise; /** * Creates or Updates in place a user. * @param user - The user to create or update. * @returns A promise that resolves to a UserRead object representing the synced user. * @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. * @deprecated replaced with permit.api.users.sync() */ syncUser(user: UserCreate): Promise; /** * Updates an existing user. * @param userId - The ID or key of the user to update. * @param user - The updated user data. * @returns A promise that resolves to a UserRead object representing the updated user. * @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. * @deprecated replaced with permit.api.users.update() */ updateUser(userId: string, user: UserUpdate): Promise; /** * Deletes a user. * @param userId - The ID or key of the user to delete. * @returns A promise that resolves when the user 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. * @deprecated replaced with permit.api.users.delete() */ deleteUser(userId: string): Promise>; /** * Creates a new tenant. * @param tenant - The tenant to create. * @returns A promise that resolves to a TenantRead object representing 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. * @deprecated replaced with permit.api.tenants.create() */ createTenant(tenant: TenantCreate): Promise; /** * Updates an existing tenant. * @param tenantId - The ID or key of the tenant to update. * @param tenant - The updated tenant data. * @returns A promise that resolves to a TenantRead object representing 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. * @deprecated replaced with permit.api.tenants.update() */ updateTenant(tenantId: string, tenant: TenantUpdate): Promise; /** * Deletes a tenant. * @param tenantId - The ID or 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. * @deprecated replaced with permit.api.tenants.delete() */ deleteTenant(tenantId: string): Promise>; /** * Creates a new role. * @param role - The role to create. * @returns A promise that resolves to a RoleRead object representing 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. * @deprecated replaced with permit.api.roles.create() */ createRole(role: RoleCreate): Promise; /** * Updates an existing role. * @param roleId - The ID or key of the role to update. * @param role - The updated role data. * @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. * @deprecated replaced with permit.api.roles.update() */ updateRole(roleId: string, role: RoleUpdate): Promise; /** * Deletes a role. * @param roleId - The ID or 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. * @deprecated replaced with permit.api.roles.delete() */ deleteRole(roleId: string): Promise>; /** * Assigns a role to a user. * @param assignedRole - The role assignment data. * @returns A promise that resolves to a RoleAssignmentRead object representing the assigned 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. * @deprecated replaced with permit.api.users.assignRole() */ assignRole(assignedRole: RoleAssignmentCreate): Promise; /** * Unassigns a role from a user. * @param removedRole - The role unassignment data. * @returns A promise that resolves when the role is unassigned. * @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. * @deprecated replaced with permit.api.users.unassignRole() */ unassignRole(removedRole: RoleAssignmentRemove): Promise>; /** * Creates a new condition set. * @param conditionSet - The condition set to create. * @returns A promise that resolves to a ConditionSetRead object representing the created condition set. * @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. * @deprecated replaced with permit.api.conditionSets.create() */ createConditionSet(conditionSet: ConditionSetCreate): Promise; /** * Updates an existing condition set. * @param conditionSetId - The ID or key of the condition set to update. * @param conditionSet - The updated condition set data. * @returns A promise that resolves to a ConditionSetRead object representing the updated condition set. * @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. * @deprecated replaced with permit.api.conditionSets.update() */ updateConditionSet(conditionSetId: string, conditionSet: ConditionSetUpdate): Promise; /** * Deletes a condition set. * @param conditionSetId - The ID or key of the condition set to delete. * @returns A promise that resolves when the condition set 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. * @deprecated replaced with permit.api.conditionSets.delete() */ deleteConditionSet(conditionSetId: string): Promise>; /** * Creates a condition set rule (i.e: grants permission to a userset to act on a resourceset). * @param conditionSetRule - The condition set rule data. * @returns A promise that resolves to a ConditionSetRuleRead object representing the assigned condition set rule. * @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. * @deprecated replaced with permit.api.conditionSetRules.create() */ assignConditionSetRule(conditionSetRule: ConditionSetRuleCreate): Promise; /** * Removes a condition set rule (i.e: unassigns permission from a userset to act on a resourceset). * @param conditionSetRuleId - The ID or key of the condition set rule to remove. * @returns A promise that resolves when the condition set rule 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. * @deprecated replaced with permit.api.conditionSetRules.delete() */ unassignConditionSetRule(conditionSetRule: ConditionSetRuleRemove): Promise>; getMethods(): IDeprecatedPermitApi; }