Skip to content

emma-community/emma-report-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Report Service

This Go application generates CSV reports from data retrieved via the EMMA API. The application uses Docker for containerization and is designed to support various types of reports.

Features

  • List Files: Retrieve a list of available CSV files generated by the API.
  • Generate CSV: Generate CSV reports containing data from the EMMA platform.
  • Download File: Download a specific CSV file from the API.

Prerequisites

  • Docker installed on your machine.
  • EMMA API client credentials.

Getting Started

Environment Variables

Set the CREDENTIALS environment variable in the format:

export CREDENTIALS="ProjectName1:ClientId1:ClientSecret1,ProjectName2:ClientId2:ClientSecret2"

Building and Running with Docker

  1. Build the Docker image:
docker build -t emma-report-generator .
  1. Run the Docker container:
docker run -p 8080:8080 -e CREDENTIALS="$CREDENTIALS" emma-report-generator

Accessing the Service

Once the container is running, you can access the service at:

curl -X POST localhost:8080/v1/generates
curl localhost:8080/v1/files
FILE=$(curl http://localhost:8080/v1/files | jq -r .files[0])
curl localhost:8080/v1/downloads?file=$FILE

Kubernetes

To start the service in a Kubernetes cluster apply the k8s.yaml. This starts this service as a pod, makes it available as a K8s services and creates a Cronjob to generate a report every 6 hours.

kubectl apply -f k8s.yaml

To make the service available locally:

kubectl port-forward service/emma-report-service 8080:80 -n reporting

To debug the service from the cluster:

kubectl run -i --tty debug-pod --image=alpine --restart=Never --rm -- /bin/sh -c "apk add --no-cache curl jq && sh"
curl http://emma-report-service.reporting.svc.cluster.local:80/v1/files | jq .files[]

API Endpoint

List Files

  • URL: /v1/files
  • Method: GET
  • Description: Retrieve a list of available CSV files generated by the API.
  • Response: JSON array containing the names of CSV files.

Generate CSV

  • URL: /v1/generates
  • Method: POST
  • Description: Generate CSV reports containing VM data from the EMMA platform.
  • Response: JSON array containing the names of newly generated CSV files.

Download File

  • URL: /v1/downloads?file=filename
  • Method: GET
  • Description: Download a specific CSV file from the API.
  • Required Query Parameter: file - Name of the CSV file to download.
  • Response: CSV file download.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •