Geninfo is a open-source project for any brazilian company interested on monitoring and tracking your infra-structure (machines, network, etc) as a realtime status monitor checker for any user. Please we recommend reading our blog post with all motivation about why and for whom we decided to build this project.
Geninfo also provides a set of useful APIs for integrating with the third-party tools that needs to automate the flow of reporting, updating and closing incidents.
Take a look at our Swagger UI interface and play with our API Playgroun by appending '/api/docs' at the main domain.
With the live project on-line you can use some available APIs, let's introduce some of them:
The Django Rest Framework uses a AuthToken to interact with the Geninfo API. So any further requests you will need to pass the Authorization Token in the headers. Use the /login API to get one valid token (you must have a valid user and password).
curl -X POST "http://YOUR_URL/api/login/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"username\": \"username\", \"password\": \"password\"}"
You can request using the POST method to the /api/incidents/ , with incident payload required information. Don't forget to include the Authorization Token in the header of the request or you will not get the authorization to perform the action.
curl -X POST "http://YOUR_URL/api/incidents/" -H "accept: application/json" -H "Authorization: Token 449d55f1ff070eb9b33061f9ad35cf0f9912f16e" -H "Content-Type: application/json" -d "{ \"name_incident\": \"Incident\", \"incident_occurrence\": \"co\", \"incident_impact\": \"le\", \"description\": \"Incident happened\", \"services_afted\": [1], \"reports\": []}"
If you need to add a update report about the incident, you can use the API /incidents/{id}/report/ , by giving the report required fields and the incident PK at the request url.
curl -X POST "http://YOUR_URL/api/incidents/5/report/" -H "accept: application/json" -H "Authorization: Token YOURTOKEN" -H "Content-Type: application/json" -d "{ \"description_report\": \"Update Report\", \"obs_report\": \"It still under work\"}"
FInally you can close the incident by calling the /api/incidents/{id}/close/. It will close the incident and it will add a finish date given by your API.
curl -X POST "http://YOUR_URL/api/incidents/5/close/" -H "accept: application/json" -H "Authorization: Token YOURTOKEN" -H "Content-Type: application/json" -d "{ \"finish_date\": \"2022-02-11T19:36:24.359Z\", \"description_report\": \"Finally working!\", \"detail_report\": \"They recovered the internet\"}"
This project provides an example of our Django (Client/Server) based application hosted on Heroku with a Gunicorn Django setup. There are a lot of state of the art libraries and tools like:
- PostgreSQL, for DB.
- prospector, for automated quality assurance.
- Sendgrid, for E-mail sending
- Sentry, for live error logging
For continuous integration, a Github Action configuration .github/workflows/main.yml is included.
Also, includes a Heroku app.json and a working Django production.py settings, enabling easy deployments with 'Deploy to Heroku' button.
You'll need to have Docker installed. It's available on Windows, macOS and most distros of Linux.
git clone https://github.com/genomika/geninfo geninfo
cd geninfo
# Optionally checkout a specific tag, such as: git checkout 0.3.0
cp .env.example .env
cp docker-compose.yml.example docker-compose.yml
The first time you run this it's going to take 5-10 minutes depending on your internet connection speed and computer's hardware specs. That's because it's going to download a few Docker images and build the Python + Pip dependencies.
We have created Makefile with several aliases with common commands so you can start your environment with a few commands.
make up
Now that everything is built and running we can treat it like any other Django app.
Did you receive an error about a port being in use? Chances are it's because
something on your machine is already running on port 8000. Check out the port
config in the docker-compose.yml
file to fix this.
# You can run this from a 2nd terminal.
make migrate
Visit http://0.0.0.0:8000 in your favorite browser.
By using the fixtures, we can load with some fake examples our database.
# You can run this from a 2nd terminal.
make load
Follow the instructions by providing an username, password and e-mail.
# You can run this from a 2nd terminal.
make super
# You should get 0 messages found (that means everything is operational).
make lint
make collect
# You should see that everything is unchanged (it's all already formatted).
marke format
We use the tox for the automation test workflow or you can run only testing mode.
# You should see all passing tests. Warnings are typically ok.
make test
# This command will run a full check: lint, tests and format code.
make tox
# Stop the containers and remove a few Docker related resources associated to this project.
make down
You can start things up again with make up
and unlike the first
time it should only take seconds.
This project comes with an app.json
file, which can be used to create an app on Heroku from a GitHub repository.
Before deploying, please make sure you've generated an up-to-date requirements.txt
file containing the Python dependencies. This is necessary even if you've used Docker for local runs. If your repository is public, you can use the following button:
If you are in a private repository, access the following link replacing $YOUR_REPOSITORY_LINK$
with your repository link.
https://heroku.com/deploy?template=$YOUR_REPOSITORY_LINK$
django
for building backend logic using Pythondjangorestframework
for building a REST API on top of Djangodjango-suit
for a customized django administration suite.psycopg2
for using PostgreSQL databasewhitenoise
for serving static assetsgunicorn
for an app server in both development and productionmailhog
for testing our e-mail workflows.drf_yasg2
for building the DRF specs and API docssentry-sdk
for logging errors tool
If you wish to contribute to this project, please first discuss the change you wish to make via an issue.
Copyright (c) 2021 Genomika Diagnosticos.