ntls-io / nautilus-trusted-compute

Nautilus Trusted Compute
GNU Affero General Public License v3.0
0 stars 3 forks source link

feat: Create two APIs for data operations #69

Open binglekruger opened 2 years ago

binglekruger commented 2 years ago

Create a new branch for the Data Service API

binglekruger commented 2 years ago

Started with two tutorials for using CosmosDB with Mongo APIs (recommended by Bill): https://www.mongodb.com/developer/languages/rust/rust-mongodb-crud-tutorial/ https://github.com/Azure-Samples/azure-cosmos-db-mongodb-rust-getting-started

Found another helpful tutorial: https://jbarszczewski.com/rust-actix-cosmosdb-mongodb-tutorial-api

Created 2 API functions:

  1. get_data - Display data pools of a specific user
  2. add_data - Add a new data pool to CosmosDB

Set connection string when starting project:

CONNECTION_STRING="mongodb://ntc-data:zkicQepvrK6B1SySo3vDLQpycrEsSt3WByUE1Zg7SYs47CceytRCzIuP3cu3p09GtY2cREJyJtdc9zSjqlxcvA==@ntc-data.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@ntc-data@" cargo run

Test POST - (Upload/Add data)

(Copy source code)

curl --header "Content-Type: application/json" \ --request POST \ --data '{"id":"Test Client 01","pool_name":"NTLS third pool","sealed_data":"This is some sealed data"}' \ http://127.0.0.1:8000/api/data

Test GET - (View/Get data)

(Copy source code)

curl --header "Content-Type: application/json" \ --request GET \ --data '{"id":"Test Client 02"}' \ http://127.0.0.1:8000/api/data

Claire-Bear commented 2 years ago

Task linked: CU-30ektdj Create 2 APIs (upload data pool & query data pool for data creator)