This is a REST service based on Dropwizard framework.
To build the application including the Docker image, execute the following maven command from the project folder:
mvn clean install -Pdocker
Since it's packaged as a single JAR, you can start the application as:
dropwizard-rest-example-1.0.0.jar server path/to/config/file.yml
The YAML configuration file is used to configure service integrations, as well as the HTTP server and logging.
In order to run the service from IntelliJ, follow the steps to configure the runner:
- From the Run menu, select Edit Configuration...
- From the left panel of the Run/Debug Configurations dialog, click *+ button from the top.
- Select
Application
from the Add New Configuration dropdown. - On the Configuration tab of the left panel, select
com.basaki.example.ExampleApplication
as the Main class by clicking ... - Add
server src/main/resources/example.yml
as the Program arguments. - Select the project parent folder as the Working directory, e.g.,
/Users/dropwizard-rest-example
. - Select
munin-application
as the Use classpath of module. - Click Apply and then OK.
You can now run the application, by clicking the green run button from the toolbar. The application should start up at
port 8080
.
Run the newly created Docker image, docker-registry.iovationnp.com/iovation/munin:1.13.0-SNAPSHOT
, by executing the
docker run command from the terminal:
docker run --rm -p 8080:8080 --name=munin docker-registry.iovationnp.com/iovation/munin:1.13.0-SNAPSHOT
--rm
option automatically clean up the container and remove the file system when the container exits.--name
option names the Docker container asmunin
. In absence of the --name option, the Docker generates a random name for your container.-p 8080:8080
option publishes all exposed ports to the host interfaces. In our example, it is port 8080 is bothhostPort
andcontainerPort
This should start up the munin service at port 8080 and an be accessed at http://localhost:8080
.
List Container
Run docker ps
to list all the containers. To see all running containers, execute the following command:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
538144f6ec0d docker-registry.iovationnp.com/iovation/munin:1.13.0-SNAPSHOT "/bin/sh -c /usr/loc…" 11 seconds ago Up 10 seconds 0.0.0.0:8080->8080/tcp munin
Remove Container
To remove the munun Docker container, execute docker rm
command. This will remove a non-running container.
$ docker rm -f munin
munin
API | Endpoint | HTTP Method |
---|---|---|
Scheduled Report | /v1/scheduledReports/{subscriberId}/{startTime} | GET |
Scheduled Report | /v1/scheduledReports/{subscriberId}/{startTime}/{endTime} | GET |
Scheduled Report | /v1/scheduledReports/{subscriberId}/{startTime}/{endTime}/{reportName} | GET |
Scheduled Report | /v1/scheduledReports/{subscriberId}/{key: [^?]+} | GET |
Scheduled Report | /v1/scheduledReports/{subscriberId}/{key: [^?]+} | DELETE |
CTD | /v1/ctd/{subscriberId}/{startTime} | GET |
CTD | /v1/ctd/{subscriberId}/{startTime}/{endTime} | GET |
CTD | /v1/ctd/download/{subscriberId}/{hourStamp} | GET |
CTD | /v1/ctd/download/{subscriberId}/{startHour}/{endHour} | GET |
CTD | /v1/ctd/download/{subscriberId}/olderThan/{hourStamp} | DELETE |
Health | /admin/healthcheck | GET |
Ping | /admin/ping | GET |
curl --request GET \
--url http://localhost:8080/reports/v1/scheduledReports/1000/1600954959000 \
--header 'authorization: Basic MTAwMC91N2k3LW02LVM3OEFBQUFBQUFBQUFBL3JlcG9ydGluZ0FwaTpSb0ZMNnZld3ZmZVpNbERiZGFkclA2REhpaEtCYXJDSnRyYzY3Zkt5RHRV'
curl --request GET \
--url http://localhost:8080/admin/healthcheck \
--header 'authorization: Basic YWRtaW46cWFvbmx5'
curl --request GET \
--url http://localhost:8080/admin/ping \
--header 'authorization: Basic YWRtaW46cWFvbmx5'