From 8b287b743ff5db95ff45a41492833356e66e96ce Mon Sep 17 00:00:00 2001 From: Nurul Sundarani Date: Sun, 17 Aug 2025 00:22:07 +0530 Subject: [PATCH 1/4] feat: add Prisma Management API integration --- components/prisma_management_api/README.md | 131 ++++++++++++++++++ .../create-database-connection-string.mjs | 37 +++++ ...reate-new-database-in-existing-project.mjs | 55 ++++++++ .../create-postgres-database.mjs | 57 ++++++++ .../delete-database-by-database-id.mjs | 33 +++++ .../delete-database-connection-string.mjs | 33 +++++ .../delete-postgres-database.mjs | 33 +++++ .../get-database-details.mjs | 29 ++++ .../get-postgres-regions.mjs | 24 ++++ .../get-project-details.mjs | 29 ++++ .../list-database-connection-strings.mjs | 30 ++++ .../list-databases-from-project.mjs | 30 ++++ .../list-projects-in-prisma-workspace.mjs | 24 ++++ components/prisma_management_api/package.json | 3 + .../prisma_management_api.app.mjs | 122 +++++++++++++++- 15 files changed, 667 insertions(+), 3 deletions(-) create mode 100644 components/prisma_management_api/README.md create mode 100644 components/prisma_management_api/actions/create-database-connection-string/create-database-connection-string.mjs create mode 100644 components/prisma_management_api/actions/create-new-database-in-existing-project/create-new-database-in-existing-project.mjs create mode 100644 components/prisma_management_api/actions/create-postgres-database/create-postgres-database.mjs create mode 100644 components/prisma_management_api/actions/delete-database-by-database-id/delete-database-by-database-id.mjs create mode 100644 components/prisma_management_api/actions/delete-database-connection-string/delete-database-connection-string.mjs create mode 100644 components/prisma_management_api/actions/delete-postgres-database/delete-postgres-database.mjs create mode 100644 components/prisma_management_api/actions/get-database-details/get-database-details.mjs create mode 100644 components/prisma_management_api/actions/get-postgres-regions/get-postgres-regions.mjs create mode 100644 components/prisma_management_api/actions/get-project-details/get-project-details.mjs create mode 100644 components/prisma_management_api/actions/list-database-connection-strings/list-database-connection-strings.mjs create mode 100644 components/prisma_management_api/actions/list-databases-from-project/list-databases-from-project.mjs create mode 100644 components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs diff --git a/components/prisma_management_api/README.md b/components/prisma_management_api/README.md new file mode 100644 index 0000000000000..096eab617eaf3 --- /dev/null +++ b/components/prisma_management_api/README.md @@ -0,0 +1,131 @@ +# Prisma Management API + +The Prisma Management API interacts seamlessly with Pipedream, empowering you to craft customized automations and workflows for your Prisma Postgres databases. Create projects, manage databases, and handle connection strings with ease. + +## Overview + +The Prisma Management API provides programmatic access to manage Prisma Postgres database projects. This integration allows you to automate database lifecycle management, connection string generation, and resource provisioning within your Pipedream workflows. + +With this integration, you can: + +- **Automate Database Provisioning**: Automatically create new Postgres database projects with proper regional distribution +- **Manage Connection Strings**: Generate and manage secure connection strings for your applications +- **Monitor Resources**: List and inspect databases, projects, and connection details across your workspace +- **Streamline Cleanup**: Systematically remove databases and connection strings when no longer needed + +## Getting Started + +To use the Prisma Management API with Pipedream, you'll need to connect your Prisma account and obtain an API integration token. + +## Actions + +### Project Management + +#### Create Postgres Database +Creates a new Postgres database project via Prisma Management API. This action creates a complete project with database and provides connection string details in the response for immediate use. + +**Parameters:** +- `name` (string, required): The name of the Postgres database project to create +- `region` (string, optional): The region where the database should be created (default: us-east-1) + +**Available regions:** us-east-1, us-west-1, eu-west-3, eu-central-1, ap-northeast-1, ap-southeast-1 + +#### List Projects in Prisma Workspace +Retrieves all projects within your Prisma workspace. + +#### Get Project Details +Retrieves detailed information about a specific project including associated databases and configuration. + +**Parameters:** +- `projectId` (string, required): The ID of the project to retrieve + +#### Delete Postgres Database +Removes an entire Postgres database project and all associated resources. + +**Parameters:** +- `projectId` (string, required): The ID of the project to delete + +### Database Management + +#### Create New Database in Existing Project +Adds a new database to an existing Prisma project. + +**Parameters:** +- `projectId` (string, required): The ID of the project where the database should be created +- `region` (string, optional): The region for the database +- `isDefault` (boolean, optional): Whether to set this as the default database for the project + +#### List Databases from Project +Retrieves all databases within a specific project. + +**Parameters:** +- `projectId` (string, required): The ID of the project + +#### Get Database Details +Retrieves detailed information about a specific Prisma Postgres database. + +**Parameters:** +- `databaseId` (string, required): The ID of the database + +#### Delete Database by Database ID +Removes a specific database by its ID. + +**Parameters:** +- `databaseId` (string, required): The ID of the database to delete + +### Connection String Management + +#### Create Database Connection String +Generates a new connection string for database access. + +**Parameters:** +- `databaseId` (string, required): The ID of the database +- `name` (string, required): A descriptive name for the connection + +#### List Database Connection Strings +Retrieves all connection strings for a specific database. + +**Parameters:** +- `databaseId` (string, required): The ID of the database + +#### Delete Database Connection String +Removes a specific connection string. + +**Parameters:** +- `connectionId` (string, required): The ID of the connection to delete + +### Utilities + +#### Get Prisma Postgres Regions +Retrieves the list of available AWS regions for Prisma Postgres deployment. + +## Authentication + +This integration uses API Token authentication. You'll need to provide your Prisma Management API integration token when configuring the connection in Pipedream. + +To obtain your API token: +1. Log in to your Prisma account +2. Navigate to your workspace settings +3. Generate a new Management API integration token +4. Copy the token for use in Pipedream + +## API Documentation + +For complete API documentation and additional details, visit the [Prisma Management API Documentation](https://www.prisma.io/docs/postgres/introduction/management-api). + +## Example Workflows + +### Automated Database Setup for New Projects +Trigger a workflow when a new project is created in your system, automatically provision a Prisma Postgres database, and store the connection details in your configuration management system. + +### Database Cleanup Automation +Schedule periodic cleanup of unused databases and connection strings to maintain security and reduce costs. + +### Multi-Region Database Deployment +Create databases across multiple regions for improved performance and redundancy based on your application's geographic distribution. + +## Support + +For issues specific to the Prisma Management API, refer to the [official documentation](https://www.prisma.io/docs/postgres/introduction/management-api). + +For Pipedream-related questions, visit the [Pipedream documentation](https://pipedream.com/docs) or community forums. \ No newline at end of file diff --git a/components/prisma_management_api/actions/create-database-connection-string/create-database-connection-string.mjs b/components/prisma_management_api/actions/create-database-connection-string/create-database-connection-string.mjs new file mode 100644 index 0000000000000..9516f40f4f392 --- /dev/null +++ b/components/prisma_management_api/actions/create-database-connection-string/create-database-connection-string.mjs @@ -0,0 +1,37 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "Create Database Connection String", + version: "0.1.0", + key: "prisma_management_api-create-database-connection-string", + description: "Creates a new connection string for an existing database via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + databaseId: { + type: "string", + label: "Database ID", + description: "The ID of the database to create a connection string for", + }, + name: { + type: "string", + label: "Connection Name", + description: "A descriptive name for the connection string", + }, + }, + async run({ $ }) { + const response = await this.app.createConnectionString({ + $, + databaseId: this.databaseId, + data: { + name: this.name, + }, + }); + + if (response) { + $.export("$summary", `Successfully created connection string for database ${this.databaseId}${response.id ? ` with connection ID ${response.id}` : ""}`); + } + + return response; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/create-new-database-in-existing-project/create-new-database-in-existing-project.mjs b/components/prisma_management_api/actions/create-new-database-in-existing-project/create-new-database-in-existing-project.mjs new file mode 100644 index 0000000000000..bd617e4f1bea7 --- /dev/null +++ b/components/prisma_management_api/actions/create-new-database-in-existing-project/create-new-database-in-existing-project.mjs @@ -0,0 +1,55 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "Create New Database in Existing Project", + version: "0.1.0", + key: "prisma_management_api-create-new-database-in-existing-project", + description: "Create a new database in an existing Prisma project. Requires Project ID. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + projectId: { + type: "string", + label: "Project ID", + description: "The ID of the project where the database should be created", + }, + region: { + type: "string", + label: "Region", + description: "The AWS region where the database should be created", + options: [ + "us-east-1", + "us-west-1", + "eu-west-3", + "eu-central-1", + "ap-northeast-1", + "ap-southeast-1", + ], + optional: true, + }, + isDefault: { + type: "boolean", + label: "Set as Default Database", + description: "Whether to set this database as the default for the project", + optional: true, + default: false, + }, + }, + async run({ $ }) { + const data = {}; + if (this.region) data.region = this.region; + if (this.isDefault !== undefined) data.default = this.isDefault; + + const response = await this.app.createDatabase({ + $, + projectId: this.projectId, + data, + }); + + if (response) { + $.export("$summary", `Successfully created database in project ${this.projectId}${response.id ? ` with ID ${response.id}` : ""}`); + } + + return response; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/create-postgres-database/create-postgres-database.mjs b/components/prisma_management_api/actions/create-postgres-database/create-postgres-database.mjs new file mode 100644 index 0000000000000..f5ded1ab3edfd --- /dev/null +++ b/components/prisma_management_api/actions/create-postgres-database/create-postgres-database.mjs @@ -0,0 +1,57 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "Create Postgres Database", + version: "0.1.0", + key: "prisma_management_api-create-postgres-database", + description: "Creates a new Postgres database project via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + name: { + type: "string", + label: "Project Name", + description: "The name of the Postgres database project to create", + }, + region: { + type: "string", + label: "Region", + description: "The region where the database should be created", + options: [ + "us-east-1", + "us-west-1", + "eu-west-3", + "eu-central-1", + "ap-northeast-1", + "ap-southeast-1", + ], + default: "us-east-1", + }, + }, + async run({ $ }) { + const response = await this.app.createProject({ + $, + data: { + name: this.name, + region: this.region, + }, + }); + + if (response) { + const projectId = response.data?.id; + const databaseId = response.data?.database?.id; + + let summary = `Successfully created Postgres database project "${this.name}"`; + if (projectId) { + summary += ` with Project ID ${projectId}`; + } + if (databaseId) { + summary += ` and Database ID ${databaseId}`; + } + + $.export("$summary", summary); + } + + return response; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/delete-database-by-database-id/delete-database-by-database-id.mjs b/components/prisma_management_api/actions/delete-database-by-database-id/delete-database-by-database-id.mjs new file mode 100644 index 0000000000000..4c4212f3abf16 --- /dev/null +++ b/components/prisma_management_api/actions/delete-database-by-database-id/delete-database-by-database-id.mjs @@ -0,0 +1,33 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "Delete Database by Database ID", + version: "0.1.0", + key: "prisma_management_api-delete-database-by-database-id", + description: "Delete a specific database by Database ID via Prisma Management API. This action is irreversible. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + databaseId: { + type: "string", + label: "Database ID", + description: "The ID of the database to delete", + }, + }, + async run({ $ }) { + const response = await this.app.deleteDatabase({ + $, + databaseId: this.databaseId, + }); + + if (response || response === null) { + $.export("$summary", `Successfully deleted database with ID ${this.databaseId}`); + } + + return { + success: true, + databaseId: this.databaseId, + message: "Database deleted successfully", + }; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/delete-database-connection-string/delete-database-connection-string.mjs b/components/prisma_management_api/actions/delete-database-connection-string/delete-database-connection-string.mjs new file mode 100644 index 0000000000000..edcf215c42adc --- /dev/null +++ b/components/prisma_management_api/actions/delete-database-connection-string/delete-database-connection-string.mjs @@ -0,0 +1,33 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "Delete Database Connection String", + version: "0.1.0", + key: "prisma_management_api-delete-database-connection-string", + description: "Deletes a specific database connection string via Prisma Management API. This action is irreversible. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + connectionId: { + type: "string", + label: "Connection ID", + description: "The ID of the database connection to delete", + }, + }, + async run({ $ }) { + const response = await this.app.deleteConnectionString({ + $, + connectionId: this.connectionId, + }); + + if (response || response === null) { + $.export("$summary", `Successfully deleted database connection with ID ${this.connectionId}`); + } + + return { + success: true, + connectionId: this.connectionId, + message: "Database connection deleted successfully", + }; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/delete-postgres-database/delete-postgres-database.mjs b/components/prisma_management_api/actions/delete-postgres-database/delete-postgres-database.mjs new file mode 100644 index 0000000000000..f41aece4a533c --- /dev/null +++ b/components/prisma_management_api/actions/delete-postgres-database/delete-postgres-database.mjs @@ -0,0 +1,33 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "Delete Postgres Database", + version: "0.1.0", + key: "prisma_management_api-delete-postgres-database", + description: "Deletes a Postgres database project via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + projectId: { + type: "string", + label: "Project ID", + description: "The ID of the Postgres database project to delete", + }, + }, + async run({ $ }) { + const response = await this.app.deleteProject({ + $, + projectId: this.projectId, + }); + + if (response || response === null) { + $.export("$summary", `Successfully deleted Postgres database project with ID ${this.projectId}`); + } + + return { + success: true, + projectId: this.projectId, + message: "Database project deleted successfully", + }; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/get-database-details/get-database-details.mjs b/components/prisma_management_api/actions/get-database-details/get-database-details.mjs new file mode 100644 index 0000000000000..b12898df4f3d8 --- /dev/null +++ b/components/prisma_management_api/actions/get-database-details/get-database-details.mjs @@ -0,0 +1,29 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "Get Database details", + version: "0.1.0", + key: "prisma_management_api-get-database-details", + description: "Get database details of a particular Prisma Postgres database via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + databaseId: { + type: "string", + label: "Database ID", + description: "The ID of the database to retrieve information for", + }, + }, + async run({ $ }) { + const response = await this.app.getDatabase({ + $, + databaseId: this.databaseId, + }); + + if (response) { + $.export("$summary", `Successfully retrieved database information for ID ${this.databaseId}`); + } + + return response; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/get-postgres-regions/get-postgres-regions.mjs b/components/prisma_management_api/actions/get-postgres-regions/get-postgres-regions.mjs new file mode 100644 index 0000000000000..15bc746a1a52a --- /dev/null +++ b/components/prisma_management_api/actions/get-postgres-regions/get-postgres-regions.mjs @@ -0,0 +1,24 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "Get Prisma Postgres Regions", + version: "0.1.0", + key: "prisma_management_api-get-postgres-regions", + description: "Retrieves a list of all available regions where Prisma Postgres databases can be deployed. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + }, + async run({ $ }) { + const response = await this.app.listRegions({ + $, + }); + + if (response) { + const count = response.data?.length || 0; + $.export("$summary", `Successfully retrieved ${count} available Postgres region${count !== 1 ? "s" : ""}`); + } + + return response; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/get-project-details/get-project-details.mjs b/components/prisma_management_api/actions/get-project-details/get-project-details.mjs new file mode 100644 index 0000000000000..5ef01a39d4c3c --- /dev/null +++ b/components/prisma_management_api/actions/get-project-details/get-project-details.mjs @@ -0,0 +1,29 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "Get Project details", + version: "0.1.0", + key: "prisma_management_api-get-project-details", + description: "Get project details of a particular project in Prisma Workspace via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + projectId: { + type: "string", + label: "Project ID", + description: "The ID of the project to retrieve information for", + }, + }, + async run({ $ }) { + const response = await this.app.getProject({ + $, + projectId: this.projectId, + }); + + if (response) { + $.export("$summary", `Successfully retrieved project information for ID ${this.projectId}`); + } + + return response; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/list-database-connection-strings/list-database-connection-strings.mjs b/components/prisma_management_api/actions/list-database-connection-strings/list-database-connection-strings.mjs new file mode 100644 index 0000000000000..e1c42dfbff1d9 --- /dev/null +++ b/components/prisma_management_api/actions/list-database-connection-strings/list-database-connection-strings.mjs @@ -0,0 +1,30 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "List Database Connection Strings", + version: "0.1.0", + key: "prisma_management_api-list-database-connection-strings", + description: "Retrieves a list of all connection strings for a specific database via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + databaseId: { + type: "string", + label: "Database ID", + description: "The ID of the database to list connections for", + }, + }, + async run({ $ }) { + const response = await this.app.listConnectionStrings({ + $, + databaseId: this.databaseId, + }); + + if (response) { + const count = response.data?.length || 0; + $.export("$summary", `Successfully retrieved ${count} connection${count !== 1 ? "s" : ""} for database ${this.databaseId}`); + } + + return response; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/list-databases-from-project/list-databases-from-project.mjs b/components/prisma_management_api/actions/list-databases-from-project/list-databases-from-project.mjs new file mode 100644 index 0000000000000..785d7f09b06a9 --- /dev/null +++ b/components/prisma_management_api/actions/list-databases-from-project/list-databases-from-project.mjs @@ -0,0 +1,30 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "List Databases from Project", + version: "0.1.0", + key: "prisma_management_api-list-databases-from-project", + description: "Retrieves a list of all databases within a specific Prisma project. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + projectId: { + type: "string", + label: "Project ID", + description: "The ID of the project to list databases from", + }, + }, + async run({ $ }) { + const response = await this.app.listDatabases({ + $, + projectId: this.projectId, + }); + + if (response) { + const count = response.data?.length || 0; + $.export("$summary", `Successfully retrieved ${count} database${count !== 1 ? "s" : ""} from project ${this.projectId}`); + } + + return response; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs b/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs new file mode 100644 index 0000000000000..f445f99604db9 --- /dev/null +++ b/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs @@ -0,0 +1,24 @@ +import app from "../../prisma_management_api.app.mjs"; + +export default { + name: "List Projects in Prisma Workspace", + version: "0.1.0", + key: "prisma_management_api-list-projects-in-prisma-workspace", + description: "List Projects in a Prisma Workspace via Prisma Management API. Supports pagination for large result sets. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + type: "action", + props: { + app, + }, + async run({ $ }) { + const response = await this.app.listProjects({ + $, + }); + + if (response) { + const count = response.data?.length || 0; + $.export("$summary", `Successfully retrieved ${count} project${count !== 1 ? "s" : ""}`); + } + + return response; + }, +}; \ No newline at end of file diff --git a/components/prisma_management_api/package.json b/components/prisma_management_api/package.json index 3b543d7c7a9e1..fe03d28844e80 100644 --- a/components/prisma_management_api/package.json +++ b/components/prisma_management_api/package.json @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^1.5.1" } } \ No newline at end of file diff --git a/components/prisma_management_api/prisma_management_api.app.mjs b/components/prisma_management_api/prisma_management_api.app.mjs index 39fcb4d5527d5..477f98fd60c5f 100644 --- a/components/prisma_management_api/prisma_management_api.app.mjs +++ b/components/prisma_management_api/prisma_management_api.app.mjs @@ -1,11 +1,127 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "prisma_management_api", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.prisma.io/v1"; + }, + _makeRequest({ + $ = this, path, ...args + }) { + return axios($, { + url: `${this._baseUrl()}${path}`, + headers: { + Authorization: `Bearer ${this.$auth.api_token}`, + "Content-Type": "application/json", + }, + ...args, + }); + }, + async createProject(args = {}) { + return this._makeRequest({ + path: "/projects", + method: "post", + ...args, + }); + }, + async deleteProject({ + projectId, ...args + }) { + return this._makeRequest({ + path: `/projects/${projectId}`, + method: "delete", + ...args, + }); + }, + async listProjects(args = {}) { + return this._makeRequest({ + path: "/projects", + method: "get", + ...args, + }); + }, + async getProject({ + projectId, ...args + }) { + return this._makeRequest({ + path: `/projects/${projectId}`, + method: "get", + ...args, + }); + }, + async createDatabase({ + projectId, ...args + }) { + return this._makeRequest({ + path: `/projects/${projectId}/databases`, + method: "post", + ...args, + }); + }, + async listDatabases({ + projectId, ...args + }) { + return this._makeRequest({ + path: `/projects/${projectId}/databases`, + method: "get", + ...args, + }); + }, + async getDatabase({ + databaseId, ...args + }) { + return this._makeRequest({ + path: `/databases/${databaseId}`, + method: "get", + ...args, + }); + }, + async deleteDatabase({ + databaseId, ...args + }) { + return this._makeRequest({ + path: `/databases/${databaseId}`, + method: "delete", + ...args, + }); + }, + async listConnectionStrings({ + databaseId, ...args + }) { + return this._makeRequest({ + path: `/databases/${databaseId}/connections`, + method: "get", + ...args, + }); + }, + async createConnectionString({ + databaseId, data, ...args + }) { + return this._makeRequest({ + path: `/databases/${databaseId}/connections`, + method: "post", + data: data || {}, + ...args, + }); + }, + async deleteConnectionString({ + connectionId, ...args + }) { + return this._makeRequest({ + path: `/connections/${connectionId}`, + method: "delete", + ...args, + }); + }, + async listRegions(args = {}) { + return this._makeRequest({ + path: "/regions/postgres", + method: "get", + ...args, + }); }, }, }; \ No newline at end of file From c17df921bfb060347477240a873159f9885c1926 Mon Sep 17 00:00:00 2001 From: Nurul Sundarani Date: Mon, 18 Aug 2025 18:45:53 +0530 Subject: [PATCH 2/4] docs: update authentication token references from integration to service token --- components/prisma_management_api/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prisma_management_api/README.md b/components/prisma_management_api/README.md index 096eab617eaf3..746d5448e8d12 100644 --- a/components/prisma_management_api/README.md +++ b/components/prisma_management_api/README.md @@ -97,16 +97,16 @@ Removes a specific connection string. ### Utilities #### Get Prisma Postgres Regions -Retrieves the list of available AWS regions for Prisma Postgres deployment. +Retrieves the list of available regions for Prisma Postgres deployment. ## Authentication -This integration uses API Token authentication. You'll need to provide your Prisma Management API integration token when configuring the connection in Pipedream. +This integration uses API Token authentication. You'll need to provide your Prisma Management API Service token when configuring the connection in Pipedream. To obtain your API token: 1. Log in to your Prisma account 2. Navigate to your workspace settings -3. Generate a new Management API integration token +3. Generate a new Service Token 4. Copy the token for use in Pipedream ## API Documentation From 42baf812efc6280ce8805c6e218ee36f03be4b7c Mon Sep 17 00:00:00 2001 From: Nurul Sundarani Date: Tue, 19 Aug 2025 14:07:11 +0530 Subject: [PATCH 3/4] chore: bump component versions to 1.0.0 and add region prop definition for database creation --- components/prisma_management_api/README.md | 4 +-- .../create-database-connection-string.mjs | 2 +- .../create-database.mjs} | 19 +++++--------- ...reate-new-database-in-existing-project.mjs | 25 ++++++++----------- .../delete-database-by-database-id.mjs | 2 +- .../delete-database-connection-string.mjs | 2 +- .../delete-database.mjs} | 6 ++--- .../get-database-details.mjs | 2 +- .../get-postgres-regions.mjs | 2 +- .../get-project-details.mjs | 2 +- .../list-database-connection-strings.mjs | 2 +- .../list-databases-from-project.mjs | 2 +- .../list-projects-in-prisma-workspace.mjs | 9 +++++-- .../prisma_management_api.app.mjs | 18 ++++++++++++- 14 files changed, 54 insertions(+), 43 deletions(-) rename components/prisma_management_api/actions/{create-postgres-database/create-postgres-database.mjs => create-database/create-database.mjs} (74%) rename components/prisma_management_api/actions/{delete-postgres-database/delete-postgres-database.mjs => delete-database/delete-database.mjs} (88%) diff --git a/components/prisma_management_api/README.md b/components/prisma_management_api/README.md index 746d5448e8d12..b6d9a3740daea 100644 --- a/components/prisma_management_api/README.md +++ b/components/prisma_management_api/README.md @@ -21,7 +21,7 @@ To use the Prisma Management API with Pipedream, you'll need to connect your Pri ### Project Management -#### Create Postgres Database +#### Create Database Creates a new Postgres database project via Prisma Management API. This action creates a complete project with database and provides connection string details in the response for immediate use. **Parameters:** @@ -39,7 +39,7 @@ Retrieves detailed information about a specific project including associated dat **Parameters:** - `projectId` (string, required): The ID of the project to retrieve -#### Delete Postgres Database +#### Delete Database Removes an entire Postgres database project and all associated resources. **Parameters:** diff --git a/components/prisma_management_api/actions/create-database-connection-string/create-database-connection-string.mjs b/components/prisma_management_api/actions/create-database-connection-string/create-database-connection-string.mjs index 9516f40f4f392..b3a01073e0f48 100644 --- a/components/prisma_management_api/actions/create-database-connection-string/create-database-connection-string.mjs +++ b/components/prisma_management_api/actions/create-database-connection-string/create-database-connection-string.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "Create Database Connection String", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-create-database-connection-string", description: "Creates a new connection string for an existing database via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", diff --git a/components/prisma_management_api/actions/create-postgres-database/create-postgres-database.mjs b/components/prisma_management_api/actions/create-database/create-database.mjs similarity index 74% rename from components/prisma_management_api/actions/create-postgres-database/create-postgres-database.mjs rename to components/prisma_management_api/actions/create-database/create-database.mjs index f5ded1ab3edfd..ba861e95e8d0e 100644 --- a/components/prisma_management_api/actions/create-postgres-database/create-postgres-database.mjs +++ b/components/prisma_management_api/actions/create-database/create-database.mjs @@ -1,9 +1,9 @@ import app from "../../prisma_management_api.app.mjs"; export default { - name: "Create Postgres Database", - version: "0.1.0", - key: "prisma_management_api-create-postgres-database", + name: "Create Database", + version: "1.0.0", + key: "prisma_management_api-create-database", description: "Creates a new Postgres database project via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", props: { @@ -14,16 +14,9 @@ export default { description: "The name of the Postgres database project to create", }, region: { - type: "string", - label: "Region", - description: "The region where the database should be created", - options: [ - "us-east-1", - "us-west-1", - "eu-west-3", - "eu-central-1", - "ap-northeast-1", - "ap-southeast-1", + propDefinition: [ + app, + "region", ], default: "us-east-1", }, diff --git a/components/prisma_management_api/actions/create-new-database-in-existing-project/create-new-database-in-existing-project.mjs b/components/prisma_management_api/actions/create-new-database-in-existing-project/create-new-database-in-existing-project.mjs index bd617e4f1bea7..73b9e19530654 100644 --- a/components/prisma_management_api/actions/create-new-database-in-existing-project/create-new-database-in-existing-project.mjs +++ b/components/prisma_management_api/actions/create-new-database-in-existing-project/create-new-database-in-existing-project.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "Create New Database in Existing Project", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-create-new-database-in-existing-project", description: "Create a new database in an existing Prisma project. Requires Project ID. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", @@ -14,18 +14,10 @@ export default { description: "The ID of the project where the database should be created", }, region: { - type: "string", - label: "Region", - description: "The AWS region where the database should be created", - options: [ - "us-east-1", - "us-west-1", - "eu-west-3", - "eu-central-1", - "ap-northeast-1", - "ap-southeast-1", + propDefinition: [ + app, + "region", ], - optional: true, }, isDefault: { type: "boolean", @@ -36,8 +28,13 @@ export default { }, }, async run({ $ }) { - const data = {}; - if (this.region) data.region = this.region; + if (!this.region) { + throw new Error("Region is required for creating a database"); + } + + const data = { + region: this.region, + }; if (this.isDefault !== undefined) data.default = this.isDefault; const response = await this.app.createDatabase({ diff --git a/components/prisma_management_api/actions/delete-database-by-database-id/delete-database-by-database-id.mjs b/components/prisma_management_api/actions/delete-database-by-database-id/delete-database-by-database-id.mjs index 4c4212f3abf16..6abf13e5d175d 100644 --- a/components/prisma_management_api/actions/delete-database-by-database-id/delete-database-by-database-id.mjs +++ b/components/prisma_management_api/actions/delete-database-by-database-id/delete-database-by-database-id.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "Delete Database by Database ID", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-delete-database-by-database-id", description: "Delete a specific database by Database ID via Prisma Management API. This action is irreversible. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", diff --git a/components/prisma_management_api/actions/delete-database-connection-string/delete-database-connection-string.mjs b/components/prisma_management_api/actions/delete-database-connection-string/delete-database-connection-string.mjs index edcf215c42adc..eed0b5a4417a7 100644 --- a/components/prisma_management_api/actions/delete-database-connection-string/delete-database-connection-string.mjs +++ b/components/prisma_management_api/actions/delete-database-connection-string/delete-database-connection-string.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "Delete Database Connection String", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-delete-database-connection-string", description: "Deletes a specific database connection string via Prisma Management API. This action is irreversible. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", diff --git a/components/prisma_management_api/actions/delete-postgres-database/delete-postgres-database.mjs b/components/prisma_management_api/actions/delete-database/delete-database.mjs similarity index 88% rename from components/prisma_management_api/actions/delete-postgres-database/delete-postgres-database.mjs rename to components/prisma_management_api/actions/delete-database/delete-database.mjs index f41aece4a533c..8391c34143907 100644 --- a/components/prisma_management_api/actions/delete-postgres-database/delete-postgres-database.mjs +++ b/components/prisma_management_api/actions/delete-database/delete-database.mjs @@ -1,9 +1,9 @@ import app from "../../prisma_management_api.app.mjs"; export default { - name: "Delete Postgres Database", - version: "0.1.0", - key: "prisma_management_api-delete-postgres-database", + name: "Delete Database", + version: "1.0.0", + key: "prisma_management_api-delete-database", description: "Deletes a Postgres database project via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", props: { diff --git a/components/prisma_management_api/actions/get-database-details/get-database-details.mjs b/components/prisma_management_api/actions/get-database-details/get-database-details.mjs index b12898df4f3d8..996383f339c1e 100644 --- a/components/prisma_management_api/actions/get-database-details/get-database-details.mjs +++ b/components/prisma_management_api/actions/get-database-details/get-database-details.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "Get Database details", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-get-database-details", description: "Get database details of a particular Prisma Postgres database via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", diff --git a/components/prisma_management_api/actions/get-postgres-regions/get-postgres-regions.mjs b/components/prisma_management_api/actions/get-postgres-regions/get-postgres-regions.mjs index 15bc746a1a52a..1ac6db5c5bf27 100644 --- a/components/prisma_management_api/actions/get-postgres-regions/get-postgres-regions.mjs +++ b/components/prisma_management_api/actions/get-postgres-regions/get-postgres-regions.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "Get Prisma Postgres Regions", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-get-postgres-regions", description: "Retrieves a list of all available regions where Prisma Postgres databases can be deployed. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", diff --git a/components/prisma_management_api/actions/get-project-details/get-project-details.mjs b/components/prisma_management_api/actions/get-project-details/get-project-details.mjs index 5ef01a39d4c3c..2b760b9fd3380 100644 --- a/components/prisma_management_api/actions/get-project-details/get-project-details.mjs +++ b/components/prisma_management_api/actions/get-project-details/get-project-details.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "Get Project details", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-get-project-details", description: "Get project details of a particular project in Prisma Workspace via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", diff --git a/components/prisma_management_api/actions/list-database-connection-strings/list-database-connection-strings.mjs b/components/prisma_management_api/actions/list-database-connection-strings/list-database-connection-strings.mjs index e1c42dfbff1d9..3b64745a1fc91 100644 --- a/components/prisma_management_api/actions/list-database-connection-strings/list-database-connection-strings.mjs +++ b/components/prisma_management_api/actions/list-database-connection-strings/list-database-connection-strings.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "List Database Connection Strings", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-list-database-connection-strings", description: "Retrieves a list of all connection strings for a specific database via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", diff --git a/components/prisma_management_api/actions/list-databases-from-project/list-databases-from-project.mjs b/components/prisma_management_api/actions/list-databases-from-project/list-databases-from-project.mjs index 785d7f09b06a9..55b65cfa68cbc 100644 --- a/components/prisma_management_api/actions/list-databases-from-project/list-databases-from-project.mjs +++ b/components/prisma_management_api/actions/list-databases-from-project/list-databases-from-project.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "List Databases from Project", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-list-databases-from-project", description: "Retrieves a list of all databases within a specific Prisma project. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", diff --git a/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs b/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs index f445f99604db9..734dd4f066ecc 100644 --- a/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs +++ b/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs @@ -2,7 +2,7 @@ import app from "../../prisma_management_api.app.mjs"; export default { name: "List Projects in Prisma Workspace", - version: "0.1.0", + version: "1.0.0", key: "prisma_management_api-list-projects-in-prisma-workspace", description: "List Projects in a Prisma Workspace via Prisma Management API. Supports pagination for large result sets. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", @@ -15,7 +15,12 @@ export default { }); if (response) { - const count = response.data?.length || 0; + const items = Array.isArray(response) + ? response + : Array.isArray(response?.data) + ? response.data + : []; + const count = items.length; $.export("$summary", `Successfully retrieved ${count} project${count !== 1 ? "s" : ""}`); } diff --git a/components/prisma_management_api/prisma_management_api.app.mjs b/components/prisma_management_api/prisma_management_api.app.mjs index 477f98fd60c5f..28dd9a2a71887 100644 --- a/components/prisma_management_api/prisma_management_api.app.mjs +++ b/components/prisma_management_api/prisma_management_api.app.mjs @@ -3,7 +3,23 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "prisma_management_api", - propDefinitions: {}, + propDefinitions: { + region: { + type: "string", + label: "Region", + description: "The region where the database should be created", + async options() { + const response = await this.listRegions(); + const regions = response?.data || []; + return regions + .filter((region) => !region.status || region.status === "available") + .map((region) => ({ + label: region.name || region.id, + value: region.id, + })); + }, + }, + }, methods: { _baseUrl() { return "https://api.prisma.io/v1"; From db2d7c502dfde8c49981aeab6cf3b3924cab4d65 Mon Sep 17 00:00:00 2001 From: Nurul Sundarani Date: Tue, 19 Aug 2025 14:29:31 +0530 Subject: [PATCH 4/4] docs: remove pagination reference from Prisma project listing description --- .../list-projects-in-prisma-workspace.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs b/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs index 734dd4f066ecc..0e0da4dc52d6a 100644 --- a/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs +++ b/components/prisma_management_api/actions/list-projects-in-prisma-workspace/list-projects-in-prisma-workspace.mjs @@ -4,7 +4,7 @@ export default { name: "List Projects in Prisma Workspace", version: "1.0.0", key: "prisma_management_api-list-projects-in-prisma-workspace", - description: "List Projects in a Prisma Workspace via Prisma Management API. Supports pagination for large result sets. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", + description: "List Projects in a Prisma Workspace via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)", type: "action", props: { app,