2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2023 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.controlloop.actorserviceprovider.impl;
25 import java.util.function.Function;
26 import org.onap.policy.controlloop.actorserviceprovider.Util;
27 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorParams;
30 * Actor that uses HTTP, where the only additional property that an operator needs is a
31 * URL. The actor's operator parameters are expected to be an
32 * {@link org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams}.
34 * @param <P> type of parameters
36 public class HttpActor<P extends HttpActorParams> extends ActorImpl {
39 * Class of Actor parameters.
41 private final Class<P> paramsClass;
44 * Constructs the object.
46 * @param name actor's name
47 * @param paramsClass class of parameters
49 public HttpActor(String name, Class<P> paramsClass) {
51 this.paramsClass = paramsClass;
55 * Translates the parameters to an {@link HttpActorParams} and then creates a function
56 * that will extract operator-specific parameters.
59 protected Function<String, Map<String, Object>> makeOperatorParameters(Map<String, Object> actorParameters) {
60 String actorName = getName();
63 return Util.translate(actorName, actorParameters, paramsClass)
64 .doValidation(actorName)
65 .makeOperationParameters(actorName);