Handshake - shubham769/Python-data-cleaning GitHub Wiki

Overview

This page enumerates the API related to Fetch data to be used by users for visualization.

Purpose of this page is to define:

  1. API responsibilities
  2. API signatures
  3. Sample payload, response, potential error codes
  4. and where possible/necessary any high-level view of the call sequence

API

Request Signature

Method URI Description Response
GET /temperatureData?startTs=Long&endTs=Long&deviceId= String Get Device Data Status 200 - application/json

Common API Features

Type Params Description
Filter ?startTs=long&endTs=long&deviceId=string Filtering of results

Request Query Parameters

Query Parameter Format Notes
startTs Long Use the standard Long format (Optional)
endTs Long Use the standard Long format (Optional)
deviceId String Use the standard String format (Optional)

Response Signature

  • Status 200 - application/json Returns a JSON representation of a list of Monitoring Data

    Example
    [ 
                  { 
                        "device-id": "0x0131", 
                        "timestamp": "2018-08-31T21:33:56Z", 
                        "temperature": 64.2 
                   }, 
                  { 
                        "device-id": "0x0132", 
                        "timestamp": "2018-08-31T21:33:56Z", 
                        "temperature": 40.2 
                   } 
    ]
    
  • Status 404 - Returned if there is no content with the given deviceId or timestamp

    Example
    
                  { 
                        "error-code": "TP-404", 
                        "message": "No record found for provided deviceId" 
    
                   }
    
  • Status 422 - Returned if given deviceId is not in correct format.

    Example
    
                  { 
                        "error-code": "TP-422", 
                        "message": "Bad Request/ deviceId should start with alphabet followed by alphanumeric and length should be between 8 to 24." 
    
                   }
    
  • Status 422 - Returned if given start Timestamp is greater than end Timestamp.

    Example
    
                  { 
                        "error-code": "TP-422", 
                        "message": "Unprocessable entity, start Timestamp must be less than end Timestamp"
    
                   }
    

Validation

Variable Requirement
(startTs, endTs) startTs must be less than endTs
deviceId Must be a valid and existing deviceId

Sequence Diagram

Use the UML sequence macro in this section. You can leverage the https://www.websequencediagrams.com/ site for help creating the diagram

Samples

Successful - startTs is less than endTs

Use Case Request Response
User wants to get data from the service as expected (Assumption: Only 10 devices data to be sent) GET /data?startTs=1549779823&endTs=1549779860 200 OK

Successful - Valid Device Id

Use Case Request Response
User wants to get data from the service as expected (Assumption: Only 100 records to be sent) GET /data?deviceId=boiler1 200 OK

Invalid request

Ex. startTs > endTs and invalid deviceId.

All Sample Response Scenarios

DeviceId Start Timestamp End Timestamp Description(Error Responses)
Yes Yes Yes code 200 :The request has succeeded.
code 404 :No record found for request
code 422 :Unprocessable entity , Start Timestamp is greater than End Timestamp or invalid deviceId
Yes Yes No code 200 :The request has succeeded.
code 404 :No record found for request
code 422 :Unprocessable entity , invalid deviceId or Timestamp
Yes No Yes code 200 :The request has succeeded.
code 404 :No record found for request
code 422 :Unprocessable entity , invalid deviceId or Timestamp
Yes No No code 200 :The request has succeeded.
code 404 :No record found for request
code 422 :Unprocessable entity , invalid deviceId
No Yes Yes code 200 :The request has succeeded.
code 404 :No record found for request
code 422 :Unprocessable entity , Start Timestamp is greater than End Timestamp
No Yes No code 200 :The request has succeeded.
code 404 :No record found for request
code 422 :Unprocessable entity , invalid Timestamp
No No Yes code 200 :The request has succeeded.
code 404 :No record found for request
code 422 :Unprocessable entity , invalid Timestamp
No No No code 422 : Unprocessable entity
⚠️ **GitHub.com Fallback** ⚠️