Update snapshot and/or references of policy/models to latest snapshots
[policy/models.git] / models-interactions / model-simulators / src / main / java / org / onap / policy / simulators / SdncSimulatorJaxRs.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * simulators
4  * ================================================================================
5  * Copyright (C) 2018 Huawei. All rights reserved.
6  * Modifications Copyright (C) 2019, 2023 Nordix Foundation.
7  * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.simulators;
24
25 import jakarta.ws.rs.Consumes;
26 import jakarta.ws.rs.POST;
27 import jakarta.ws.rs.Path;
28 import jakarta.ws.rs.Produces;
29 import jakarta.ws.rs.core.MediaType;
30 import java.util.UUID;
31 import org.onap.policy.sdnc.SdncResponse;
32 import org.onap.policy.sdnc.SdncResponseOutput;
33 import org.onap.policy.sdnc.util.Serialization;
34
35
36 @Path("/restconf/operations/")
37 public class SdncSimulatorJaxRs {
38
39     /**
40      * SDNC post query.
41      *
42      * @return the response
43      */
44     @POST
45     @Path("/GENERIC-RESOURCE-API:network-topology-operation")
46     @Consumes(MediaType.APPLICATION_JSON)
47     @Produces("application/json")
48     public String sdncPostQuery() {
49         return makeSuccessResponse();
50     }
51
52
53     /**
54      * SDNC vf module topology operation.
55      *
56      * @return the response
57      */
58     @POST
59     @Path("/GENERIC-RESOURCE-API:vf-module-topology-operation")
60     @Consumes(MediaType.APPLICATION_JSON)
61     @Produces("application/json")
62     public String sdncVnfTopologyOperation() {
63         return makeSuccessResponse();
64     }
65
66
67     private String makeSuccessResponse() {
68         final var response = new SdncResponse();
69         response.setRequestId(UUID.randomUUID().toString());
70         var responseOutput = new SdncResponseOutput();
71         responseOutput.setResponseCode("200");
72         responseOutput.setAckFinalIndicator("Y");
73         responseOutput.setSvcRequestId(UUID.randomUUID().toString());
74         response.setResponseOutput(responseOutput);
75         return Serialization.gsonPretty.toJson(response);
76     }
77 }