diff options
author | Liam Fallon <liam.fallon@est.tech> | 2022-12-05 17:36:04 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-12-05 17:36:04 +0000 |
commit | 6f3447836b04f2fbea1fa4fca526d549bec42661 (patch) | |
tree | 212c3f61afd3e14d3b1181d70bc58c4aab8c5284 /runtime-acm/src/main | |
parent | e10751382507fa55742a59caf00e42783f33dbe5 (diff) | |
parent | b5d62899bf9cfaef5c9dcc49023428bbb12bcc55 (diff) |
Merge "Refactor POST and PUT Automation Composition"
Diffstat (limited to 'runtime-acm/src/main')
4 files changed, 112 insertions, 189 deletions
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 2601a233b..29b337edd 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 @@ -21,9 +21,7 @@ package org.onap.policy.clamp.acm.runtime.instantiation; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; import javax.ws.rs.core.Response; @@ -44,8 +42,7 @@ import org.onap.policy.clamp.models.acm.utils.AcmUtils; 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.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.base.PfModelRuntimeException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -65,75 +62,66 @@ public class AutomationCompositionInstantiationProvider { private static final String ENTRY = "entry "; /** - * Create automation compositions. + * Create automation composition. * - * @param automationCompositions the automation composition + * @param automationComposition the automation composition * @return the result of the instantiation operation - * @throws PfModelException on creation errors */ - public InstantiationResponse createAutomationCompositions(AutomationCompositions automationCompositions) - throws PfModelException { - for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) { - var checkAutomationCompositionOpt = + public InstantiationResponse createAutomationComposition(AutomationComposition automationComposition) { + + var checkAutomationCompositionOpt = automationCompositionProvider.findAutomationComposition(automationComposition.getKey().asIdentifier()); - if (checkAutomationCompositionOpt.isPresent()) { - throw new PfModelException(Response.Status.BAD_REQUEST, + if (checkAutomationCompositionOpt.isPresent()) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, automationComposition.getKey().asIdentifier() + " already defined"); - } } - BeanValidationResult validationResult = validateAutomationCompositions(automationCompositions); + + var validationResult = validateAutomationComposition(automationComposition); if (!validationResult.isValid()) { - throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); } - automationCompositionProvider.saveAutomationCompositions(automationCompositions.getAutomationCompositionList()); + automationComposition = automationCompositionProvider.saveAutomationComposition(automationComposition); var response = new InstantiationResponse(); - response.setAffectedAutomationCompositions(automationCompositions.getAutomationCompositionList().stream() - .map(ac -> ac.getKey().asIdentifier()).collect(Collectors.toList())); + response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier()); return response; } /** - * Update automation compositions. + * Update automation composition. * - * @param automationCompositions the automation composition + * @param automationComposition the automation composition * @return the result of the instantiation operation - * @throws PfModelException on update errors */ - public InstantiationResponse updateAutomationCompositions(AutomationCompositions automationCompositions) - throws PfModelException { - BeanValidationResult validationResult = validateAutomationCompositions(automationCompositions); + public InstantiationResponse updateAutomationComposition(AutomationComposition automationComposition) { + var validationResult = validateAutomationComposition(automationComposition); if (!validationResult.isValid()) { - throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); } - automationCompositionProvider.saveAutomationCompositions(automationCompositions.getAutomationCompositionList()); + automationCompositionProvider.saveAutomationComposition(automationComposition); var response = new InstantiationResponse(); - response.setAffectedAutomationCompositions(automationCompositions.getAutomationCompositionList().stream() - .map(ac -> ac.getKey().asIdentifier()).collect(Collectors.toList())); + response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier()); return response; } /** - * Validate AutomationCompositions. + * Validate AutomationComposition. * - * @param automationCompositions AutomationCompositions to validate + * @param automationComposition AutomationComposition to validate * @return the result of validation - * @throws PfModelException if automationCompositions is not valid */ - private BeanValidationResult validateAutomationCompositions(AutomationCompositions automationCompositions) { - - var result = new BeanValidationResult("AutomationCompositions", automationCompositions); - for (var automationComposition : automationCompositions.getAutomationCompositionList()) { - var serviceTemplate = acDefinitionProvider.findAcDefinition(automationComposition.getCompositionId()); - if (serviceTemplate.isEmpty()) { - result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID, - "Commissioned automation composition definition not found")); - } else { - result.addResult(AcmUtils.validateAutomationComposition(automationComposition, serviceTemplate.get())); - } + private BeanValidationResult validateAutomationComposition(AutomationComposition automationComposition) { + + var result = new BeanValidationResult("AutomationComposition", automationComposition); + var serviceTemplate = acDefinitionProvider.findAcDefinition(automationComposition.getCompositionId()); + if (serviceTemplate.isEmpty()) { + result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID, + "Commissioned automation composition definition not found")); + } else { + result.addResult(AcmUtils.validateAutomationComposition(automationComposition, serviceTemplate.get())); } return result; } @@ -144,21 +132,20 @@ public class AutomationCompositionInstantiationProvider { * @param name the name of the automation composition to delete * @param version the version of the automation composition to delete * @return the result of the deletion - * @throws PfModelException on deletion errors */ - public InstantiationResponse deleteAutomationComposition(String name, String version) throws PfModelException { + public InstantiationResponse deleteAutomationComposition(String name, String version) { var automationCompositionOpt = automationCompositionProvider.findAutomationComposition(name, version); if (automationCompositionOpt.isEmpty()) { - throw new PfModelException(Response.Status.NOT_FOUND, "Automation composition not found"); + throw new PfModelRuntimeException(Response.Status.NOT_FOUND, "Automation composition not found"); } var automationComposition = automationCompositionOpt.get(); if (!AutomationCompositionState.UNINITIALISED.equals(automationComposition.getState())) { - throw new PfModelException(Response.Status.BAD_REQUEST, - "Automation composition state is still " + automationComposition.getState()); + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, + "Automation composition state is still " + automationComposition.getState()); } var response = new InstantiationResponse(); - response.setAffectedAutomationCompositions( - List.of(automationCompositionProvider.deleteAutomationComposition(name, version).getKey().asIdentifier())); + response.setAffectedAutomationComposition( + automationCompositionProvider.deleteAutomationComposition(name, version).getKey().asIdentifier()); return response; } @@ -168,13 +155,12 @@ public class AutomationCompositionInstantiationProvider { * @param name the name of the automation composition to get, null for all automation compositions * @param version the version of the automation composition to get, null for all automation compositions * @return the automation compositions - * @throws PfModelException on errors getting automation compositions */ @Transactional(readOnly = true) - public AutomationCompositions getAutomationCompositions(String name, String version) throws PfModelException { + public AutomationCompositions getAutomationCompositions(String name, String version) { var automationCompositions = new AutomationCompositions(); automationCompositions - .setAutomationCompositionList(automationCompositionProvider.getAutomationCompositions(name, version)); + .setAutomationCompositionList(automationCompositionProvider.getAutomationCompositions(name, version)); return automationCompositions; } @@ -184,76 +170,64 @@ public class AutomationCompositionInstantiationProvider { * * @param command the command to issue to automation compositions * @return the result of the initiation command - * @throws PfModelException on errors setting the ordered state on the automation compositions * @throws AutomationCompositionException on ordered state invalid */ public InstantiationResponse issueAutomationCompositionCommand(InstantiationCommand command) - throws AutomationCompositionException, PfModelException { + throws AutomationCompositionException { if (command.getOrderedState() == null) { throw new AutomationCompositionException(Status.BAD_REQUEST, - "ordered state invalid or not specified on command"); + "ordered state invalid or not specified on command"); } var participants = participantProvider.getParticipants(); if (participants.isEmpty()) { throw new AutomationCompositionException(Status.BAD_REQUEST, "No participants registered"); } - var validationResult = new BeanValidationResult("InstantiationCommand", command); - List<AutomationComposition> automationCompositions = - new ArrayList<>(command.getAutomationCompositionIdentifierList().size()); - for (ToscaConceptIdentifier id : command.getAutomationCompositionIdentifierList()) { - var automationCompositionOpt = automationCompositionProvider.findAutomationComposition(id); - if (automationCompositionOpt.isEmpty()) { - validationResult.addResult("ToscaConceptIdentifier", id, ValidationStatus.INVALID, - "AutomationComposition with id " + id + " not found"); - } else { - var automationComposition = automationCompositionOpt.get(); - automationComposition.setCascadedOrderedState(command.getOrderedState()); - automationCompositions.add(automationComposition); - } - } - if (validationResult.isValid()) { - validationResult = validateIssueAutomationCompositions(automationCompositions, participants); + var automationCompositionOpt = + automationCompositionProvider.findAutomationComposition(command.getAutomationCompositionIdentifier()); + if (automationCompositionOpt.isEmpty()) { + throw new AutomationCompositionException(Response.Status.BAD_REQUEST, + "AutomationComposition with id " + command.getAutomationCompositionIdentifier() + " not found"); } + + var automationComposition = automationCompositionOpt.get(); + var validationResult = validateIssueAutomationComposition(automationComposition, participants); if (!validationResult.isValid()) { - throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); + throw new AutomationCompositionException(Response.Status.BAD_REQUEST, validationResult.getResult()); } - automationCompositionProvider.saveAutomationCompositions(automationCompositions); - supervisionHandler.triggerAutomationCompositionSupervision(command.getAutomationCompositionIdentifierList()); + automationComposition.setCascadedOrderedState(command.getOrderedState()); + supervisionHandler.triggerAutomationCompositionSupervision(automationComposition); + automationCompositionProvider.saveAutomationComposition(automationComposition); var response = new InstantiationResponse(); - response.setAffectedAutomationCompositions(command.getAutomationCompositionIdentifierList()); + response.setAffectedAutomationComposition(command.getAutomationCompositionIdentifier()); return response; } - private BeanValidationResult validateIssueAutomationCompositions(List<AutomationComposition> automationCompositions, - List<Participant> participants) { - var result = new BeanValidationResult("AutomationCompositions", automationCompositions); - - Map<ToscaConceptIdentifier, Participant> participantMap = participants.stream() - .collect(Collectors.toMap(participant -> participant.getKey().asIdentifier(), Function.identity())); + private BeanValidationResult validateIssueAutomationComposition(AutomationComposition automationComposition, + List<Participant> participants) { + var result = new BeanValidationResult("AutomationComposition", automationComposition); - for (AutomationComposition automationComposition : automationCompositions) { + var participantMap = participants.stream() + .collect(Collectors.toMap(participant -> participant.getKey().asIdentifier(), Function.identity())); - for (var element : automationComposition.getElements().values()) { + for (var element : automationComposition.getElements().values()) { - var subResult = new BeanValidationResult(ENTRY + element.getDefinition().getName(), element); - Participant p = participantMap.get(element.getParticipantId()); - if (p == null) { - subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, + var subResult = new BeanValidationResult(ENTRY + element.getDefinition().getName(), element); + var p = participantMap.get(element.getParticipantId()); + if (p == null) { + subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, element.getDefinition().getName(), ValidationStatus.INVALID, "Participant with ID " + element.getParticipantId() + " is not registered")); - } else if (!p.getParticipantType().equals(element.getParticipantType())) { - subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, + } else if (!p.getParticipantType().equals(element.getParticipantType())) { + subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, element.getDefinition().getName(), ValidationStatus.INVALID, "Participant with ID " + element.getParticipantType() + " - " + element.getParticipantId() - + " is not registered")); - } - result.addResult(subResult); + + " is not registered")); } - + result.addResult(subResult); } return result; diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java index ba00c0ede..d575a690e 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java @@ -34,10 +34,10 @@ import lombok.RequiredArgsConstructor; import org.onap.policy.clamp.acm.runtime.instantiation.AutomationCompositionInstantiationProvider; import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController; import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; -import org.onap.policy.models.base.PfModelException; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -65,9 +65,8 @@ public class InstantiationController extends AbstractRestController { * Creates a automation composition. * * @param requestId request ID used in ONAP logging - * @param automationCompositions the automation compositions + * @param automationComposition the automation composition * @return a response - * @throws PfModelException on errors creating a automation composition */ // @formatter:off @PostMapping(value = "/instantiation", @@ -116,14 +115,13 @@ public class InstantiationController extends AbstractRestController { } ) // @formatter:on - public ResponseEntity<InstantiationResponse> create( + public ResponseEntity<InstantiationResponse> createCompositionInstance( @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, @ApiParam( value = "Entity Body of automation composition", - required = true) @RequestBody AutomationCompositions automationCompositions) - throws PfModelException { + required = true) @RequestBody AutomationComposition automationComposition) { - return ResponseEntity.ok().body(provider.createAutomationCompositions(automationCompositions)); + return ResponseEntity.ok().body(provider.createAutomationComposition(automationComposition)); } /** @@ -133,7 +131,6 @@ public class InstantiationController extends AbstractRestController { * @param name the name of the automation composition to get, null for all automation compositions * @param version the version of the automation composition to get, null for all automation compositions * @return the automation compositions - * @throws PfModelException on errors getting commissioning of automation composition */ // @formatter:off @GetMapping(value = "/instantiation", @@ -172,15 +169,14 @@ public class InstantiationController extends AbstractRestController { } ) // @formatter:on - public ResponseEntity<AutomationCompositions> query( + public ResponseEntity<AutomationCompositions> queryCompositionInstances( @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, @ApiParam(value = "Automation composition definition name", required = false) @RequestParam( value = "name", required = false) String name, @ApiParam(value = "Automation composition definition version", required = false) @RequestParam( value = "version", - required = false) String version) - throws PfModelException { + required = false) String version) { return ResponseEntity.ok().body(provider.getAutomationCompositions(name, version)); } @@ -189,9 +185,8 @@ public class InstantiationController extends AbstractRestController { * Updates a automation composition. * * @param requestId request ID used in ONAP logging - * @param automationCompositions the automation compositions + * @param automationComposition the automation composition * @return a response - * @throws PfModelException on errors updating of automation compositions */ // @formatter:off @PutMapping(value = "/instantiation", @@ -240,14 +235,13 @@ public class InstantiationController extends AbstractRestController { } ) // @formatter:on - public ResponseEntity<InstantiationResponse> update( + public ResponseEntity<InstantiationResponse> updateCompositionInstance( @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, @ApiParam( value = "Entity Body of Automation Composition", - required = true) @RequestBody AutomationCompositions automationCompositions) - throws PfModelException { + required = true) @RequestBody AutomationComposition automationComposition) { - return ResponseEntity.ok().body(provider.updateAutomationCompositions(automationCompositions)); + return ResponseEntity.ok().body(provider.updateAutomationComposition(automationComposition)); } /** @@ -257,7 +251,6 @@ public class InstantiationController extends AbstractRestController { * @param name the name of the automation composition to delete * @param version the version of the automation composition to delete * @return a response - * @throws PfModelException on errors deleting of automation composition */ // @formatter:off @DeleteMapping(value = "/instantiation", @@ -304,13 +297,12 @@ public class InstantiationController extends AbstractRestController { ) // @formatter:on - public ResponseEntity<InstantiationResponse> delete( + public ResponseEntity<InstantiationResponse> deleteCompositionInstance( @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, @ApiParam(value = "Automation composition definition name", required = true) @RequestParam("name") String name, @ApiParam(value = "Automation composition definition version") @RequestParam( value = "version", - required = true) String version) - throws PfModelException { + required = true) String version) { return ResponseEntity.ok().body(provider.deleteAutomationComposition(name, version)); } @@ -321,7 +313,6 @@ public class InstantiationController extends AbstractRestController { * @param requestId request ID used in ONAP logging * @param command the command to issue to automation compositions * @return the automation composition definitions - * @throws PfModelException on errors issuing a command * @throws AutomationCompositionException on errors issuing a command */ // @formatter:off @@ -367,7 +358,7 @@ public class InstantiationController extends AbstractRestController { @ApiParam( value = "Entity Body of automation composition command", required = true) @RequestBody InstantiationCommand command) - throws AutomationCompositionException, PfModelException { + throws AutomationCompositionException { return ResponseEntity.accepted().body(provider.issueAutomationCompositionCommand(command)); } 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 b01aca5e8..b5d7645da 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 @@ -22,13 +22,11 @@ package org.onap.policy.clamp.acm.runtime.supervision; import io.micrometer.core.annotation.Timed; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import javax.ws.rs.core.Response; import lombok.AllArgsConstructor; -import org.apache.commons.collections4.CollectionUtils; import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher; @@ -52,7 +50,6 @@ import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvide import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -88,43 +85,6 @@ public class SupervisionHandler { private final ParticipantUpdatePublisher participantUpdatePublisher; /** - * Supervision trigger called when a command is issued on automation compositions. - * - * <p/> - * Causes supervision to start or continue supervision on the automation compositions in question. - * - * @param automationCompositionIdentifierList the automation compositions for which the supervision command has been - * issued - * @throws AutomationCompositionException on supervision triggering exceptions - */ - public void triggerAutomationCompositionSupervision( - List<ToscaConceptIdentifier> automationCompositionIdentifierList) throws AutomationCompositionException { - - LOGGER.debug("triggering automation composition supervision on automation compositions {}", - automationCompositionIdentifierList); - - if (CollectionUtils.isEmpty(automationCompositionIdentifierList)) { - // This is just to force throwing of the exception in certain circumstances. - exceptionOccured(Response.Status.NOT_ACCEPTABLE, - "The list of automation compositions for supervision is empty"); - } - - for (ToscaConceptIdentifier automationCompositionId : automationCompositionIdentifierList) { - try { - var automationComposition = - automationCompositionProvider.getAutomationComposition(automationCompositionId); - - superviseAutomationComposition(automationComposition); - - automationCompositionProvider.saveAutomationComposition(automationComposition); - } catch (PfModelException pfme) { - throw new AutomationCompositionException(pfme.getErrorResponse().getResponseCode(), pfme.getMessage(), - pfme); - } - } - } - - /** * Handle a ParticipantStatus message from a participant. * * @param participantStatusMessage the ParticipantStatus message received from a participant @@ -268,23 +228,18 @@ public class SupervisionHandler { private void setAcElementStateInDb(AutomationCompositionAck automationCompositionAckMessage) { if (automationCompositionAckMessage.getAutomationCompositionResultMap() != null) { - try { - var automationComposition = automationCompositionProvider - .getAutomationComposition(automationCompositionAckMessage.getAutomationCompositionId()); - if (automationComposition != null) { - var updated = updateState(automationComposition, + var automationComposition = automationCompositionProvider + .findAutomationComposition(automationCompositionAckMessage.getAutomationCompositionId()); + if (automationComposition.isPresent()) { + var updated = updateState(automationComposition.get(), automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet()); - updated |= setPrimed(automationComposition); - if (updated) { - automationCompositionProvider.saveAutomationComposition(automationComposition); - } - } else { - LOGGER.warn("AutomationComposition not found in database {}", - automationCompositionAckMessage.getAutomationCompositionId()); + updated |= setPrimed(automationComposition.get()); + if (updated) { + automationCompositionProvider.saveAutomationComposition(automationComposition.get()); } - } catch (PfModelException pfme) { - LOGGER.warn("Model exception occured with AutomationComposition Id {}", - automationCompositionAckMessage.getAutomationCompositionId()); + } else { + LOGGER.warn("AutomationComposition not found in database {}", + automationCompositionAckMessage.getAutomationCompositionId()); } } } @@ -327,7 +282,7 @@ public class SupervisionHandler { * @param automationComposition the automation composition to supervises * @throws AutomationCompositionException on supervision errors */ - private void superviseAutomationComposition(AutomationComposition automationComposition) + public void triggerAutomationCompositionSupervision(AutomationComposition automationComposition) throws AutomationCompositionException { switch (automationComposition.getOrderedState()) { case UNINITIALISED: diff --git a/runtime-acm/src/main/resources/openapi/openapi.yaml b/runtime-acm/src/main/resources/openapi/openapi.yaml index 6e07e037d..de7b26ead 100644 --- a/runtime-acm/src/main/resources/openapi/openapi.yaml +++ b/runtime-acm/src/main/resources/openapi/openapi.yaml @@ -696,14 +696,14 @@ paths: post: tags: - Automation Composition Instance - summary: Create automation composition instances - description: Creates automation composition instances that use the sepcified automation composition definition. The IDs of the created - automation composition instances are returned. - operationId: createCompositionInstances + summary: Create automation composition instance + description: Creates automation composition instance that use the sepcified automation composition definition. The ID of the created + automation composition instance is returned. + operationId: createCompositionInstance parameters: - name : compositionId in: path - description: The UUID of the automation composition definition on which to create instances + description: The UUID of the automation composition definition on which to create instance required: true schema: type: string @@ -716,25 +716,25 @@ paths: format: uuid requestBody: description: Serialised instance of - [AutomationCompositions](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java) - containing a list of automation composition instances to create + [AutomationComposition](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java) + containing a automation composition instance to create content: application/json: schema: - $ref: '#/components/schemas/AutomationCompositions' + $ref: '#/components/schemas/AutomationComposition' example: - externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/postCompositionInstances.json' + externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/postCompositionInstance.json' application/yaml: schema: - $ref: '#/components/schemas/AutomationCompositions' + $ref: '#/components/schemas/AutomationComposition' example: - externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/postCompositionInstances.yaml' + externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/postCompositionInstance.yaml' required: true responses: 201: description: Serialised instance of [InstantiationResponse](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java) - containing the UUIDs of the created automation composition instances + containing the UUID of the created automation composition instance headers: X-LatestVersion: schema: @@ -860,8 +860,8 @@ paths: responses: 200: description: Serialised instance of - [AutomationCompositions](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java) - containing a list of automation composition instances with one entry + [AutomationComposition](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java) + containing the automation composition instance headers: X-LatestVersion: schema: @@ -879,12 +879,12 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/AutomationCompositions' + $ref: '#/components/schemas/AutomationComposition' example: externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getCompositionInstanceResponse.json' application/yaml: schema: - $ref: '#/components/schemas/AutomationCompositions' + $ref: '#/components/schemas/AutomationComposition' example: externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getCompositionInstanceResponse.yaml' 401: @@ -1216,6 +1216,9 @@ components: ToscaServiceTemplate: title: ToscaServiceTemplate type: object + AutomationComposition: + title: AutomationComposition + type: object AutomationCompositions: title: AutomationCompositions type: object |