2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.sim.dmaap.rest;
23 import io.swagger.annotations.ApiOperation;
24 import io.swagger.annotations.ApiResponse;
25 import io.swagger.annotations.ApiResponses;
26 import io.swagger.annotations.Authorization;
27 import javax.ws.rs.GET;
28 import javax.ws.rs.POST;
29 import javax.ws.rs.Path;
30 import javax.ws.rs.PathParam;
31 import javax.ws.rs.QueryParam;
32 import javax.ws.rs.core.Response;
34 import org.onap.policy.models.sim.dmaap.provider.DmaapSimProvider;
37 * Class to provide REST endpoints for DMaaP simulator component statistics.
40 public class DmaapSimRestControllerV1 extends BaseRestControllerV1 {
43 * Get a DMaaP message.
45 * @param topicName topic to get message from
46 * @param consumerGroup consumer group that is getting the message
47 * @param consumerId consumer ID that is getting the message
48 * @param timeout timeout for the message
52 @Path("{topicName}/{consumerGroup}/{consumerId}")
55 value = "Get a DMaaP event on a topic",
56 notes = "Returns an event on a DMaaP topic",
57 response = Object.class,
59 @Authorization(value = AUTHORIZATION_TYPE)
64 code = AUTHENTICATION_ERROR_CODE,
65 message = AUTHENTICATION_ERROR_MESSAGE),
67 code = AUTHORIZATION_ERROR_CODE,
68 message = AUTHORIZATION_ERROR_MESSAGE),
70 code = SERVER_ERROR_CODE,
71 message = SERVER_ERROR_MESSAGE)
75 public Response getDmaaapMessage(@PathParam("topicName") final String topicName,
76 @PathParam("consumerGroup") final String consumerGroup, @PathParam("consumerId") final String consumerId,
77 @QueryParam("timeout") final int timeout) {
79 return new DmaapSimProvider().processDmaapMessageGet(topicName, consumerGroup, consumerId, timeout);
83 * Post a DMaaP message.
85 * @param topicName topic to get message from415
86 * @return the response to the post
92 value = "Post a DMaaP event on a topic",
93 notes = "Returns an event on a DMaaP topic",
94 response = Response.class,
96 @Authorization(value = AUTHORIZATION_TYPE)
101 code = AUTHENTICATION_ERROR_CODE,
102 message = AUTHENTICATION_ERROR_MESSAGE),
104 code = AUTHORIZATION_ERROR_CODE,
105 message = AUTHORIZATION_ERROR_MESSAGE),
107 code = SERVER_ERROR_CODE,
108 message = SERVER_ERROR_MESSAGE)
112 public Response postDmaaapMessage(@PathParam("topicName") final String topicName, final Object dmaapMessage) {
114 return new DmaapSimProvider().processDmaapMessagePut(topicName, dmaapMessage);