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 com.google.gson.Gson;
26 import java.util.UUID;
27 import javax.ws.rs.Consumes;
28 import javax.ws.rs.DELETE;
29 import javax.ws.rs.POST;
30 import javax.ws.rs.Path;
31 import javax.ws.rs.PathParam;
32 import javax.ws.rs.Produces;
33 import javax.ws.rs.core.MediaType;
34 import org.onap.policy.so.SoRequest;
35 import org.onap.policy.so.SoRequestReferences;
36 import org.onap.policy.so.SoRequestStatus;
37 import org.onap.policy.so.SoResponse;
41 public class SoSimulatorJaxRs {
46 * @param serviceInstanceId the service instance Id
47 * @param vnfInstanceId the VNF Id
48 * @return the response
51 @Path("/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut")
52 @Consumes(MediaType.APPLICATION_JSON)
53 @Produces("application/json")
54 public String soPostQuery(@PathParam("serviceInstanceId") final String serviceInstanceId,
55 @PathParam("vnfInstanceId") final String vnfInstanceId) {
56 return makeCompleteSuccess();
62 * @param serviceInstanceId the service instance Id
63 * @param vnfInstanceId the VNF Id
64 * @return the response
67 @Path("/serviceInstances/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleInstanceId}")
68 @Consumes(MediaType.APPLICATION_JSON)
69 @Produces("application/json")
70 public String soDelete(@PathParam("serviceInstanceId") final String serviceInstanceId,
71 @PathParam("vnfInstanceId") final String vnfInstanceId,
72 @PathParam("vfModuleInstanceId") final String vfModuleInstanceId) {
73 return makeCompleteSuccess();
76 private String makeCompleteSuccess() {
77 final SoRequest request = new SoRequest();
78 final SoRequestStatus requestStatus = new SoRequestStatus();
79 requestStatus.setRequestState("COMPLETE");
80 request.setRequestStatus(requestStatus);
81 request.setRequestId(UUID.randomUUID());
83 final SoResponse response = new SoResponse();
85 final SoRequestReferences requestReferences = new SoRequestReferences();
86 final String requestId = UUID.randomUUID().toString();
87 requestReferences.setRequestId(requestId);
88 response.setRequestReferences(requestReferences);
90 response.setRequest(request);
92 return new Gson().toJson(response);