Skip to content

Commit 3aee12f

Browse files
authored
Merging pull request #18092
* feat: add Prisma Management API integration * docs: update authentication token references from integration to service token * chore: bump component versions to 1.0.0 and add region prop definition for database creation * docs: remove pagination reference from Prisma project listing description
1 parent 7b39a4f commit 3aee12f

File tree

15 files changed

+679
-4
lines changed

15 files changed

+679
-4
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Prisma Management API
2+
3+
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.
4+
5+
## Overview
6+
7+
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.
8+
9+
With this integration, you can:
10+
11+
- **Automate Database Provisioning**: Automatically create new Postgres database projects with proper regional distribution
12+
- **Manage Connection Strings**: Generate and manage secure connection strings for your applications
13+
- **Monitor Resources**: List and inspect databases, projects, and connection details across your workspace
14+
- **Streamline Cleanup**: Systematically remove databases and connection strings when no longer needed
15+
16+
## Getting Started
17+
18+
To use the Prisma Management API with Pipedream, you'll need to connect your Prisma account and obtain an API integration token.
19+
20+
## Actions
21+
22+
### Project Management
23+
24+
#### Create Database
25+
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.
26+
27+
**Parameters:**
28+
- `name` (string, required): The name of the Postgres database project to create
29+
- `region` (string, optional): The region where the database should be created (default: us-east-1)
30+
31+
**Available regions:** us-east-1, us-west-1, eu-west-3, eu-central-1, ap-northeast-1, ap-southeast-1
32+
33+
#### List Projects in Prisma Workspace
34+
Retrieves all projects within your Prisma workspace.
35+
36+
#### Get Project Details
37+
Retrieves detailed information about a specific project including associated databases and configuration.
38+
39+
**Parameters:**
40+
- `projectId` (string, required): The ID of the project to retrieve
41+
42+
#### Delete Database
43+
Removes an entire Postgres database project and all associated resources.
44+
45+
**Parameters:**
46+
- `projectId` (string, required): The ID of the project to delete
47+
48+
### Database Management
49+
50+
#### Create New Database in Existing Project
51+
Adds a new database to an existing Prisma project.
52+
53+
**Parameters:**
54+
- `projectId` (string, required): The ID of the project where the database should be created
55+
- `region` (string, optional): The region for the database
56+
- `isDefault` (boolean, optional): Whether to set this as the default database for the project
57+
58+
#### List Databases from Project
59+
Retrieves all databases within a specific project.
60+
61+
**Parameters:**
62+
- `projectId` (string, required): The ID of the project
63+
64+
#### Get Database Details
65+
Retrieves detailed information about a specific Prisma Postgres database.
66+
67+
**Parameters:**
68+
- `databaseId` (string, required): The ID of the database
69+
70+
#### Delete Database by Database ID
71+
Removes a specific database by its ID.
72+
73+
**Parameters:**
74+
- `databaseId` (string, required): The ID of the database to delete
75+
76+
### Connection String Management
77+
78+
#### Create Database Connection String
79+
Generates a new connection string for database access.
80+
81+
**Parameters:**
82+
- `databaseId` (string, required): The ID of the database
83+
- `name` (string, required): A descriptive name for the connection
84+
85+
#### List Database Connection Strings
86+
Retrieves all connection strings for a specific database.
87+
88+
**Parameters:**
89+
- `databaseId` (string, required): The ID of the database
90+
91+
#### Delete Database Connection String
92+
Removes a specific connection string.
93+
94+
**Parameters:**
95+
- `connectionId` (string, required): The ID of the connection to delete
96+
97+
### Utilities
98+
99+
#### Get Prisma Postgres Regions
100+
Retrieves the list of available regions for Prisma Postgres deployment.
101+
102+
## Authentication
103+
104+
This integration uses API Token authentication. You'll need to provide your Prisma Management API Service token when configuring the connection in Pipedream.
105+
106+
To obtain your API token:
107+
1. Log in to your Prisma account
108+
2. Navigate to your workspace settings
109+
3. Generate a new Service Token
110+
4. Copy the token for use in Pipedream
111+
112+
## API Documentation
113+
114+
For complete API documentation and additional details, visit the [Prisma Management API Documentation](https://www.prisma.io/docs/postgres/introduction/management-api).
115+
116+
## Example Workflows
117+
118+
### Automated Database Setup for New Projects
119+
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.
120+
121+
### Database Cleanup Automation
122+
Schedule periodic cleanup of unused databases and connection strings to maintain security and reduce costs.
123+
124+
### Multi-Region Database Deployment
125+
Create databases across multiple regions for improved performance and redundancy based on your application's geographic distribution.
126+
127+
## Support
128+
129+
For issues specific to the Prisma Management API, refer to the [official documentation](https://www.prisma.io/docs/postgres/introduction/management-api).
130+
131+
For Pipedream-related questions, visit the [Pipedream documentation](https://pipedream.com/docs) or community forums.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../prisma_management_api.app.mjs";
2+
3+
export default {
4+
name: "Create Database Connection String",
5+
version: "1.0.0",
6+
key: "prisma_management_api-create-database-connection-string",
7+
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)",
8+
type: "action",
9+
props: {
10+
app,
11+
databaseId: {
12+
type: "string",
13+
label: "Database ID",
14+
description: "The ID of the database to create a connection string for",
15+
},
16+
name: {
17+
type: "string",
18+
label: "Connection Name",
19+
description: "A descriptive name for the connection string",
20+
},
21+
},
22+
async run({ $ }) {
23+
const response = await this.app.createConnectionString({
24+
$,
25+
databaseId: this.databaseId,
26+
data: {
27+
name: this.name,
28+
},
29+
});
30+
31+
if (response) {
32+
$.export("$summary", `Successfully created connection string for database ${this.databaseId}${response.id ? ` with connection ID ${response.id}` : ""}`);
33+
}
34+
35+
return response;
36+
},
37+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import app from "../../prisma_management_api.app.mjs";
2+
3+
export default {
4+
name: "Create Database",
5+
version: "1.0.0",
6+
key: "prisma_management_api-create-database",
7+
description: "Creates a new Postgres database project via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)",
8+
type: "action",
9+
props: {
10+
app,
11+
name: {
12+
type: "string",
13+
label: "Project Name",
14+
description: "The name of the Postgres database project to create",
15+
},
16+
region: {
17+
propDefinition: [
18+
app,
19+
"region",
20+
],
21+
default: "us-east-1",
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.app.createProject({
26+
$,
27+
data: {
28+
name: this.name,
29+
region: this.region,
30+
},
31+
});
32+
33+
if (response) {
34+
const projectId = response.data?.id;
35+
const databaseId = response.data?.database?.id;
36+
37+
let summary = `Successfully created Postgres database project "${this.name}"`;
38+
if (projectId) {
39+
summary += ` with Project ID ${projectId}`;
40+
}
41+
if (databaseId) {
42+
summary += ` and Database ID ${databaseId}`;
43+
}
44+
45+
$.export("$summary", summary);
46+
}
47+
48+
return response;
49+
},
50+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import app from "../../prisma_management_api.app.mjs";
2+
3+
export default {
4+
name: "Create New Database in Existing Project",
5+
version: "1.0.0",
6+
key: "prisma_management_api-create-new-database-in-existing-project",
7+
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)",
8+
type: "action",
9+
props: {
10+
app,
11+
projectId: {
12+
type: "string",
13+
label: "Project ID",
14+
description: "The ID of the project where the database should be created",
15+
},
16+
region: {
17+
propDefinition: [
18+
app,
19+
"region",
20+
],
21+
},
22+
isDefault: {
23+
type: "boolean",
24+
label: "Set as Default Database",
25+
description: "Whether to set this database as the default for the project",
26+
optional: true,
27+
default: false,
28+
},
29+
},
30+
async run({ $ }) {
31+
if (!this.region) {
32+
throw new Error("Region is required for creating a database");
33+
}
34+
35+
const data = {
36+
region: this.region,
37+
};
38+
if (this.isDefault !== undefined) data.default = this.isDefault;
39+
40+
const response = await this.app.createDatabase({
41+
$,
42+
projectId: this.projectId,
43+
data,
44+
});
45+
46+
if (response) {
47+
$.export("$summary", `Successfully created database in project ${this.projectId}${response.id ? ` with ID ${response.id}` : ""}`);
48+
}
49+
50+
return response;
51+
},
52+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import app from "../../prisma_management_api.app.mjs";
2+
3+
export default {
4+
name: "Delete Database by Database ID",
5+
version: "1.0.0",
6+
key: "prisma_management_api-delete-database-by-database-id",
7+
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)",
8+
type: "action",
9+
props: {
10+
app,
11+
databaseId: {
12+
type: "string",
13+
label: "Database ID",
14+
description: "The ID of the database to delete",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.deleteDatabase({
19+
$,
20+
databaseId: this.databaseId,
21+
});
22+
23+
if (response || response === null) {
24+
$.export("$summary", `Successfully deleted database with ID ${this.databaseId}`);
25+
}
26+
27+
return {
28+
success: true,
29+
databaseId: this.databaseId,
30+
message: "Database deleted successfully",
31+
};
32+
},
33+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import app from "../../prisma_management_api.app.mjs";
2+
3+
export default {
4+
name: "Delete Database Connection String",
5+
version: "1.0.0",
6+
key: "prisma_management_api-delete-database-connection-string",
7+
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)",
8+
type: "action",
9+
props: {
10+
app,
11+
connectionId: {
12+
type: "string",
13+
label: "Connection ID",
14+
description: "The ID of the database connection to delete",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.deleteConnectionString({
19+
$,
20+
connectionId: this.connectionId,
21+
});
22+
23+
if (response || response === null) {
24+
$.export("$summary", `Successfully deleted database connection with ID ${this.connectionId}`);
25+
}
26+
27+
return {
28+
success: true,
29+
connectionId: this.connectionId,
30+
message: "Database connection deleted successfully",
31+
};
32+
},
33+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import app from "../../prisma_management_api.app.mjs";
2+
3+
export default {
4+
name: "Delete Database",
5+
version: "1.0.0",
6+
key: "prisma_management_api-delete-database",
7+
description: "Deletes a Postgres database project via Prisma Management API. [See docs here](https://www.prisma.io/docs/postgres/introduction/management-api)",
8+
type: "action",
9+
props: {
10+
app,
11+
projectId: {
12+
type: "string",
13+
label: "Project ID",
14+
description: "The ID of the Postgres database project to delete",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.deleteProject({
19+
$,
20+
projectId: this.projectId,
21+
});
22+
23+
if (response || response === null) {
24+
$.export("$summary", `Successfully deleted Postgres database project with ID ${this.projectId}`);
25+
}
26+
27+
return {
28+
success: true,
29+
projectId: this.projectId,
30+
message: "Database project deleted successfully",
31+
};
32+
},
33+
};

0 commit comments

Comments
 (0)