import { WorkspaceScopedResource, extractData } from './base.js';
/**
 * Manage API keys for a workspace.
 *
 * API keys are used to authenticate SDK/API requests. Each key has a role
 * and a set of permissions. Keys expire after 1-90 days.
 */
export class ApiKeysResource extends WorkspaceScopedResource {
    /**
     * Get info about the currently authenticated API key.
     * Does not require a workspace ID in the path.
     */
    async me() {
        return extractData(await this.client.GET('/v1/auth/me', {}));
    }
    /** Create a new API key */
    async create(body) {
        return extractData(await this.client.POST('/v1/{workspace_id}/api-keys', {
            params: { path: { workspace_id: this.workspaceId } },
            body,
        }));
    }
    /** List API keys in the workspace */
    async list(params) {
        return extractData(await this.client.GET('/v1/{workspace_id}/api-keys', {
            params: { path: { workspace_id: this.workspaceId }, query: params },
        }));
    }
    listAutoPaging(params) {
        return this.iteratePaginatedList((pageParams) => this.list(pageParams), params);
    }
    /** Revoke an API key */
    async revoke(keyId) {
        await this.client.DELETE('/v1/{workspace_id}/api-keys/{key_id}', {
            params: { path: { workspace_id: this.workspaceId, key_id: keyId } },
        });
    }
    /** Rotate an API key — invalidates the old key and issues a new one */
    async rotate(keyId, body) {
        return extractData(await this.client.POST('/v1/{workspace_id}/api-keys/{key_id}/rotate', {
            params: { path: { workspace_id: this.workspaceId, key_id: keyId } },
            body,
        }));
    }
}
//# sourceMappingURL=api-keys.js.map