2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019 Nordix Foundation.
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.apex.plugins.event.carrier.restclient;
24 import java.util.Arrays;
25 import java.util.HashSet;
27 import java.util.regex.Matcher;
28 import java.util.regex.Pattern;
29 import java.util.regex.PatternSyntaxException;
31 import javax.ws.rs.core.MultivaluedHashMap;
32 import javax.ws.rs.core.MultivaluedMap;
36 import org.apache.commons.lang3.StringUtils;
37 import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters;
38 import org.onap.policy.common.parameters.GroupValidationResult;
39 import org.onap.policy.common.parameters.ValidationStatus;
40 import org.onap.policy.common.utils.validation.ParameterValidationUtils;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
46 * Apex parameters for REST as an event carrier technology with Apex as a REST client.
48 * <p>The parameters for this plugin are:
50 * <li>url: The URL that the Apex Rest client will connect to over REST for event reception or event sending. This
51 * parameter is mandatory.
52 * <li>httpMethod: The HTTP method to use when sending events over REST, legal values are POST (default) and PUT. When
53 * receiving events, the REST client plugin always uses the HTTP GET method.
54 * <li>httpHeaders, the HTTP headers to send on REST requests, optional parameter, defaults to none.
55 * <li>httpCodeFilter: a regular expression filter for returned HTTP codes, if the returned HTTP code passes this
56 * filter, then the request is assumed to have succeeded by the plugin, optional, defaults to allowing 2xx codes
57 * through, that is a regular expression of "[2][0-9][0-9]"
60 * @author Joss Armstrong (joss.armstrong@ericsson.com)
65 public class RestClientCarrierTechnologyParameters extends RestPluginCarrierTechnologyParameters {
66 // Get a reference to the logger
67 private static final Logger LOGGER = LoggerFactory.getLogger(RestClientCarrierTechnologyParameters.class);
69 * Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
72 public RestClientCarrierTechnologyParameters() {
74 CARRIER_TECHNOLOGY_LABEL = "RESTCLIENT";
75 EVENT_PRODUCER_PLUGIN_CLASS = ApexRestClientProducer.class.getName();
76 EVENT_CONSUMER_PLUGIN_CLASS = ApexRestClientConsumer.class.getName();
77 // Set the carrier technology properties for the web socket carrier technology
78 this.setLabel(CARRIER_TECHNOLOGY_LABEL);
79 this.setEventProducerPluginClass(EVENT_PRODUCER_PLUGIN_CLASS);
80 this.setEventConsumerPluginClass(EVENT_CONSUMER_PLUGIN_CLASS);