This task involves implementing a Java application that provides a REST API for managing "task" objects. These task objects represent shell commands that can be executed within a Kubernetes pod.
task-api/: The Java Spring Boot application (to be implemented).README.md: This documentation file.
Each task object should have the following properties:
id(String): Task IDname(String): Task nameowner(String): Task ownercommand(String): Shell command to be runtaskExecutions(List): A list of task execution records.
Each TaskExecution object should contain:
startTime(Date): Execution start date/timeendTime(Date): Execution end date/timeoutput(String): Command output
{
"id": "123",
"name": "Print Hello",
"owner": "John Smith",
"command": "echo Hello World again!",
"taskExecutions": [
{
"startTime": "2023-04-21 15:51:42.276Z",
"endTime": "2023-04-21 15:51:43.276Z",
"output": "Hello World!"
},
{
"startTime": "2023-04-21 15:52:42.276Z",
"endTime": "2023-04-21 15:52:43.276Z",
"output": "Hello World again!"
}
]
}The application should expose the following REST API endpoints:
-
GET /tasks
- Returns all
taskobjects if no parameters are passed. - If a
taskID is passed as a parameter, it should return a single task or a 404 Not Found error if no such task exists.
- Returns all
-
PUT /tasks
- Accepts a
taskobject as a JSON-encoded message body. - The application must validate the
commandprovided in the request to ensure it does not contain unsafe or malicious code.
- Accepts a
-
Clone the Repository: If you haven't already, clone this repository to your local machine.
git clone <repository-url> cd task1-java-backend
-
Navigate to the
task-apidirectory: The core Java backend application will be located in thetask-apisubdirectory.cd task-api -
Build the Application: Use Maven to build the project.
./mvnw clean install
-
Run the Application: Once built, you can run the Spring Boot application.
java -jar target/taskmanager-1.0.0.jar
(Note: The exact JAR name might vary based on your
pom.xmlconfiguration.) -
Access the API: Once the application is running, the REST API will typically be accessible at
http://localhost:8080(or another port if configured differently).