-
Notifications
You must be signed in to change notification settings - Fork 4
Dev rundeck api #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Dev rundeck api #132
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
31d76ab
Modelisation of rundeck executions
loichenninger 2f09cd0
Ports and repository to sava data in rundeckExecutions collection
loichenninger c594df4
Create controller for rundeck executions
loichenninger 89a3c14
Change id names
loichenninger 14ab925
Merge branch 'main' into devRundeckApi
loichenninger 2d8f780
Merge branch 'main' into devRundeckApi
alexisszmundy b45c4ca
feat: correction of false description
loichenninger 161d7e1
test: add test on RundeckExecution Service
loichenninger 206cd1c
test: test rundeckExecution controller
loichenninger 66db1e4
feat: test mapper
loichenninger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/main/java/fr/insee/genesis/controller/rest/RundeckExecutionController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package fr.insee.genesis.controller.rest; | ||
|
|
||
| import fr.insee.genesis.domain.model.rundeck.RundeckExecution; | ||
| import fr.insee.genesis.domain.ports.api.RundeckExecutionApiPort; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.stereotype.Controller; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
|
|
||
| @RequestMapping(path = "/rundeck-execution") | ||
| @Controller | ||
| @Slf4j | ||
| public class RundeckExecutionController { | ||
|
|
||
| private final RundeckExecutionApiPort rundeckExecutionApiPort; | ||
|
|
||
| @Autowired | ||
| public RundeckExecutionController(RundeckExecutionApiPort rundeckExecutionApiPort) { | ||
| this.rundeckExecutionApiPort = rundeckExecutionApiPort; | ||
| } | ||
|
|
||
| @Operation(summary = "Register a Rundeck execution") | ||
| @PostMapping(path = "/save") | ||
| public ResponseEntity<Object> addRundeckExecution( | ||
| @Parameter(description = "Survey name to call Kraftwerk on") @RequestBody RundeckExecution rundeckExecution | ||
| ){ | ||
| try{ | ||
| rundeckExecutionApiPort.addExecution(rundeckExecution); | ||
| log.info("{} job saved", rundeckExecution.getJob().getName()); | ||
| } catch(Exception e){ | ||
| log.info("Rundeck execution was not saved in database"); | ||
| return ResponseEntity.internalServerError().build(); | ||
| } | ||
| return ResponseEntity.ok().build(); | ||
| } | ||
|
|
||
| } | ||
13 changes: 13 additions & 0 deletions
13
src/main/java/fr/insee/genesis/domain/model/rundeck/DateStarted.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package fr.insee.genesis.domain.model.rundeck; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public class DateStarted { | ||
|
|
||
| private long unixtime; | ||
| private String date; | ||
|
|
||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/fr/insee/genesis/domain/model/rundeck/Job.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package fr.insee.genesis.domain.model.rundeck; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public class Job { | ||
|
|
||
| @JsonProperty("id") | ||
| private String idJob; | ||
| private long averageDuration; | ||
| private String name; | ||
| private String group; | ||
| private String project; | ||
| private String description; | ||
| private String href; | ||
| private String permalink; | ||
| } |
27 changes: 27 additions & 0 deletions
27
src/main/java/fr/insee/genesis/domain/model/rundeck/RundeckExecution.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package fr.insee.genesis.domain.model.rundeck; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public class RundeckExecution { | ||
|
|
||
| @JsonProperty("id") | ||
| private long idExecution; | ||
| private String href; | ||
| private String permalink; | ||
| private String status; | ||
| private String project; | ||
| private String executionType; | ||
| private String user; | ||
|
|
||
| @JsonProperty("date-started") | ||
| private DateStarted dateStarted; | ||
|
|
||
| private Job job; | ||
| private String description; | ||
| private String argstring; | ||
| private String serverUUID; | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/fr/insee/genesis/domain/ports/api/RundeckExecutionApiPort.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package fr.insee.genesis.domain.ports.api; | ||
|
|
||
| import fr.insee.genesis.domain.model.rundeck.RundeckExecution; | ||
|
|
||
| public interface RundeckExecutionApiPort { | ||
|
|
||
| void addExecution(RundeckExecution rundeckExecution); | ||
|
|
||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/fr/insee/genesis/domain/ports/spi/RundeckExecutionPersistencePort.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package fr.insee.genesis.domain.ports.spi; | ||
|
|
||
| import fr.insee.genesis.domain.model.rundeck.RundeckExecution; | ||
|
|
||
| public interface RundeckExecutionPersistencePort { | ||
|
|
||
| void save(RundeckExecution rundeckExecution); | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/main/java/fr/insee/genesis/domain/service/rundeck/RundeckExecutionService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package fr.insee.genesis.domain.service.rundeck; | ||
|
|
||
| import fr.insee.genesis.domain.model.rundeck.RundeckExecution; | ||
| import fr.insee.genesis.domain.ports.api.RundeckExecutionApiPort; | ||
| import fr.insee.genesis.domain.ports.spi.RundeckExecutionPersistencePort; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.beans.factory.annotation.Qualifier; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @Slf4j | ||
| public class RundeckExecutionService implements RundeckExecutionApiPort { | ||
| @Qualifier("rundeckExecutionMongoAdapter") | ||
| private final RundeckExecutionPersistencePort rundeckExecutionPersistencePort; | ||
|
|
||
| @Autowired | ||
| public RundeckExecutionService(RundeckExecutionPersistencePort rundeckExecutionPersistencePort) { | ||
| this.rundeckExecutionPersistencePort = rundeckExecutionPersistencePort; | ||
| } | ||
|
|
||
| @Override | ||
| public void addExecution(RundeckExecution rundeckExecution) { | ||
| rundeckExecutionPersistencePort.save(rundeckExecution); | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/main/java/fr/insee/genesis/infrastructure/adapter/RundeckExecutionMongoAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package fr.insee.genesis.infrastructure.adapter; | ||
|
|
||
| import fr.insee.genesis.domain.model.rundeck.RundeckExecution; | ||
| import fr.insee.genesis.domain.ports.spi.RundeckExecutionPersistencePort; | ||
| import fr.insee.genesis.infrastructure.mappers.RundeckExecutionDocumentMapper; | ||
| import fr.insee.genesis.infrastructure.repository.RundeckExecutionDBRepository; | ||
| import fr.insee.genesis.infrastructure.repository.ScheduleMongoDBRepository; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.beans.factory.annotation.Qualifier; | ||
| import org.springframework.data.mongodb.core.MongoTemplate; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @Qualifier("rundeckExecutionMongoAdapter") | ||
| @Slf4j | ||
| public class RundeckExecutionMongoAdapter implements RundeckExecutionPersistencePort { | ||
|
|
||
| private final RundeckExecutionDBRepository rundeckExecutionDBRepository; | ||
|
|
||
| @Autowired | ||
| public RundeckExecutionMongoAdapter(RundeckExecutionDBRepository rundeckExecutionDBRepository) { | ||
| this.rundeckExecutionDBRepository = rundeckExecutionDBRepository; | ||
| } | ||
|
|
||
| @Override | ||
| public void save(RundeckExecution rundeckExecution) { | ||
| rundeckExecutionDBRepository.insert(RundeckExecutionDocumentMapper.INSTANCE.modelToDocument(rundeckExecution)); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/fr/insee/genesis/infrastructure/document/rundeck/Job.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package fr.insee.genesis.infrastructure.document.rundeck; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class Job { | ||
|
|
||
| private String idJob; | ||
| private long averageDuration; | ||
| private String name; | ||
| private String project; | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/main/java/fr/insee/genesis/infrastructure/document/rundeck/RundeckExecutionDocument.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package fr.insee.genesis.infrastructure.document.rundeck; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import fr.insee.genesis.domain.model.rundeck.DateStarted; | ||
| import lombok.*; | ||
| import org.springframework.data.mongodb.core.mapping.Document; | ||
|
|
||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Document(collection= "rundeckExecutions") | ||
| public class RundeckExecutionDocument { | ||
|
|
||
| private long idExecution; | ||
| private String status; | ||
| private String project; | ||
| private String user; | ||
|
|
||
| @JsonProperty("date-started") | ||
| private DateStarted dateStarted; | ||
|
|
||
| private Job job; | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/java/fr/insee/genesis/infrastructure/mappers/RundeckExecutionDocumentMapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package fr.insee.genesis.infrastructure.mappers; | ||
|
|
||
| import fr.insee.genesis.domain.model.rundeck.RundeckExecution; | ||
| import fr.insee.genesis.infrastructure.document.rundeck.RundeckExecutionDocument; | ||
| import org.mapstruct.Mapper; | ||
| import org.mapstruct.factory.Mappers; | ||
|
|
||
| @Mapper | ||
| public interface RundeckExecutionDocumentMapper { | ||
|
|
||
| RundeckExecutionDocumentMapper INSTANCE = Mappers.getMapper(RundeckExecutionDocumentMapper.class); | ||
|
|
||
| RundeckExecution documentToModel(RundeckExecutionDocument rundeckExecutionDocument); | ||
|
|
||
| RundeckExecutionDocument modelToDocument(RundeckExecution rundeckExecution); | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/fr/insee/genesis/infrastructure/repository/RundeckExecutionDBRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package fr.insee.genesis.infrastructure.repository; | ||
|
|
||
| import fr.insee.genesis.infrastructure.document.rundeck.RundeckExecutionDocument; | ||
| import org.springframework.data.mongodb.repository.MongoRepository; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public interface RundeckExecutionDBRepository extends MongoRepository<RundeckExecutionDocument, String> { | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (non-blocking): La description m'a l'air pas bonne