acd5e52e80942fc272bb88b00616985906a73479
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.plugins.event.carrier.restrequestor;
22
23 import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
24
25 /**
26  * Apex parameters for REST as an event carrier technology with Apex issuing a REST request and receiving a REST
27  * response.
28  *
29  * <p>The parameters for this plugin are:
30  * <ol>
31  * <li>url: The URL that the Apex Rest Requestor will connect to over REST for REST request sending. This parameter is
32  * mandatory.
33  * <li>httpMethod: The HTTP method to use when making requests over REST, legal values are GET (default), POST, PUT, and
34  * DELETE.
35  * <li>restRequestTimeout: The time in milliseconds to wait for a REST request to complete.
36  * </ol>
37  *
38  * @author Liam Fallon (liam.fallon@ericsson.com)
39  */
40 public class RestRequestorCarrierTechnologyParameters extends CarrierTechnologyParameters {
41     /** The supported HTTP methods. */
42     public enum HttpMethod {
43         GET, PUT, POST, DELETE
44     }
45
46     /** The label of this carrier technology. */
47     public static final String RESTREQUESTOR_CARRIER_TECHNOLOGY_LABEL = "RESTREQUESTOR";
48
49     /** The producer plugin class for the REST carrier technology. */
50     public static final String RESTREQUSTOR_EVENT_PRODUCER_PLUGIN_CLASS =
51             ApexRestRequestorProducer.class.getCanonicalName();
52
53     /** The consumer plugin class for the REST carrier technology. */
54     public static final String RESTREQUSTOR_EVENT_CONSUMER_PLUGIN_CLASS =
55             ApexRestRequestorConsumer.class.getCanonicalName();
56
57     /** The default HTTP method for request events. */
58     public static final HttpMethod DEFAULT_REQUESTOR_HTTP_METHOD = HttpMethod.GET;
59
60     /** The default timeout for REST requests. */
61     public static final long DEFAULT_REST_REQUEST_TIMEOUT = 500;
62
63     private String url = null;
64     private HttpMethod httpMethod = null;
65
66     /**
67      * Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
68      * service.
69      */
70     public RestRequestorCarrierTechnologyParameters() {
71         super();
72
73         // Set the carrier technology properties for the web socket carrier technology
74         this.setLabel(RESTREQUESTOR_CARRIER_TECHNOLOGY_LABEL);
75         this.setEventProducerPluginClass(RESTREQUSTOR_EVENT_PRODUCER_PLUGIN_CLASS);
76         this.setEventConsumerPluginClass(RESTREQUSTOR_EVENT_CONSUMER_PLUGIN_CLASS);
77     }
78
79     /**
80      * Gets the URL for the REST request.
81      *
82      * @return the URL
83      */
84     public String getUrl() {
85         return url;
86     }
87
88     /**
89      * Sets the URL for the REST request.
90      *
91      * @param incomingUrl the URL
92      */
93     public void setUrl(final String incomingUrl) {
94         this.url = incomingUrl;
95     }
96
97     /**
98      * Gets the HTTP method to use for the REST request.
99      *
100      * @return the HTTP method
101      */
102     public HttpMethod getHttpMethod() {
103         return httpMethod;
104     }
105
106     /**
107      * Sets the HTTP method to use for the REST request.
108      *
109      * @param httpMethod the HTTP method
110      */
111     public void setHttpMethod(final HttpMethod httpMethod) {
112         this.httpMethod = httpMethod;
113     }
114
115     /*
116      * (non-Javadoc)
117      *
118      * @see java.lang.Object#toString()
119      */
120
121     @Override
122     public String toString() {
123         return "RESTRequestorCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
124     }
125 }