/** * Palantir Foundry Connectivity API. * External connections, configurations, secrets, table/file imports. * Base path: /api/v2/connectivity/connections/ * @see https://www.palantir.com/docs/foundry/api/v2/connectivity-v2-resources/ */ import type { PalantirClient } from "./client.js"; import type { Connection, PageResponse, PageParams } from "./types.js"; export class ConnectivityNamespace { constructor(private client: PalantirClient) {} // ─── Connections ──────────────────────────────────────────────── /** List connections. */ async list(params?: PageParams): Promise> { return this.client.get("/api/v2/connectivity/connections", params); } /** Get a connection by RID. */ async get(connectionRid: string): Promise { return this.client.get(`/api/v2/connectivity/connections/${connectionRid}`); } /** Create a new connection. */ async create(params: { parentFolderRid: string; displayName: string; configuration: Record; }): Promise { return this.client.post("/api/v2/connectivity/connections", params); } /** Get the configuration of a connection (lighter-weight than get). */ async getConfiguration(connectionRid: string): Promise> { return this.client.get( `/api/v2/connectivity/connections/${connectionRid}/getConfiguration`, { preview: true } as Record ); } /** Get configurations for multiple connections in batch. */ async getConfigurationBatch(params: { connectionRids: string[] }): Promise { return this.client.post( "/api/v2/connectivity/connections/getConfigurationBatch", params ); } /** Update secrets on a connection. */ async updateSecrets( connectionRid: string, params: { secrets: Record } ): Promise { return this.client.post( `/api/v2/connectivity/connections/${connectionRid}/updateSecrets`, params ); } // ─── Table Imports ───────────────────────────────────────────── // @see https://www.palantir.com/docs/foundry/api/v2/connectivity-v2-resources/table-imports/ /** List table imports for a connection. */ async listTableImports( connectionRid: string, params?: PageParams ): Promise> { return this.client.get( `/api/v2/connectivity/connections/${connectionRid}/tableImports`, params ); } /** Get a table import. */ async getTableImport(connectionRid: string, tableImportRid: string): Promise { return this.client.get( `/api/v2/connectivity/connections/${connectionRid}/tableImports/${tableImportRid}` ); } /** Create a table import. */ async createTableImport( connectionRid: string, params: Record ): Promise { return this.client.post( `/api/v2/connectivity/connections/${connectionRid}/tableImports`, params ); } /** Replace a table import. */ async replaceTableImport( connectionRid: string, tableImportRid: string, params: Record ): Promise { return this.client.put( `/api/v2/connectivity/connections/${connectionRid}/tableImports/${tableImportRid}`, params ); } /** Delete a table import. */ async deleteTableImport(connectionRid: string, tableImportRid: string): Promise { return this.client.delete( `/api/v2/connectivity/connections/${connectionRid}/tableImports/${tableImportRid}` ); } /** Execute a table import. */ async executeTableImport(connectionRid: string, tableImportRid: string): Promise { return this.client.post( `/api/v2/connectivity/connections/${connectionRid}/tableImports/${tableImportRid}/execute` ); } // ─── File Imports ────────────────────────────────────────────── // @see https://www.palantir.com/docs/foundry/api/v2/connectivity-v2-resources/file-imports/ /** List file imports for a connection. */ async listFileImports( connectionRid: string, params?: PageParams ): Promise> { return this.client.get( `/api/v2/connectivity/connections/${connectionRid}/fileImports`, params ); } /** Get a file import. */ async getFileImport(connectionRid: string, fileImportRid: string): Promise { return this.client.get( `/api/v2/connectivity/connections/${connectionRid}/fileImports/${fileImportRid}` ); } /** Create a file import. */ async createFileImport( connectionRid: string, params: Record ): Promise { return this.client.post( `/api/v2/connectivity/connections/${connectionRid}/fileImports`, params ); } /** Replace a file import. */ async replaceFileImport( connectionRid: string, fileImportRid: string, params: Record ): Promise { return this.client.put( `/api/v2/connectivity/connections/${connectionRid}/fileImports/${fileImportRid}`, params ); } /** Delete a file import. */ async deleteFileImport(connectionRid: string, fileImportRid: string): Promise { return this.client.delete( `/api/v2/connectivity/connections/${connectionRid}/fileImports/${fileImportRid}` ); } /** Execute a file import. */ async executeFileImport(connectionRid: string, fileImportRid: string): Promise { return this.client.post( `/api/v2/connectivity/connections/${connectionRid}/fileImports/${fileImportRid}/execute` ); } }