2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2020 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.Logger;
34 import org.slf4j.LoggerFactory;
36 @Path("/api/nslcm/v1")
37 public class VfcSimulatorJaxRs {
42 * @param nsInstanceId the NS instance
43 * @param response the response
44 * @return the response
47 @Path("/ns/{nsInstanceId}/heal")
48 @Consumes(MediaType.APPLICATION_JSON)
49 @Produces("application/json")
50 public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId,
51 @Context final HttpServletResponse response) {
52 response.setStatus(HttpServletResponse.SC_ACCEPTED);
54 response.flushBuffer();
55 } catch (Exception e) {
56 final Logger logger = LoggerFactory.getLogger(VfcSimulatorJaxRs.class);
57 logger.error("flushBuffer threw: ", e);
61 return "{\"jobId\":\"1\"}";
67 * @param jobId tthe job id
68 * @return the response
71 @Path("/jobs/{jobId}")
72 @Consumes(MediaType.APPLICATION_JSON)
73 @Produces("application/json")
74 public String vfcGetQuery(@PathParam("jobId") String jobId) {
75 return "{\"jobId\" : " + jobId
76 + ",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription"
77 + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\""
78 + "responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription"
79 + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\""
80 + "progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are "
81 + "decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";