diff options
Diffstat (limited to 'runtime-acm/src/main')
-rw-r--r-- | runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringDocBean.java (renamed from runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java) | 27 | ||||
-rw-r--r-- | runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java | 18 | ||||
-rw-r--r-- | runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java | 88 | ||||
-rw-r--r-- | runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java | 2 | ||||
-rw-r--r-- | runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java | 2 |
5 files changed, 39 insertions, 98 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringDocBean.java index 0918cea1c..df9a0bfa4 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringFoxConfig.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SpringDocBean.java @@ -20,26 +20,29 @@ package org.onap.policy.clamp.acm.runtime.config; -import org.onap.policy.clamp.acm.runtime.main.rest.CommissioningController; +import io.swagger.v3.oas.models.ExternalDocumentation; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; @Configuration -public class SpringFoxConfig { +public class SpringDocBean { /** - * Docket Spring Fox Config. + * Bean to configure SpringDoc. * - * @return Docket + * @return the OpenAPI specification */ @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2).select() - .apis(RequestHandlerSelectors.basePackage(CommissioningController.class.getPackageName())) - .paths(PathSelectors.any()).build(); + public OpenAPI kubernetesParticipantOpenApi() { + return new OpenAPI() + .info(new Info().title("ACM Runtime") + .description("CLAMP Automation Composition Management Runtime API") + .license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0"))) + .externalDocs(new ExternalDocumentation() + .description("CLAMP Automation Composition Management Documentation") + .url("https://docs.onap.org/projects/onap-policy-parent/en/latest/clamp/clamp.html")); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java index 29b337edd..03a2f4e25 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java @@ -43,6 +43,7 @@ import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ObjectValidationResult; import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -80,9 +81,10 @@ public class AutomationCompositionInstantiationProvider { if (!validationResult.isValid()) { throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); } - automationComposition = automationCompositionProvider.saveAutomationComposition(automationComposition); + automationComposition = automationCompositionProvider.createAutomationComposition(automationComposition); var response = new InstantiationResponse(); + response.setInstanceId(automationComposition.getInstanceId()); response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier()); return response; @@ -99,9 +101,10 @@ public class AutomationCompositionInstantiationProvider { if (!validationResult.isValid()) { throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); } - automationCompositionProvider.saveAutomationComposition(automationComposition); + automationCompositionProvider.updateAutomationComposition(automationComposition); var response = new InstantiationResponse(); + response.setInstanceId(automationComposition.getInstanceId()); response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier()); return response; @@ -134,7 +137,8 @@ public class AutomationCompositionInstantiationProvider { * @return the result of the deletion */ public InstantiationResponse deleteAutomationComposition(String name, String version) { - var automationCompositionOpt = automationCompositionProvider.findAutomationComposition(name, version); + var automationCompositionOpt = + automationCompositionProvider.findAutomationComposition(new ToscaConceptIdentifier(name, version)); if (automationCompositionOpt.isEmpty()) { throw new PfModelRuntimeException(Response.Status.NOT_FOUND, "Automation composition not found"); } @@ -144,8 +148,10 @@ public class AutomationCompositionInstantiationProvider { "Automation composition state is still " + automationComposition.getState()); } var response = new InstantiationResponse(); - response.setAffectedAutomationComposition( - automationCompositionProvider.deleteAutomationComposition(name, version).getKey().asIdentifier()); + automationComposition = + automationCompositionProvider.deleteAutomationComposition(automationComposition.getInstanceId()); + response.setInstanceId(automationComposition.getInstanceId()); + response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier()); return response; } @@ -199,7 +205,7 @@ public class AutomationCompositionInstantiationProvider { automationComposition.setCascadedOrderedState(command.getOrderedState()); supervisionHandler.triggerAutomationCompositionSupervision(automationComposition); - automationCompositionProvider.saveAutomationComposition(automationComposition); + automationCompositionProvider.updateAutomationComposition(automationComposition); var response = new InstantiationResponse(); response.setAffectedAutomationComposition(command.getAutomationCompositionIdentifier()); diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java index 5a24db9af..4247a5b31 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java @@ -20,26 +20,16 @@ package org.onap.policy.clamp.acm.runtime.main.rest; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.onap.policy.clamp.acm.runtime.commissioning.CommissioningProvider; +import org.onap.policy.clamp.acm.runtime.main.rest.gen.AutomationCompositionDefinitionApi; import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController; import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -59,20 +49,11 @@ public class CommissioningController extends AbstractRestController implements A * @return a response */ @Override - // @formatter:off - @PostMapping(value = "/commission", - consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - // @formatter:on - public ResponseEntity<CommissioningResponse> createCompositionDefinitions( - @Parameter( - description = "Entity Body of Automation Composition", - required = true) @RequestBody ToscaServiceTemplate body, - @RequestHeader(name = REQUEST_ID_NAME, required = false) @Parameter( - description = REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) { + public ResponseEntity<CommissioningResponse> createCompositionDefinitions(ToscaServiceTemplate body, + UUID requestId) { var response = provider.createAutomationCompositionDefinitions(body); - return ResponseEntity.created(createUri("/commission/" + response.getCompositionId())).body(response); + return ResponseEntity.created(createUri("/compositions/" + response.getCompositionId())).body(response); } /** @@ -83,18 +64,7 @@ public class CommissioningController extends AbstractRestController implements A * @return a response */ @Override - // @formatter:off - @DeleteMapping(value = "/commission/{compositionId}", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - // @formatter:on - public ResponseEntity<CommissioningResponse> deleteCompositionDefinition( - @Parameter( - in = ParameterIn.PATH, - description = "The UUID of the automation composition definition to delete", - required = true) @PathVariable("compositionId") UUID compositionId, - @RequestHeader(name = REQUEST_ID_NAME, required = false) @Parameter( - description = REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) { - + public ResponseEntity<CommissioningResponse> deleteCompositionDefinition(UUID compositionId, UUID requestId) { return ResponseEntity.ok().body(provider.deleteAutomationCompositionDefinition(compositionId)); } @@ -108,57 +78,19 @@ public class CommissioningController extends AbstractRestController implements A * @throws PfModelException on errors getting details of all or specific automation composition definitions */ @Override - // @formatter:off - @GetMapping(value = "/commission", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - // @formatter:on - public ResponseEntity<ToscaServiceTemplates> queryCompositionDefinitions( - - @Parameter(description = "Automation composition definition name", required = false) @RequestParam( - value = "name", - required = false) String name, - @Parameter(description = "Automation composition definition version", required = false) @RequestParam( - value = "version", - required = false) String version, - @RequestHeader(name = REQUEST_ID_NAME, required = false) @Parameter( - description = REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) { - + public ResponseEntity<ToscaServiceTemplates> queryCompositionDefinitions(String name, String version, + UUID requestId) { return ResponseEntity.ok().body(provider.getAutomationCompositionDefinitions(name, version)); } - // @formatter:off @Override - @GetMapping(value = "/commission/{compositionId}", - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - // @formatter:on - public ResponseEntity<ToscaServiceTemplate> getCompositionDefinition( - @Parameter( - in = ParameterIn.PATH, - description = "The UUID of the automation composition definition to get", - required = true) @PathVariable("compositionId") UUID compositionId, - @RequestHeader(name = REQUEST_ID_NAME, required = false) @Parameter( - description = REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) { - + public ResponseEntity<ToscaServiceTemplate> getCompositionDefinition(UUID compositionId, UUID requestId) { return ResponseEntity.ok().body(provider.getAutomationCompositionDefinitions(compositionId)); } - // @formatter:off @Override - @PutMapping(value = "/commission/{compositionId}", - consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}, - produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML}) - // @formatter:on - public ResponseEntity<CommissioningResponse> updateCompositionDefinition( - @Parameter( - in = ParameterIn.PATH, - description = "The UUID of the automation composition definition to update", - required = true) @PathVariable("compositionId") UUID compositionId, - @Parameter( - in = ParameterIn.DEFAULT, - description = "Serialised instance of.", - required = true) @RequestBody ToscaServiceTemplate body, - @RequestHeader(name = REQUEST_ID_NAME, required = false) @Parameter( - description = REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) { + public ResponseEntity<CommissioningResponse> updateCompositionDefinition(UUID compositionId, + ToscaServiceTemplate body, UUID requestId) { return ResponseEntity.ok().body(provider.updateCompositionDefinition(compositionId, body)); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java index b5d7645da..de67360f8 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java @@ -235,7 +235,7 @@ public class SupervisionHandler { automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet()); updated |= setPrimed(automationComposition.get()); if (updated) { - automationCompositionProvider.saveAutomationComposition(automationComposition.get()); + automationCompositionProvider.updateAutomationComposition(automationComposition.get()); } } else { LOGGER.warn("AutomationComposition not found in database {}", diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java index e2f8b6777..129569b6b 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java @@ -242,7 +242,7 @@ public class SupervisionScanner { automationComposition.getState(), automationComposition.getOrderedState()); automationComposition.setState(automationComposition.getOrderedState().asState()); - automationCompositionProvider.saveAutomationComposition(automationComposition); + automationCompositionProvider.updateAutomationComposition(automationComposition); // Clear missed report counter on automation composition clearFaultAndCounter(automationComposition); |