Skip to content

Module: api_gateway

Tanmay Sawaji edited this page Feb 8, 2022 · 3 revisions

API Gateway is a gateway that separates the user interface from other microservices. The purpose of the gate is to validate incoming requests, routing requests to the backend services, and return an appropriate response to the client UI. The service exposes its endpoint to the following services:

  1. UI component
  2. DB middleware

The service will be running on port - 5000

Following are the endpoints exposed to

  1. UI component

GET /getAllInfo

Request:

    No parameters

Response:

{
    "station_name": ['DAN1', 'KABR', 'KABX', ...],
    "time": ['00:00:00 - 00:05:59', '00:06:00 - 00:11:59', ...],
    "property": [ 'Reflectivity']
}

GET /getAllStatus

Request:

{
    "user_email":"tanmaysawaji44@gmail.com
}

Response:

{
    "error_code": "0",
    "error_message": "Information retrieved",
    "request_details": [
        {
            "_id": "6201ae94a0aa8bcdb7ad97bf",
            "user_email": "tanmaysawaji44@gmail.com",
            "request_id": "DAN1_02022022_000000_002959_Reflectivity",
            "status": "0",
            "time_stamp": "1644277396",
            "property": "Reflectivity",
            "__v": 0
        }
    ]
}

POST /postNewRequest

Request:

{
    “station_name” : "DAN1",
    “date” : "02-02-2022", 
    “time” : ”00:00:00 - 00:29:59”,
    “user_email” : "tanmaysawaji44@gmail.com",
    “property” : "Reflectivity"
}

Response:

{
    "response_code": "0",
    "response_message": "Information retrieved",
    "data_dump": [
        {
            "_id": "6201ae94a0aa8bcdb7ad97bf",
            "user_email": "tanmaysawaji44@gmail.com",
            "request_id": "DAN1_02022022_000000_002959_Reflectivity",
            "status": "0",
            "time_stamp": "1644277396",
            "property": "Reflectivity",
            "__v": 0
        }
    ],
    "data_status": "true/false"
}

POST /getDataOfRequestID

Request:

{
    "request_id" : "KAKQ_02012022_003000_005959_Reflectivity",
    "user_email" : "tanmaysawaji44@gmail.com",
    "property" : "Reflectivity"
}

Response:

{
    "response_code": "0",
    "response_message": "Information retrieved",
    "data": [
        {
            "_id": "6201af9ba0aa8bcdb7ad97f1",
            "request_id": "KAKQ_02012022_003000_005959_Reflectivity",
            "start_time": "003000",
            "end_time": "005959",
            "__v": 0,
            "lat": {
                "_id": "6201af9ba0aa8bcdb7ad97f2",
                "parent_doc_ref": "6201af9ba0aa8bcdb7ad97f1",
                "lat": [[],[]....],
                "__v": 0
            },
            "long": {
                "_id": "6201af9ba0aa8bcdb7ad97f3",
                "parent_doc_ref": "6201af9ba0aa8bcdb7ad97f1",
                "long": [[],[]....],
                "__v": 0
            },
            "reflectivity": {
                "_id": "6201af9ba0aa8bcdb7ad97f4",
                "parent_doc_ref": "6201af9ba0aa8bcdb7ad97f1",
                "data": [[],[]....],
                "__v": 0
            }
        }
    ]
}
  1. DB Middleware
NOTE: All the endpoints are POST requests

POST /getAllStatus

Request:

{
    "user_email":"rishabh.jain53@gmail.com"
}

Response:

{
    "status": "success",
    "message": "Information retrieved",
    "requests": [
        {
            "_id": "6201ae94a0aa8bcdb7ad97bf",
            "user_email": "rishabh.jain53@gmail.com",
            "request_id": "DAN1_02022022_000000_002959_Reflectivity",
            "status": "0",
            "time_stamp": "1644277396",
            "property": "Reflectivity",
            "__v": 0
        }
    ]
}

POST /postCheckRequest

Request:

{
    "request_id":"DAN1_02022022_000000_002959_Reflectivity"
}

Response:

{
    "status": "success",
    "message": "Information retrieved",
    "requests": [
        {
            "_id": "6201ae94a0aa8bcdb7ad97bf",
            "user_email": "rishabh.jain53@gmail.com",
            "request_id": "DAN1_02022022_000000_002959_Reflectivity",
            "status": "0",
            "time_stamp": "1644277396",
            "property": "Reflectivity",
            "__v": 0
        }
    ],
    "data_status": "true/false"
}

data_status - 1. true - means the data for the request already exists in the database no need to download data from S3 2. false - data doesn't exist in the database

POST /postNewRequest

Request:

{
    "user_email": "rishabh.jain53@gmail.com",
    "request_id":"KAKQ_02022022_000000_002959_Reflectivity",
    "property":"reflectivity",
    "time_stamp":"1644090027"            
}

Response:

{
   status: "success/error",
   message: "Insertion successful/Insertion failed"
}

POST /getDataOfRequestID

Request:

{
    "request_id":"KAKQ_02012022_003000_005959_Reflectivity"
}

Response:

{
    "data": [
        {
            "_id": "6201af9ba0aa8bcdb7ad97f1",
            "request_id": "KAKQ_02012022_003000_005959_Reflectivity",
            "start_time": "003000",
            "end_time": "005959",
            "__v": 0,
            "lat": {
                "_id": "6201af9ba0aa8bcdb7ad97f2",
                "parent_doc_ref": "6201af9ba0aa8bcdb7ad97f1",
                "lat": [[],[]....],
                "__v": 0
            },
            "long": {
                "_id": "6201af9ba0aa8bcdb7ad97f3",
                "parent_doc_ref": "6201af9ba0aa8bcdb7ad97f1",
                "long": [[],[]....],
                "__v": 0
            },
            "reflectivity": {
                "_id": "6201af9ba0aa8bcdb7ad97f4",
                "parent_doc_ref": "6201af9ba0aa8bcdb7ad97f1",
                "data": [[],[]....],
                "__v": 0
            }
        }
    ]
}