From d7226091d3435926271c3d3443e6986f4c985803 Mon Sep 17 00:00:00 2001 From: "saul.gill" Date: Thu, 3 Jun 2021 10:17:48 +0100 Subject: Endpoint added to get Tosca Serivce Template Issue-Id: POLICY-3222 Change-Id: Ie95bce752019ccfe900205a11bfc28770a7017c9 Signed-off-by: saul.gill --- .../rest/CommissioningController.java | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'runtime-controlloop/src/main/java') diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java index 18e1f7787..4060ae5be 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java @@ -278,6 +278,74 @@ public class CommissioningController extends RestController { } + /** + * Retrieves the Tosca Service Template. + * + * @param requestId request ID used in ONAP logging + * @param name the name of the tosca service template to retrieve + * @param version the version of the tosca service template to get + * @return the specified tosca service template + */ + // @formatter:off + @GET + @Path("/commission/toscaservicetemplate") + @ApiOperation(value = "Query details of the requested tosca service templates", + notes = "Queries details of the requested commissioned tosca service template, " + + "returning all tosca service template details", + response = ToscaServiceTemplate.class, + tags = { + "Clamp Control Loop Commissioning API" + }, + authorizations = @Authorization(value = AUTHORIZATION_TYPE), + responseHeaders = { + @ResponseHeader( + name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION, + response = String.class), + @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION, + response = String.class), + @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION, + response = UUID.class)}, + extensions = { + @Extension( + name = EXTENSION_NAME, + properties = { + @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION), + @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE) + } + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE), + @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE), + @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) + } + ) + // @formatter:on + public Response queryToscaServiceTemplate(@HeaderParam(REQUEST_ID_NAME) + @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, + @ApiParam(value = "Tosca service template name", required = true) + @QueryParam("name") String name, + @ApiParam(value = "Tosca service template version", required = true) + @QueryParam("version") String version) { + + try { + ToscaServiceTemplate response = provider.getToscaServiceTemplate(name, version); + return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response) + .build(); + + } catch (PfModelRuntimeException | PfModelException e) { + LOGGER.warn("Get of tosca service template failed", e); + CommissioningResponse resp = new CommissioningResponse(); + resp.setErrorDetails(e.getErrorResponse().getErrorMessage()); + return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp); + } + + } + /** * Queries the elements of a specific control loop. * -- cgit 1.2.3-korg