Merge "Add data type and policy type reference checking"
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / main / java / org / onap / policy / controlloop / actorserviceprovider / impl / HttpActor.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.controlloop.actorserviceprovider.impl;
22
23 import java.util.Map;
24 import java.util.function.Function;
25 import org.onap.policy.controlloop.actorserviceprovider.Util;
26 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorParams;
27
28 /**
29  * Actor that uses HTTP, where the only additional property that an operator needs is a
30  * URL. The actor's parameters must be an {@link HttpActorParams} and its operator
31  * parameters are expected to be an {@link HttpParams}.
32  */
33 public class HttpActor extends ActorImpl {
34
35     /**
36      * Constructs the object.
37      *
38      * @param name actor's name
39      */
40     public HttpActor(String name) {
41         super(name);
42     }
43
44     /**
45      * Translates the parameters to an {@link HttpActorParams} and then creates a function
46      * that will extract operator-specific parameters.
47      */
48     @Override
49     protected Function<String, Map<String, Object>> makeOperatorParameters(Map<String, Object> actorParameters) {
50         String actorName = getName();
51
52         // @formatter:off
53         return Util.translate(actorName, actorParameters, HttpActorParams.class)
54                         .doValidation(actorName)
55                         .makeOperationParameters(actorName);
56         // @formatter:on
57     }
58 }