This Lambda function serves as an API handler for managing events, flows, and elements in a DynamoDB-based event store. It supports CRUD operations via HTTP methods and routes.
Ensure you have the following prerequisites:
- AWS Lambda
- AWS DynamoDB
- AWS API Gateway or Lambda URL
The following routes are supported by the handler:
- GET /events: Retrieve all events.
- GET /flows: Retrieve all flows.
- GET /elements: Retrieve all elements across all flows.
- GET /elements/{flowName}: Retrieve elements for a specific flow.
- GET /event/{eventName}: Retrieve details of a specific event.
- GET /flow/{flowId}: Retrieve details of a specific flow.
- GET /element/{flowName}/{elementId}: Retrieve details of a specific element within a specific flow.
- POST /event: Create a new event.
- POST /flow: Create a new flow.
- POST /element: Create a new element.
- DELETE /flow/{flowId}: Delete a specific flow.
Request:
curl -X GET "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/events" \
-H "Content-Type: application/json"
Response:
[
{
"eventName": "FiveSecVideoFragEvent",
"eventSchema": { ... }
},
{
"eventName": "OneMinFiveSecVideoFragEvent",
"eventSchema": { ... }
}
]
Request:
curl -X GET "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/flows" \
-H "Content-Type: application/json"
Response:
[
{
"flowId": "ExampleFlow",
"data": { ... }
},
{
"flowId": "AnotherFlow",
"data": { ... }
}
]
Request:
curl -X GET "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/elements" \
-H "Content-Type: application/json"
Response:
[
{
"elementId": "FiveSecVideoFragCounter",
"flowName": "ExampleFlow",
"elementDetails": { ... }
},
{
"elementId": "OneMinFiveSecVideoFragExtractor",
"flowName": "ExampleFlow",
"elementDetails": { ... }
}
]
Request:
curl -X GET "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/elements/ExampleFlow" \
-H "Content-Type: application/json"
Response:
[
{
"elementId": "FiveSecVideoFragCounter",
"elementDetails": { ... }
},
{
"elementId": "OneMinFiveSecVideoFragExtractor",
"elementDetails": { ... }
}
]
Request:
curl -X GET "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/event/FiveSecVideoFragEvent" \
-H "Content-Type: application/json"
Response:
{
"eventName": "FiveSecVideoFragEvent",
"eventSchema": { ... }
}
Request:
curl -X GET "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/flow/ExampleFlow" \
-H "Content-Type: application/json"
Response:
{
"nodes": [
{
"id": "Get Eventbridge-1716717420333",
"label": "Get Eventbridge"
},
{
"id": "Get Eventbridge-1716717423334",
"label": "Get Eventbridge"
},
{
"id": "OpenAI-1716717747543",
"label": "OpenAI"
}
],
"edges": [
{
"id": "reactflow__edge-Get Eventbridge-1716717423334-OpenAI-1716717747543",
"source": "Get Eventbridge-1716717423334",
"target": "OpenAI-1716717747543"
}
]
}
Request:
curl -X GET "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/element/ExampleFlow/FiveSecVideoFragCounter" \
-H "Content-Type: application/json"
Response:
{
"elementId": "FiveSecVideoFragCounter",
"elementDetails": { ... }
}
Request:
curl -X POST "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/event" \
-H "Content-Type: application/json" \
-d '{
"eventName": "NewEvent",
"eventSchema": { ... }
}'
Response:
{
"statusCode": 201,
"body": "Event created"
}
Request:
curl -X POST "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/flow" \
-H "Content-Type: application/json" \
-d '{
"flowName": "NewFlow",
"data": { ... }
}'
Response:
{
"statusCode": 201,
"body": { "flowId": "new-flow-id" }
}
Request:
curl -X POST "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/element" \
-H "Content-Type: application/json" \
-d '{
"flowName": "ExampleFlow",
"elementId": "NewElement",
"elementDetails": { ... }
}'
Response:
{
"statusCode": 201,
"body": "Element created"
}
Request:
curl -X DELETE "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/flow/ExampleFlow" \
-H "Content-Type: application/json"
Response:
{
"statusCode": 200,
"body": "Flow deleted"
}
- Ensure to replace
https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws
with your actual API endpoint. - Adjust CORS headers as per your domain requirements.