-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataStorage] APIs to add Event and delete Events from database based on event ids #503
Conversation
Signed-off-by: Nitu Gupta <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
By the way, how to get the information inserted with add event API?
information of what? Addevent will return the id of the event inserted |
Input from service application such as |
This information can be obtained from database using the reading API or by calling the api in coredatabase to get all the events |
Can a service application fetch the information through DataStroage REST API at the moment? |
Yes reading API
For readings fetching Service application can call /api/v1/device/{deviceNameKey}/resource/{resourceNameKey} Get API |
@nitu-s-gupta Thank you for the answer! I opened an issue #505 for the later implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Signed-off-by: Nitu Gupta [email protected]
Description
Currently DataStorage has APIs to add data to the database or get the reading. API to delete a record from database is not present. This PR will add an API to delete record from CoreData given the Event ID
Usage Example
Add an Event
curl --location --request POST 'http://{DeviceServiceIP:Port}/api/v1/event'
Delete an Event
curl --location --request DELETE 'http://192.168.1.107:49986/api/v1/event/id/{EventID}"
Fixes # (issue)
Type of change
How Has This Been Tested?
Post an event by calling the API
curl --location --request POST 'http://192.168.1.107:49986/api/v1/event'
--header 'Content-Type: text/plain'
--data-raw '{
"device":"camera",
"readings":[{
"name":"cowcount",
"value":"9"
}]
}'
This will return an id of the event (In this example it returned 0d8d6738-5968-4b6c-92eb-1d45b2b3740a)
Call the delete API using
curl --location --request DELETE 'http://192.168.1.107:49986/api/v1/event/id/0d8d6738-5968-4b6c-92eb-1d45b2b3740a'
This will return true in case of success
Test Configuration:
Checklist: