Skip to content
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

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

nitu-s-gupta
Copy link
Contributor

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

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  1. Run the Docker container for Edge-orchestration
docker run -it -d --privileged --network="host" --name edge-orchestration  -v /var/edge-orchestration/:/var/edge-orchestration/:rw -v /var/run/docker.sock:/var/run/docker.sock:rw -v /proc/:/process/:ro  lfedge/edge-home-orchestration-go:latest
  1. 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)

  2. 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:

  • OS type & version: (Ubuntu 20.04)
  • Hardware: (x86-64)
  • Edge Orchestration Release: (v1.1.0)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@sonarcloud
Copy link

sonarcloud bot commented Mar 1, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@tiokim tiokim left a 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?

@nitu-s-gupta
Copy link
Contributor Author

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

@tiokim
Copy link
Contributor

tiokim commented Mar 2, 2022

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 { "device":"camera", "readings":[{ "name":"cowcount", "value":"9" }] }

@nitu-s-gupta
Copy link
Contributor Author

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 { "device":"camera", "readings":[{ "name":"cowcount", "value":"9" }] }

This information can be obtained from database using the reading API or by calling the api in coredatabase to get all the events

@tiokim
Copy link
Contributor

tiokim commented Mar 2, 2022

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 { "device":"camera", "readings":[{ "name":"cowcount", "value":"9" }] }

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?

@nitu-s-gupta
Copy link
Contributor Author

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 { "device":"camera", "readings":[{ "name":"cowcount", "value":"9" }] }

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

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 { "device":"camera", "readings":[{ "name":"cowcount", "value":"9" }] }

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?

For readings fetching Service application can call /api/v1/device/{deviceNameKey}/resource/{resourceNameKey} Get API
For event fetching no API exits as provided by homeedge

@tiokim
Copy link
Contributor

tiokim commented Mar 2, 2022

For readings fetching Service application can call /api/v1/device/{deviceNameKey}/resource/{resourceNameKey} Get API For event fetching no API exits as provided by homeedge

@nitu-s-gupta Thank you for the answer! I opened an issue #505 for the later implementation.

Copy link
Contributor

@suresh-lc suresh-lc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

@tdrozdovsky tdrozdovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@MoonkiHong MoonkiHong left a 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.

@MoonkiHong MoonkiHong merged commit 3df9018 into lf-edge:master Mar 2, 2022
@nitu-s-gupta nitu-s-gupta deleted the EventAPI branch March 3, 2022 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants