summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop
diff options
context:
space:
mode:
authorsaul.gill <saul.gill.nordix@gmail.com>2021-06-03 10:17:48 +0100
committersaul.gill <saul.gill@est.tech>2021-06-03 17:03:51 +0100
commitd7226091d3435926271c3d3443e6986f4c985803 (patch)
tree646a919cbfa67d3b7d994b1cfe470b4fb8686b00 /runtime-controlloop
parent20c7487f77d0728d270b2bed34c2c798d17cc12d (diff)
Endpoint added to get Tosca Serivce Template
Issue-Id: POLICY-3222 Change-Id: Ie95bce752019ccfe900205a11bfc28770a7017c9 Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'runtime-controlloop')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java68
1 files changed, 68 insertions, 0 deletions
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
@@ -279,6 +279,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.
*
* @param requestId request ID used in ONAP logging