+
+ @PUT
+ @Path("/services/{serviceId}/toscaTemplate")
+ @Tag(name = "SDCE-2 APIs")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Operation(description = "Update service by tosca template import", method = "PUT", summary = "Returns updated service",
+ responses = {
+ @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Service.class)))),
+ @ApiResponse(responseCode = "200", description = "Service Updated"),
+ @ApiResponse(responseCode = "403", description = "Restricted operation"),
+ @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")})
+ public Response importToscaTemplate(@PathParam("serviceId") final String serviceId,
+ @Parameter(description = "Service object to be Updated", required = true) final String data,
+ @Context final HttpServletRequest request,
+ @HeaderParam(value = Constants.USER_ID_HEADER) final String userId) throws IOException {
+ initSpringFromContext();
+ final User modifier = getUser(request);
+ try {
+ final ServiceImportBusinessLogic serviceImportBusinessLogic = serviceImportManager.getServiceImportBusinessLogic();
+ final Service updatedService = serviceImportBusinessLogic.updateServiceFromToscaTemplate(serviceId, modifier, data);
+ return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), RepresentationUtils.toRepresentation(updatedService));
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Update Service Metadata");
+ log.error("update service metadata failed with exception", e);
+ throw e;
+ }
+ }
+
+ @PUT
+ @Path("/services/{serviceId}/toscaModel")
+ @Tag(name = "SDCE-2 APIs")
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Operation(description = "Update service by tosca template model", method = "PUT", summary = "Returns updated service",
+ responses = {
+ @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Service.class)))),
+ @ApiResponse(responseCode = "200", description = "Service Updated"),
+ @ApiResponse(responseCode = "403", description = "Restricted operation"),
+ @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")})
+ public Response importToscaModel(@PathParam("serviceId") final String serviceId,
+ @NotNull @FormDataParam("upload") final InputStream fileToUpload,
+ @Context final HttpServletRequest request,
+ @HeaderParam(value = Constants.USER_ID_HEADER) final String userId) throws IOException {
+ initSpringFromContext();
+ final User modifier = getUser(request);
+ try {
+ final ServiceImportBusinessLogic serviceImportBusinessLogic = serviceImportManager.getServiceImportBusinessLogic();
+ final Service updatedService = serviceImportBusinessLogic.updateServiceFromToscaModel(serviceId, modifier, fileToUpload);
+ return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), RepresentationUtils.toRepresentation(updatedService));
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Update Service Metadata");
+ log.error("update service metadata failed with exception", e);
+ throw e;
+ }
+ }
+