2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.simulators;
24 import javax.servlet.http.HttpServletResponse;
25 import javax.ws.rs.Consumes;
26 import javax.ws.rs.GET;
27 import javax.ws.rs.POST;
28 import javax.ws.rs.Path;
29 import javax.ws.rs.PathParam;
30 import javax.ws.rs.Produces;
31 import javax.ws.rs.core.Context;
32 import javax.ws.rs.core.MediaType;
33 import org.slf4j.LoggerFactory;
35 @Path("/api/nslcm/v1")
36 public class VfcSimulatorJaxRs {
41 * @param nsInstanceId the NS instance
42 * @param response the response
43 * @return the response
46 @Path("/ns/{nsInstanceId}/heal")
47 @Consumes(MediaType.APPLICATION_JSON)
48 @Produces("application/json")
49 public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId,
50 @Context final HttpServletResponse response) {
51 response.setStatus(HttpServletResponse.SC_ACCEPTED);
53 response.flushBuffer();
54 } catch (Exception e) {
55 final var logger = LoggerFactory.getLogger(VfcSimulatorJaxRs.class);
56 logger.error("flushBuffer threw: ", e);
60 return "{\"jobId\":\"1\"}";
66 * @param jobId tthe job id
67 * @return the response
70 @Path("/jobs/{jobId}")
71 @Consumes(MediaType.APPLICATION_JSON)
72 @Produces("application/json")
73 public String vfcGetQuery(@PathParam("jobId") String jobId) {
74 return "{\"jobId\" : " + jobId
75 + ",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription"
76 + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\""
77 + "responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription"
78 + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\""
79 + "progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are "
80 + "decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";