Default Thresholds

Base route: /api/defaultThreshold

📚 Read more about how User Thresholds and Default Thresholds are used in the Back-end Server Architecture Thresholds documentation.

Table of contents

  1. /createDefaultThreshold
    1. Request Schema
    2. Sample Request
    3. Response Schema
    4. Sample Success Response
    5. Fail Response
    6. /updateDefaultThreshold
    7. Request Schema
    8. Sample Request
    9. Response Schema
    10. Sample Success Response
    11. Fail Response
  2. /deleteDefaultThreshold
    1. Request Schema
    2. Sample Request
    3. Response Schema
    4. Sample Success Response
    5. Fail Response
  3. /getAllDefaultThresholds
    1. Response Schema
    2. Sample Success Response
    3. Fail Response
    4. /getSingleDefaultThreshold
    5. Request Schema
    6. Sample Request
    7. Response Schema
    8. Sample Success Response
    9. Fail Response

/createDefaultThreshold

Description Create a default threshold document in the database.
HTTP Verb POST
Success Codes 200
Failure Codes 400, 500

Request Schema

{
    "metric": string (a valid metric code),
    "defaultMin": number,
    "defaultMax": number
}

Sample Request

{
    "metric": "do",
    "defaultMin": 60,
    "defaultMax": 70
}

Response Schema

{
    "_id": string,
    "metric": string,
    "defaultMin": number,
    "defaultMax": number
}

Sample Success Response

{
    "text": {
        "metric": "dissolvedOxygen",
        "defaultMin": 60,
        "defaultMax": 70,
        "_id": "644b12f36f6b221f921ba2c7",
        "__v": 0
    }
}

Fail Response

Failure Code 400:

{ message: "Invalid request: metric, default minimum and default maximum values are required." }

Failure Code 500:

{ message: "There was an error with the request." }

/updateDefaultThreshold

Description Update a default threshold document stored in the database.
HTTP Verb PUT
Success Codes 200
Failure Codes 400, 500

Request Schema

{
    "metric": string,
    "defaultMin": number,
    "defaultMax": number
}

Sample Request

{
    "metric": "do",
    "defaultMin": 900,
    "defaultMax": 1000
}

Response Schema

{
    "_id": string,
    "metric": string,
    "defaultMin": number,
    "defaultMax": number
}

Sample Success Response

{
    "text": {
        "_id": "644b12f36f6b221f921ba2c7",
        "metric": "dissolvedOxygen",
        "defaultMin": 900,
        "defaultMax": 1000,
        "__v": 0
    }
}

Fail Response

Failure Code 400:

{ 
    message: "Invalid request: metric value and at least one of default minimum, default maximum values (defaultMax > defaultMin) are required." 
}

Failure Code 500:

{ message: "There was an error with the request." }

/deleteDefaultThreshold

Description Delete a default threshold document stored in the database.
HTTP Verb DELETE
Success Codes 200
Failure Codes 400, 500

Request Schema

{
    "metric": string
}

Sample Request

{
    "metric": "dissolvedOxygen"
}

Response Schema

Return deleted document.

{
    "_id": string,
    "metric": string,
    "defaultMin": number,
    "defaultMax": number
}

Sample Success Response

{
    "text": {
        "_id": "644b12f36f6b221f921ba2c7",
        "metric": "dissolvedOxygen",
        "defaultMin": 900,
        "defaultMax": 1000,
        "__v": 0
    }
}

Fail Response

Failure Code 400:

{ message: "Invalid request: metric is required." }

Failure Code 500:

{ message: "There was an error with the request." }

/getAllDefaultThresholds

Description Get all default threshold documents stored in the database.
HTTP Verb GET
Success Codes 200
Failure Codes 500
Request Schema Endpoint does not expect a request body or parameters.
Sample Request Endpoint does not expect a request body or parameters.

Response Schema

Response is array of default threshold documents stored in the database.

[
    {
        "_id": string,
        "metric": string,
        "defaultMin": number,
        "defaultMax": number
   },
    {
        "_id": string,
        "metric": string,
        "defaultMin": number,
        "defaultMax": number
   }
]

Sample Success Response

{
    "text": [
        {
            "_id": "6418eabe22a59781f4a36c76",
            "metric": "waterLevel",
            "defaultMin": 112,
            "defaultMax": 350,
            "__v": 0
        },
        {
            "_id": "6418ead722a59781f4a36c78",
            "metric": "electricalConductivity",
            "defaultMin": 5,
            "defaultMax": 10,
            "__v": 0
        }
    ]
}

Fail Response

Failure Code 500

{ message: "There was an error with the request." }

/getSingleDefaultThreshold

Description Get a default threshold document stored in the database.
HTTP Verb GET
Success Codes 200
Failure Codes 400, 500
Request Schema Endpoint does not expect a request body or parameters.
Sample Request Endpoint does not expect a request body or parameters.

Request Schema

{
    "metric": string
}

Sample Request

{
    "metric": "do"
}

Response Schema

{
    "_id": string,
    "metric": string,
    "defaultMin": number,
    "defaultMax": number
}

Sample Success Response

{
    "text": {
        "_id": "644b277a35869a94d14ea5e5",
        "metric": "dissolvedOxygen",
        "defaultMin": 60,
        "defaultMax": 70,
        "__v": 0
    }
}

Fail Response

Failure Code 400:

{ message: "Invalid request: metric is required." }

Failure Code 500:

{ message: "There was an error with the request." }