Giter Site home page Giter Site logo

api's Introduction

Python API

The Python API is used to query the raw data contained in the database. It listens for HTTP GET requests on port 8080. When a request comes in to the URI “/” it returns a usage message, in Python style. Data can be requested of the API for devices by serial number by using the URI “/serial”. For example, to qeury the API running locally for data from serial 7, you would execute a GET request to 127.0.0.1:8080/7. The official server is db.sead.systems.

Filters can be applied using the following GET parameters:

  • start_time: The earliest data point to include in the query. Specified as a UTC Unix timestamp.
  • end_time: The earliest data point to include in the query. Specified as a UTC Unix timestamp.
  • type: The type of data to retrieve. Current options: I for current, T for temperature, W for power, V for voltage.
  • subset: Select a subset of the data within the given filters such that the number of elements returned are evenly spaced within the range of data returned in the filter. This option may not return exactly specified number of data points. The number of data points returned should be close to the specified number. If the same query without a subset clause would return fewer than the specified number of rows, the subset option will have no effect.
  • limit: Retrieve only the first x rows
  • json: Format result as JSON
  • reverse: Return the result in reverse order

Example API calls with parameters:

The service can be started using the init script installed via Puppet:

$ sudo service seadapi start

The Python API is the primary interface to be used by the front end designers to query the database for SEAD plug data, and facilitates the necessary action for our first user story:

As a GUI developer, I want to query the database for signals within a certain range.

Our final goals for the API are currently being blocked by other teams. Querying based on device type is dependent on the analysis sub-team producing tested and working modules. Querying SEAD panel data is dependent on the SEAD panel team (not affiliated with CMPS 115) finishing the data transmission component of the SEAD panel.

Once we have the API prepared to accept information from the SEAD panel and the classification scripts, we will be able to generate a signature to classify the device based on the raw data received. This will allow us to proceed with our second user story:

As a GUI developer, I want to query the database for data by appliance type.

##Installation

Installation of the Go Landing Zone and the Python API can be automated by using the Puppet modules included in the repository. The puppet modules are written for and assume to be executed on an Ubuntu 14.04 x64 Linux server. First you must install the prerequisites for running Puppet. From the terminal, execute:

$ sudo apt-get install puppet git

It is recommended that you also install fail2ban with the following command:

$ sudo apt-get install fail2ban

Copy the Puppet files onto the server (for example, by cloning the repository) and change to the DB directory.

$ cd DB/

If desired, configure the UNIX application user’s password in puppet/modules/config. First add the user credentials to manifests/credentials.pp, then uncomment the password definitions in config/manifests/init.pp.

$ cd puppet/config
$ nano manifests/credentials.pp
$ nano manifests/init.pp
$ cd ../..

Copy the files to the /etc/puppet directory, and execute Puppet:

$ sudo rsync -avc puppet/ /etc/puppet/
$ sudo puppet apply puppet/manifests/site.pp

After Puppet has executed the modules correctly, the server should be listening on ports 8080 and 9000. Verify with netstat:

$ netstat -tln | egrep ':(8080|9000)'

api's People

Contributors

iangudger avatar

Stargazers

Kevin Jung avatar

Watchers

James Cloos avatar Ali Adabi avatar  avatar Henry Crute avatar Jared Jensen avatar Alec Reid avatar Cameron Wright avatar Mithilesh Athreya 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.