Code Monkey home page Code Monkey logo

drones-api's Introduction

Drones API

Description

This project contains a REST API for managing drones. Implemented using Ruby on Rails.

Running the app

To avoid complex installations to run the project, you can create a docker image and run it locally.

You only need to do the following steps:

# build the docker images
$ docker-compose build

# create, migrate and seed the database
$ docker-compose run web rake db:create db:migrate db:seed

# run the images in the background
$ docker-compose up -d

By default the application is going to run on http://0.0.0.0:3000

About audit drone battery periodic task

Once you run the images, you can check how a periodic task is inserting into the database info about the battery level of every drone

To check that, you need to do the following steps:

Enter to the drones-api_web_1 container in interactive mode
$ docker exec -it drones-api_web_1 bash

To enter to an irb session where you can query the database using ActiveRecord ORM
$ rails c

To see the logs 
> DroneLog.all

The task is going to run every minute, so if you wait a little bit and you do the same query you are going to find more logs

API

There are 5 endpoints:

To obtain all the registered drones
GET host:port/api/drones

To obtain an specific drone
GET host:port/api/drones/:id

To register a drone
POST host:port/api/drones

To get all the medications that is loading an drone
GET host:port/api/drones/:id/medications

To load a drone with a medication
POST host:port/api/drones/:id/medications

API endpoints examples via curl

curl host:port/api/drones \
    -H "Accept: application/json"

curl host:port/api/drones/:id \
    -H "Accept: application/json"

curl host:port/api/drones \
    -H "Content-Type: application/json" \
    -d \
    ' {
        "drone": {
            "serial_number": "abcd",
            "battery_capacity": 80,
            "weight_limit": 400,
            "model": "CruiserWeight",
            "state": "IDLE"
        }
    } '

curl host:port/api/drones/:id/medications \
    -H "Accept: application/json"

curl host:port/api/drones/:id/medications \
    -H "Content-Type: application/json" \
    -d \
    ' {
        "medication": {
            "name": "fooo",
            "weight": 30,
            "code": "ADBD"
        }
    } '
    

drones-api's People

Contributors

rbruno95 avatar

Watchers

 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.