Giter VIP home page Giter VIP logo

events's Introduction

Event Store API Handler

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.

Setup

Ensure you have the following prerequisites:

  • AWS Lambda
  • AWS DynamoDB
  • AWS API Gateway or Lambda URL

Routes

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 and Response Examples

GET /events

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": { ... }
    }
]

GET /flows

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": { ... }
    }
]

GET /elements

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": { ... }
    }
]

GET /elements/{flowName}

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": { ... }
    }
]

GET /event/{eventName}

Request:

curl -X GET "https://fnm5fxxy2vahrcele6g3akqn5y0spper.lambda-url.us-east-1.on.aws/event/FiveSecVideoFragEvent" \
     -H "Content-Type: application/json"

Response:

{
    "eventName": "FiveSecVideoFragEvent",
    "eventSchema": { ... }
}

GET /flow/{flowId}

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"
        }
    ]
}

GET /element/{flowName}/{elementId}

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": { ... }
}

POST /event

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"
}

POST /flow

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" }
}

POST /element

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"
}

DELETE /flow/{flowId}

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"
}

Notes

  • 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.

events's People

Contributors

dschwartzi avatar mobilinq avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.