Giter Club home page Giter Club logo

play-spring-boot's Introduction

Welcome

Roots

Root ID Name
root-0 example-0
root-1 example-1
root-2 example-2
root-3 example-3
root-4 example-4

These values are used in the code and in the following examples too.

Requirements

The project requires Java 1.8 or higher.

The project makes use of Gradle and uses the Gradle wrapper, which means you don't need Gradle installed.

Useful Gradle commands

The project makes use of Gradle and uses the Gradle wrapper to help you out carrying some common tasks such as building the project or running it.

List all Gradle tasks

List all the tasks that Gradle can do, such as build and test.

$ ./gradlew tasks

Build the project

Compiles the project, runs the test and then creates an executable JAR file

$ ./gradlew build

Run the application using Java and the executable JAR file produced by the Gradle build task. The application will be listening to port 8080.

$ java -jar build/libs/play-spring-boot.jar

Run the tests

There are two types of tests, the unit tests and the functional tests. These can be executed as follows.

  • Run unit tests only

    $ ./gradlew test
  • Run functional tests only

    $ ./gradlew functionalTest
  • Run both unit and functional tests

    $ ./gradlew check

Run the application

Run the application which will be listening on port 8080.

$ ./gradlew bootRun

API

Below is a list of API endpoints with their respective input and output. Please note that the application needs to be running for the following endpoints to work. For more information about how to run the application, please refer to run the application section above.

Store Readings

Endpoint

POST /values/store

Example of body

{
  "rootId": <rootId>,
  "exampleValues": [
    {
      "time": <time>,
      "value": <value>
    }
  ]
}

Parameters

Parameter Description
rootId One of the root id listed above
time The date/time (as epoch)
value Any BigDecimal

The following POST request, is an example request using CURL, sends the readings shown in the table above.

$ curl \
  -X POST \
  -H "Content-Type: application/json" \
  "http://localhost:8080/values/store" \
  -d '{"rootId":"root-10","exampleValues":[{"time":1606636800,"value":0.0503},{"time":1606636860,"value":0.0621},{"time":1606636920,"value":0.0222},{"time":1606636980,"value":0.0423},{"time":1606637040,"value":0.0191}]}'

The above command does not return anything.

Get Stored Readings

Endpoint

GET /values/read/<rootId>

Parameters

Parameter Description
rootId One of the smart meters' id listed above

Retrieving readings using CURL

$ curl "http://localhost:8080/values/read/root-0"

Example output

[
  {
    "time": "2020-11-29T08:00:00Z",
    "value": 0.0503
  },
  {
    "time": "2020-11-29T08:01:00Z",
    "value": 0.0621
  },
  {
    "time": "2020-11-29T08:02:00Z",
    "value": 0.0222
  },
  {
    "time": "2020-11-29T08:03:00Z",
    "value": 0.0423
  },
  {
    "time": "2020-11-29T08:04:00Z",
    "value": 0.0191
  }
]

play-spring-boot's People

Contributors

sdrahcirekim avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.