59db16743f6535239b3da9f0b1cb3f6f419692c3
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 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
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.grpc;
22
23 import lombok.Getter;
24 import lombok.Setter;
25 import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
26 import org.onap.policy.common.parameters.annotations.Max;
27 import org.onap.policy.common.parameters.annotations.Min;
28 import org.onap.policy.common.parameters.annotations.NotNull;
29
30 // @formatter:off
31 /**
32  * Apex parameters for gRPC as an event carrier technology.
33  *
34  * <p>The parameters for this plugin are:
35  * <ol>
36  * <li>host: The host on which CDS is running. This parameter is mandatory
37  * <li>port: The port on the CDS host to connect to for CDS. This parameter is mandatory.
38  * <li>username: The username for basic authentication to connect to CDS. This parameter is mandatory.
39  * <li>password: The password for basic authentication to connect to CDS. This parameter is mandatory.
40  * <li>timeout: The timeout in seconds for CDS requests. This parameter is mandatory.
41  * </ol>
42  *
43  * @author Ajith Sreekumar(ajith.sreekumar@est.tech)
44  */
45 //@formatter:on
46 @Getter
47 @Setter
48 public class GrpcCarrierTechnologyParameters extends CarrierTechnologyParameters {
49     // @formatter:off
50     private static final int MIN_USER_PORT =  1024;
51     private static final int MAX_USER_PORT = 65535;
52
53     /** The label of this carrier technology. */
54     public static final String GRPC_CARRIER_TECHNOLOGY_LABEL = "GRPC";
55
56     /** The producer plugin class for the grpc carrier technology. */
57     public static final String GRPC_EVENT_PRODUCER_PLUGIN_CLASS = ApexGrpcProducer.class.getName();
58
59     /** The consumer plugin class for the gRPC carrier technology. */
60     public static final String GRPC_EVENT_CONSUMER_PLUGIN_CLASS = ApexGrpcConsumer.class.getName();
61
62     @Min(value = 1)
63     private int timeout;
64
65     @Min(value = MIN_USER_PORT)
66     @Max(value = MAX_USER_PORT)
67     private int port;
68
69     @NotNull
70     private String host;
71
72     @NotNull
73     private String username;
74
75     @NotNull
76     private String password;
77
78
79     /**
80      * Constructor to create a gRPC carrier technology parameters instance and register the instance with the
81      * parameter service.
82      */
83     public GrpcCarrierTechnologyParameters() {
84         super();
85         // Set the carrier technology properties for the gRPC carrier technology
86         this.setLabel(GRPC_CARRIER_TECHNOLOGY_LABEL);
87         this.setEventProducerPluginClass(GRPC_EVENT_PRODUCER_PLUGIN_CLASS);
88         this.setEventConsumerPluginClass(GRPC_EVENT_CONSUMER_PLUGIN_CLASS);
89     }
90 }