import { WorkspaceScopedResource, extractData } from './base.js';
export class WorkspaceDatabaseResource extends WorkspaceScopedResource {
    get(path, init) {
        return this.client.GET(path, init);
    }
    post(path, init) {
        return this.client.POST(path, init);
    }
    patch(path, init) {
        return this.client.PATCH(path, init);
    }
    delete(path, init) {
        return this.client.DELETE(path, init);
    }
    // -- Fork lifecycle -------------------------------------------------------
    async getFork() {
        return extractData(await this.get('/v1/{workspace_id}/fork', {
            params: { path: { workspace_id: this.workspaceId } },
        }));
    }
    async createFork(body) {
        return extractData(await this.post('/v1/{workspace_id}/fork', {
            params: { path: { workspace_id: this.workspaceId } },
            body,
        }));
    }
    async deleteFork() {
        await this.delete('/v1/{workspace_id}/fork', {
            params: { path: { workspace_id: this.workspaceId } },
        });
    }
    // -- Query execution ------------------------------------------------------
    async executeQuery(body) {
        return extractData(await this.post('/v1/{workspace_id}/lakebase/query', {
            params: { path: { workspace_id: this.workspaceId } },
            body,
        }));
    }
    // -- Query tool CRUD ------------------------------------------------------
    async listQueryTools(params) {
        return extractData(await this.get('/v1/{workspace_id}/query-tools', {
            params: { path: { workspace_id: this.workspaceId }, query: params },
        }));
    }
    listQueryToolsAutoPaging(params) {
        return this.iteratePaginatedList((pageParams) => this.listQueryTools(pageParams), params);
    }
    async createQueryTool(body) {
        return extractData(await this.post('/v1/{workspace_id}/query-tools', {
            params: { path: { workspace_id: this.workspaceId } },
            body,
        }));
    }
    async updateQueryTool(toolId, body) {
        return extractData(await this.patch('/v1/{workspace_id}/query-tools/{tool_id}', {
            params: { path: { workspace_id: this.workspaceId, tool_id: toolId } },
            body,
        }));
    }
    async deleteQueryTool(toolId) {
        await this.delete('/v1/{workspace_id}/query-tools/{tool_id}', {
            params: { path: { workspace_id: this.workspaceId, tool_id: toolId } },
        });
    }
    async testQueryTool(toolId, body) {
        return extractData(await this.post('/v1/{workspace_id}/query-tools/{tool_id}/test', {
            params: { path: { workspace_id: this.workspaceId, tool_id: toolId } },
            body,
        }));
    }
}
//# sourceMappingURL=workspace-database.js.map