2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * Modifications Copyright (C) 2021 Bell Canada.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.distribution.forwarding.testclasses;
24 import io.swagger.annotations.ApiParam;
25 import javax.ws.rs.Consumes;
26 import javax.ws.rs.POST;
27 import javax.ws.rs.Path;
28 import javax.ws.rs.PathParam;
29 import javax.ws.rs.Produces;
30 import javax.ws.rs.core.MediaType;
31 import javax.ws.rs.core.Response;
32 import org.onap.policy.models.pap.concepts.PdpDeployPolicies;
33 import org.onap.policy.models.pap.concepts.PdpGroupDeployResponse;
34 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
37 * Class to provide rest end points for LifecycycleApiSimulator.
39 * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
42 @Produces(MediaType.APPLICATION_JSON)
43 public class LifecycycleApiSimulatorEndpoint {
46 * Create policy type endpoint.
48 * @param body the post body
49 * @return the response object
52 @Path("/api/v1/policytypes")
53 @Consumes(MediaType.APPLICATION_JSON)
54 @Produces(MediaType.APPLICATION_JSON)
55 public Response createPolicyTypes(final ToscaServiceTemplate body) {
56 return Response.status(Response.Status.OK).entity(body).build();
60 * Create policy endpoint.
62 * @param policyTypeId the policy type id
63 * @param policyTypeVersion the policy type version
64 * @param body the post body
65 * @return the response object
68 @Path("/api/v1/policies")
69 @Consumes(MediaType.APPLICATION_JSON)
70 @Produces(MediaType.APPLICATION_JSON)
71 public Response createPolicies(@PathParam("policyTypeId") final String policyTypeId,
72 @PathParam("policyTypeVersion") final String policyTypeVersion,
73 @ApiParam(value = "Entity body of policy", required = true) final ToscaServiceTemplate body) {
74 if ("onap.policies.controlloop.operational.ApexFailure".equals(policyTypeId)) {
75 return Response.status(Response.Status.NOT_FOUND).build();
77 return Response.status(Response.Status.OK).entity(body).build();
82 * Deploy policy endpoint.
84 * @param policies the post body
85 * @return the response object
88 @Path("/pap/v1/pdps/policies")
89 @Consumes(MediaType.APPLICATION_JSON)
90 @Produces(MediaType.APPLICATION_JSON)
91 public Response deployPolicies(final PdpDeployPolicies policies) {
92 return Response.status(Response.Status.OK).entity(new PdpGroupDeployResponse()).build();