Invoke example:
cat input.json | python nest.py currency country city
Testing commands:
python -m unittest src.tests.test_restructure
python -m unittest src.tests.test_validators
-
pip install -r requirements.txt
-
hug -f server.py
-
cat body_input.json | http --auth serban:gron-drunt-crisp POST :8000/restructure
ORcat huge.json | http --auth serban:gron-drunt-crisp POST :8000/restructure
This POST is not exactly non-idempotent, but i couldn't figure out a more RESTful way of implementing this
curl --location --request POST 'http://127.0.0.1:8000/restructure' \
--header 'Authorization: Basic c2VyYmFuOmdyb24tZHJ1bnQtY3Jpc3A==' \
--header 'Content-Type: application/json' \
--data-raw '{
"json": [
{
"country": "US",
"city": "Boston",
"currency": "USD",
"amount": 100
},
{
"country": "FR",
"city": "Paris",
"currency": "EUR",
"amount": 20
},
{
"country": "FR",
"city": "Lyon",
"currency": "EUR",
"amount": 11.4
},
{
"country": "ES",
"city": "Madrid",
"currency": "EUR",
"amount": 8.9
},
{
"country": "UK",
"city": "London",
"currency": "GBP",
"amount": 12.2
},
{
"country": "UK",
"city": "London",
"currency": "FBP",
"amount": 10.9
}
],
"arguments": ["currency", "country", "city"]
}'