import { Logger } from 'winston'; import { IPermitConfig } from '../config'; import { APIKeyRead, EnvironmentCopy, EnvironmentCreate, EnvironmentRead, EnvironmentStats, EnvironmentUpdate } from '../openapi'; import { BasePermitApi, IPagination } from './base'; export { APIKeyRead, EnvironmentCopy, EnvironmentCreate, EnvironmentRead, EnvironmentStats, EnvironmentUpdate, } from '../openapi'; export interface IListEnvironments extends IPagination { /** * only environments under the project with this key will be listed. */ projectKey: string; } export interface IEnvironmentsApi { /** * Retrieves a list of environments. * * @param params - the filters and pagination options, @see {@link IListEnvironments} * @returns A promise that resolves to an array of EnvironmentRead objects representing the listed environments. * @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: IListEnvironments): Promise; /** * Gets an environment by project key and environment key. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves to an EnvironmentRead object representing the retrieved environment. * @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(projectKey: string, environmentKey: string): Promise; /** * Gets an environment by project key and environment key. * Alias for the {@link get} method. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves to an EnvironmentRead object representing the retrieved environment. * @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(projectKey: string, environmentKey: string): Promise; /** * Gets an environment by project ID and environment ID. * Alias for the {@link get} method. * * @param projectId - The project ID. * @param environmentId - The environment ID. * @returns A promise that resolves to an EnvironmentRead object representing the retrieved environment. * @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(projectId: string, environmentId: string): Promise; /** * Retrieves statistics and metadata for an environment. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves to an EnvironmentStats object representing the statistics data. * @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. */ getStats(projectKey: string, environmentKey: string): Promise; /** * Retrieves the API key that grants access for an environment (and only the requested environment). * Must be requested with an organization-level api key. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves to an APIKeyRead object containing the API key and its metadata. * @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. */ getApiKey(projectKey: string, environmentKey: string): Promise; /** * Creates a new environment. * * @param projectKey - The project key. * @param environmentData - The data for creating the environment. * @returns A promise that resolves to an EnvironmentRead object representing the created environment. * @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(projectKey: string, environmentData: EnvironmentCreate): Promise; /** * Updates an existing environment. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @param environmentData - The data for updating the environment. * @returns A promise that resolves to an EnvironmentRead object representing the updated environment. * @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(projectKey: string, environmentKey: string, environmentData: EnvironmentUpdate): Promise; /** * Clones data (creates a copy) from a source specified environment into a different target * environment in the same project. The target environment can be a new environment or an existing * environment. For existing environments, the user must specify a conflict strategy - meaning what * the system should do in case a copied object conflicts with an existing object (with the same key) * in the target environment. The system can overwrite all the conflicting objects, or fail (and * cancel the copy) when encountering the first conflict. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @param copyParams - The parameters for copying the environment. * @returns A promise that resolves to an EnvironmentRead object representing the copied environment. * @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. */ copy(projectKey: string, environmentKey: string, copyParams: EnvironmentCopy): Promise; /** * Deletes an environment. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves when the environment 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(projectKey: string, environmentKey: string): Promise; } /** * The EnvironmentsApi class provides methods for interacting with Permit Environments. */ export declare class EnvironmentsApi extends BasePermitApi implements IEnvironmentsApi { private environments; private apiKeys; /** * Creates an instance of the EnvironmentsApi. * @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 environments. * * @param params - the filters and pagination options, @see {@link IListEnvironments} * @returns A promise that resolves to an array of EnvironmentRead objects representing the listed environments. * @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: IListEnvironments): Promise; /** * Gets an environment by project key and environment key. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves to an EnvironmentRead object representing the retrieved environment. * @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(projectKey: string, environmentKey: string): Promise; /** * Gets an environment by project key and environment key. * Alias for the {@link get} method. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves to an EnvironmentRead object representing the retrieved environment. * @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(projectKey: string, environmentKey: string): Promise; /** * Gets an environment by project ID and environment ID. * Alias for the {@link get} method. * * @param projectId - The project ID. * @param environmentId - The environment ID. * @returns A promise that resolves to an EnvironmentRead object representing the retrieved environment. * @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(projectId: string, environmentId: string): Promise; /** * Retrieves statistics and metadata for an environment. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves to an EnvironmentStats object representing the statistics data. * @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. */ getStats(projectKey: string, environmentKey: string): Promise; /** * Retrieves the API key that grants access for an environment (and only the requested environment). * Must be requested with an organization-level api key. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves to an APIKeyRead object containing the API key and its metadata. * @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. */ getApiKey(projectKey: string, environmentKey: string): Promise; /** * Creates a new environment. * * @param projectKey - The project key. * @param environmentData - The data for creating the environment. * @returns A promise that resolves to an EnvironmentRead object representing the created environment. * @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(projectKey: string, environmentData: EnvironmentCreate): Promise; /** * Updates an existing environment. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @param environmentData - The data for updating the environment. * @returns A promise that resolves to an EnvironmentRead object representing the updated environment. * @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(projectKey: string, environmentKey: string, environmentData: EnvironmentUpdate): Promise; /** * Clones data (creates a copy) from a source specified environment into a different target * environment in the same project. The target environment can be a new environment or an existing * environment. For existing environments, the user must specify a conflict strategy - meaning what * the system should do in case a copied object conflicts with an existing object (with the same key) * in the target environment. The system can overwrite all the conflicting objects, or fail (and * cancel the copy) when encountering the first conflict. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @param copyParams - The parameters for copying the environment. * @returns A promise that resolves to an EnvironmentRead object representing the copied environment. * @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. */ copy(projectKey: string, environmentKey: string, copyParams: EnvironmentCopy): Promise; /** * Deletes an environment. * * @param projectKey - The project key. * @param environmentKey - The environment key. * @returns A promise that resolves when the environment 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(projectKey: string, environmentKey: string): Promise; }