-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add Prisma Postgres Actions for Database Provisioning, Management & Cleanup via Prisma Management API #18092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8b287b7
feat: add Prisma Management API integration
nurul3101 1b4761b
Merge branch 'PipedreamHQ:master' into master
nurul3101 c17df92
docs: update authentication token references from integration to serv…
nurul3101 42baf81
chore: bump component versions to 1.0.0 and add region prop definitio…
nurul3101 ee8d69e
Merge branch 'master' into master
nurul3101 1f3a259
Merge branch 'master' into master
nurul3101 db2d7c5
docs: remove pagination reference from Prisma project listing descrip…
nurul3101 8897867
Merge branch 'master' of https://github.com/nurul3101/pipedream
nurul3101 0eae3a3
Merge branch 'master' into master
nurul3101 0d164bb
Merge branch 'master' into master
nurul3101 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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 Database | ||
Removes an entire Postgres database project and all associated resources. | ||
|
||
**Parameters:** | ||
- `projectId` (string, required): The ID of the project to delete | ||
|
||
nurul3101 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### 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 regions for Prisma Postgres deployment. | ||
|
||
## Authentication | ||
|
||
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 Service 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. |
37 changes: 37 additions & 0 deletions
37
...ement_api/actions/create-database-connection-string/create-database-connection-string.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import app from "../../prisma_management_api.app.mjs"; | ||
|
||
export default { | ||
name: "Create Database Connection String", | ||
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", | ||
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; | ||
}, | ||
}; |
50 changes: 50 additions & 0 deletions
50
components/prisma_management_api/actions/create-database/create-database.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import app from "../../prisma_management_api.app.mjs"; | ||
|
||
export default { | ||
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", | ||
nurul3101 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
props: { | ||
app, | ||
name: { | ||
type: "string", | ||
label: "Project Name", | ||
description: "The name of the Postgres database project to create", | ||
}, | ||
region: { | ||
propDefinition: [ | ||
app, | ||
"region", | ||
], | ||
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; | ||
}, | ||
}; |
52 changes: 52 additions & 0 deletions
52
...tions/create-new-database-in-existing-project/create-new-database-in-existing-project.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import app from "../../prisma_management_api.app.mjs"; | ||
|
||
export default { | ||
name: "Create New Database in Existing Project", | ||
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", | ||
props: { | ||
app, | ||
projectId: { | ||
type: "string", | ||
label: "Project ID", | ||
description: "The ID of the project where the database should be created", | ||
}, | ||
region: { | ||
propDefinition: [ | ||
app, | ||
"region", | ||
], | ||
}, | ||
isDefault: { | ||
type: "boolean", | ||
label: "Set as Default Database", | ||
description: "Whether to set this database as the default for the project", | ||
optional: true, | ||
default: false, | ||
}, | ||
nurul3101 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
async run({ $ }) { | ||
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({ | ||
$, | ||
projectId: this.projectId, | ||
data, | ||
}); | ||
|
||
if (response) { | ||
$.export("$summary", `Successfully created database in project ${this.projectId}${response.id ? ` with ID ${response.id}` : ""}`); | ||
} | ||
|
||
return response; | ||
}, | ||
}; |
33 changes: 33 additions & 0 deletions
33
..._management_api/actions/delete-database-by-database-id/delete-database-by-database-id.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import app from "../../prisma_management_api.app.mjs"; | ||
|
||
export default { | ||
name: "Delete Database by Database ID", | ||
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)", | ||
nurul3101 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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", | ||
}; | ||
}, | ||
}; |
33 changes: 33 additions & 0 deletions
33
...ement_api/actions/delete-database-connection-string/delete-database-connection-string.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import app from "../../prisma_management_api.app.mjs"; | ||
|
||
export default { | ||
name: "Delete Database Connection String", | ||
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", | ||
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", | ||
}; | ||
}, | ||
}; |
33 changes: 33 additions & 0 deletions
33
components/prisma_management_api/actions/delete-database/delete-database.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import app from "../../prisma_management_api.app.mjs"; | ||
|
||
export default { | ||
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", | ||
nurul3101 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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", | ||
}; | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.