Merge "move two modules from drools-application to models"
[policy/models.git] / models-interactions / model-simulators / src / main / java / org / onap / policy / simulators / SoSimulatorJaxRs.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * simulators
4  * ================================================================================
5  * Copyright (C) 2017-2019 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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.policy.simulators;
23
24 import com.att.aft.dme2.internal.gson.Gson;
25 import java.util.UUID;
26 import javax.ws.rs.Consumes;
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.MediaType;
32 import org.onap.policy.so.SoRequest;
33 import org.onap.policy.so.SoRequestReferences;
34 import org.onap.policy.so.SoRequestStatus;
35 import org.onap.policy.so.SoResponse;
36
37 @Path("/serviceInstantiation")
38 public class SoSimulatorJaxRs {
39
40     /**
41      * SO post query.
42      *
43      * @param serviceInstanceId the service instance Id
44      * @param vnfInstanceId the VNF Id
45      * @return the response
46      */
47     @POST
48     @Path("/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut")
49     @Consumes(MediaType.APPLICATION_JSON)
50     @Produces("application/json")
51     public String soPostQuery(@PathParam("serviceInstanceId") final String serviceInstanceId,
52                     @PathParam("vnfInstanceId") final String vnfInstanceId) {
53         final SoRequest request = new SoRequest();
54         final SoRequestStatus requestStatus = new SoRequestStatus();
55         requestStatus.setRequestState("COMPLETE");
56         request.setRequestStatus(requestStatus);
57         request.setRequestId(UUID.randomUUID());
58
59         final SoResponse response = new SoResponse();
60
61         final SoRequestReferences requestReferences = new SoRequestReferences();
62         final String requestId = UUID.randomUUID().toString();
63         requestReferences.setRequestId(requestId);
64         response.setRequestReferences(requestReferences);
65
66         response.setRequest(request);
67
68         return new Gson().toJson(response);
69     }
70 }