Skip to content

Latest commit

 

History

History
320 lines (303 loc) · 6.51 KB

showcase.md

File metadata and controls

320 lines (303 loc) · 6.51 KB

Showcase

Use http://127.0.0.1:7000 in place of http://188.0.0.2:7000 if testing from host

0. Check if service is up

curl http://188.0.0.2:7000/

1. Check /summary endpoint with no data added (empty table)

curl http://188.0.0.2:7000/api/v1/iris/summary

Result:

{
  "petal_length": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "float"
  },
  "petal_width": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "float"
  },
  "sepal_length": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "float"
  },
  "sepal_width": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "float"
  },
  "species": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "str"
  }
}

2. Use /sync endpoint to pull, de-duplicate and store data

curl http://188.0.0.2:7000/api/v1/iris/sync

Result:

Inserted 147 rows.

3. Get summary again to verify that data has been inserted

curl http://188.0.0.2:7000/api/v1/iris/summary

Result:

{
  "petal_length": {
    "maximum": 6.9,
    "median": 4.4,
    "minimum": 1.0,
    "n_total_values": 147,
    "n_unique_values": 43,
    "type": "float"
  },
  "petal_width": {
    "maximum": 2.5,
    "median": 1.3,
    "minimum": 0.1,
    "n_total_values": 147,
    "n_unique_values": 22,
    "type": "float"
  },
  "sepal_length": {
    "maximum": 7.9,
    "median": 5.8,
    "minimum": 4.3,
    "n_total_values": 147,
    "n_unique_values": 35,
    "type": "float"
  },
  "sepal_width": {
    "maximum": 4.4,
    "median": 3.0,
    "minimum": 2.0,
    "n_total_values": 147,
    "n_unique_values": 23,
    "type": "float"
  },
  "species": {
    "n_total_values": 147,
    "n_unique_values": 3,
    "type": "str"
  }
}

4. Post new values in json format

curl -X POST http://188.0.0.2:7000/api/v1/iris -H "Content-Type: application/json" -d "[{\"petal_length\": 10, \"petal_width\": 20, \"sepal_length\": 30, \"sepal_width\": 40}, {\"petal_length\": 10, \"petal_width\": 20, \"sepal_length\": 30, \"sepal_width\": 40}]"

Result:

Inserted 2 rows.

5. Post new values in csv format

curl -X POST http://188.0.0.2:7000/api/v1/iris -H "Content-Type: text/csv" -d $'sepal_length,sepal_width,petal_length,petal_width,species\n5.1,3.5,1.4,0.2,setosa\n5.2,2.7,3.9,1.4,versicolor\n7.2,3.0,5.8,1.6,virginica'

Have to use $'csv-data-to-insert' (with single quotes!) format in bash curl for the \n characters to be sent as newlines, not literal \n.

Result:

Inserted 3 rows.

6. Post duplicates of existing values

curl -X POST http://188.0.0.2:7000/api/v1/iris -H "Content-Type: application/json" -d "[{\"petal_length\": 10, \"petal_width\": 20, \"sepal_length\": 30, \"sepal_width\": 40}, {\"petal_length\": 10, \"petal_width\": 20, \"sepal_length\": 30, \"sepal_width\": 40}]"

Result:

Inserted 2 rows.

7. Post duplicates of existing values by the /unique endpoint

curl -X POST http://188.0.0.2:7000/api/v1/iris/unique -H "Content-Type: application/json" -d "[{\"petal_length\": 10, \"petal_width\": 20, \"sepal_length\": 30, \"sepal_width\": 40}, {\"petal_length\": 10, \"petal_width\": 20, \"sepal_length\": 30, \"sepal_width\": 40}]"

Result:

Inserted 0 rows.

8. Get all

curl -sN http://188.0.0.2:7000/api/v1/iris/all | head --bytes 512

Result:

[
  {
    "petal_length": 1.7,
    "petal_width": 0.2,
    "sepal_length": 5.4,
    "sepal_width": 3.4,
    "species": "setosa"
  },
  {
    "petal_length": 4.6,
    "petal_width": 1.3,
    "sepal_length": 6.6,
    "sepal_width": 2.9,
    "species": "versicolor"
  },
  {
    "petal_length": 4.6,
    "petal_width": 1.4,
    "sepal_length": 6.1,
    "sepal_width": 3.0,
    "species": "versicolor"
  },
  {
    "petal_length": 1.4,
    "petal_width": 0.2,
    "sepal_length": 5.0,
    "sepal_width": 3.6,
    "sp

9. Get with 'where' filter

curl "http://188.0.0.2:7000/api/v1/iris?where=sepal_width>3.9&where=species%20IN%20(virginica,setosa)"

Result:

[
  {
    "petal_length": 1.5,
    "petal_width": 0.1,
    "sepal_length": 5.2,
    "sepal_width": 4.1,
    "species": "setosa"
  },
  {
    "petal_length": 1.5,
    "petal_width": 0.4,
    "sepal_length": 5.7,
    "sepal_width": 4.4,
    "species": "setosa"
  },
  {
    "petal_length": 1.2,
    "petal_width": 0.2,
    "sepal_length": 5.8,
    "sepal_width": 4.0,
    "species": "setosa"
  },
  {
    "petal_length": 1.4,
    "petal_width": 0.2,
    "sepal_length": 5.5,
    "sepal_width": 4.2,
    "species": "setosa"
  }
]

10. Delete with the same 'where' filter

curl -X DELETE "http://188.0.0.2:7000/api/v1/iris?where=sepal_width>3.9&where=species%20IN%20(virginica,setosa)"

Result:

Deleted 4 rows

11. Summary of current state

curl http://188.0.0.2:7000/api/v1/iris/summary

Result:

{
  "petal_length": {
    "maximum": 10.0,
    "median": 4.45,
    "minimum": 1.0,
    "n_total_values": 150,
    "n_unique_values": 44,
    "type": "float"
  },
  "petal_width": {
    "maximum": 20.0,
    "median": 1.4,
    "minimum": 0.1,
    "n_total_values": 150,
    "n_unique_values": 23,
    "type": "float"
  },
  "sepal_length": {
    "maximum": 30.0,
    "median": 5.85,
    "minimum": 4.3,
    "n_total_values": 150,
    "n_unique_values": 36,
    "type": "float"
  },
  "sepal_width": {
    "maximum": 40.0,
    "median": 3.0,
    "minimum": 2.0,
    "n_total_values": 150,
    "n_unique_values": 20,
    "type": "float"
  },
  "species": {
    "n_total_values": 150,
    "n_unique_values": 4,
    "type": "str"
  }
}

12. Delete using the /all endpoint

curl -X DELETE http://188.0.0.2:7000/api/v1/iris/all

Result:

Deleted 150 rows

13. Get summary to verify that all data is deleted

curl http://188.0.0.2:7000/api/v1/iris/summary

Result:

{
  "petal_length": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "float"
  },
  "petal_width": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "float"
  },
  "sepal_length": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "float"
  },
  "sepal_width": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "float"
  },
  "species": {
    "n_total_values": 0,
    "n_unique_values": 0,
    "type": "str"
  }
}

14. Test a request that raises an exception

curl "http://188.0.0.2:7000/api/v1/iris/sync?url=http://www.mr-wensleydale.com"

Result:

While connecting to Iris data url, ConnectionError occurred.