0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 09:14:46 +01:00
posthog/openapi/customer-data-pipeline.yaml
Harry Waye 9529cdd443
feat(cdp): add cdp destination APIs (#14994)
This commit adds the CDP destination APIs. Key changes include:

 - use `db-migrate` for migrations
 - jest for functional_tests (although I would be happy to use vitest or
   alternatives if we want to, I didn't want to change too much at once)
 - pnpm for package management
 - koajs for the server
 - Ajv for validation
 - A separate PostgreSQL logical database for the destination APIs
   persistence.

Things still to do:

 - add some delivery mechanism that takes events from Kafka and puts
   them to the destinations.
 - add CI
 - add to Helm Chart
 - add some method of authentication. I've added the API here but it
   might be that I just end up putting that in the main app in the end,
   depending on how much momentum there is to try out separating the API
   a bit, and the logistics of that.
2023-04-12 12:47:50 +01:00

373 lines
14 KiB
YAML

openapi: 3.0.0
info:
title: Customer Data Pipeline
description: |
The Customer Data Pipeline (CDP) is a service that allows users to
upload data to the platform. It allows users to specify `Destination`s
to which the data should be sent, and `Source`s from which the data is
sent from the client.
Destinations can be of type 'webhook' only currently. The CDP service
will send a POST request to the webhook URL with the data in the body
of the request. A basic transformation can be specified to transform
event data into the format required by the destination.
paths:
/api/projects/{project_id}/destination-types:
get:
summary: List destination types
description: |
List all destination types.
operationId: listDestinationTypes
parameters:
- name: project_id
in: path
description: ID of the project
required: true
schema:
type: string
responses:
'200':
description: List of destination types
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/DestinationType'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Project not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/projects/{project_id}/destinations:
get:
summary: List destinations
description: |
List all destinations for a project.
operationId: listDestinations
parameters:
- name: project_id
in: path
description: ID of the project
required: true
schema:
type: string
responses:
'200':
description: List of destinations
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Destination'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Project not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
summary: Create a destination
description: |
Create a destination for a project.
operationId: createDestination
parameters:
- name: project_id
in: path
description: ID of the project
required: true
schema:
type: string
requestBody:
description: Destination to create
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Destination'
responses:
'201':
description: Destination created
content:
application/json:
schema:
$ref: '#/components/schemas/Destination'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Project not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/projects/{project_id}/destinations/{destination_id}:
get:
summary: Get a destination
description: |
Get a destination for a project.
operationId: getDestination
parameters:
- name: project_id
in: path
description: ID of the project
required: true
schema:
type: string
- name: destination_id
in: path
description: ID of the destination
required: true
schema:
type: string
responses:
'200':
description: Destination
content:
application/json:
schema:
$ref: '#/components/schemas/Destination'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Project or destination not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
put:
summary: Update a destination
description: |
Update a destination for a project.
operationId: updateDestination
parameters:
- name: project_id
in: path
description: ID of the project
required: true
schema:
type: string
- name: destination_id
in: path
description: ID of the destination
required: true
schema:
type: string
requestBody:
description: Destination to update
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Destination'
responses:
'200':
description: Destination updated
content:
application/json:
schema:
$ref: '#/components/schemas/Destination'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Project or destination not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
summary: Delete a destination
description: |
Delete a destination for a project.
operationId: deleteDestination
parameters:
- name: project_id
in: path
description: ID of the project
required: true
schema:
type: string
- name: destination_id
in: path
description: ID of the destination
required: true
schema:
type: string
responses:
'204':
description: Destination deleted
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Project or destination not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
DestinationType:
type: object
properties:
id:
type: string
description: ID of the destination type
name:
type: string
description: Name of the destination type
description:
type: string
description: Description of the destination type
created_at:
type: string
format: date-time
description: Date and time when the destination type was created
updated_at:
type: string
format: date-time
description: Date and time when the destination type was updated
Destination:
type: object
properties:
id:
type: string
description: ID of the destination
type:
type: string
description: Type of the destination
name:
type: string
description: Name of the destination
description:
type: string
description: Description of the destination
created_at:
type: string
format: date-time
description: Date and time when the destination was created
updated_at:
type: string
format: date-time
description: Date and time when the destination was updated
Error:
type: object
properties:
message:
type: string
description: Error message