Use CBS by means of SDK in place of Consul
[dcaegen2/collectors/hv-ves.git] / sources / hv-collector-commandline / src / main / kotlin / org / onap / dcae / collectors / veshv / commandline / CommandLineOption.kt
1 /*
2  * ============LICENSE_START=======================================================
3  * dcaegen2-collectors-veshv
4  * ================================================================================
5  * Copyright (C) 2018-2019 NOKIA
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 package org.onap.dcae.collectors.veshv.commandline
21
22 import org.apache.commons.cli.Option
23
24
25 enum class CommandLineOption(val option: Option, val required: Boolean = false) {
26     HEALTH_CHECK_API_PORT(
27         Option.builder("H")
28             .longOpt("health-check-api-port")
29             .hasArg()
30             .desc("Health check rest api listen port")
31             .build()
32     ),
33     LISTEN_PORT(
34         Option.builder("p")
35             .longOpt("listen-port")
36             .hasArg()
37             .desc("Listen port")
38             .build(),
39         required = true
40     ),
41     CONFIGURATION_FIRST_REQUEST_DELAY(
42         Option.builder("d")
43             .longOpt("first-request-delay")
44             .hasArg()
45             .desc("Delay of first request for configuration in seconds")
46             .build()
47     ),
48     CONFIGURATION_REQUEST_INTERVAL(
49         Option.builder("I")
50             .longOpt("request-interval")
51             .hasArg()
52             .desc("Interval of configuration requests in seconds")
53             .build()
54     ),
55     VES_HV_PORT(
56         Option.builder("v")
57             .longOpt("ves-port")
58             .hasArg()
59             .desc("VesHvCollector port")
60             .build(),
61         required = true
62     ),
63     VES_HV_HOST(
64         Option.builder("h")
65             .longOpt("ves-host")
66             .hasArg()
67             .desc("VesHvCollector host")
68             .build(),
69         required = true
70     ),
71     KAFKA_SERVERS(
72         Option.builder("s")
73             .longOpt("kafka-bootstrap-servers")
74             .hasArg()
75             .desc("Comma-separated Kafka bootstrap servers in <host>:<port> format")
76             .build(),
77         required = true
78     ),
79     KAFKA_TOPICS(
80         Option.builder("f")
81             .longOpt("kafka-topics")
82             .hasArg()
83             .desc("Comma-separated Kafka topics")
84             .build(),
85         required = true
86     ),
87     SSL_DISABLE(
88         Option.builder("l")
89             .longOpt("ssl-disable")
90             .desc("Disable SSL encryption")
91             .build()
92     ),
93     KEY_STORE_FILE(
94         Option.builder("k")
95             .longOpt("key-store")
96             .hasArg()
97             .desc("Key store in PKCS12 format")
98             .build()
99     ),
100     KEY_STORE_PASSWORD(
101             Option.builder("kp")
102                     .longOpt("key-store-password")
103                     .hasArg()
104                     .desc("Key store password")
105                     .build()
106     ),
107     TRUST_STORE_FILE(
108         Option.builder("t")
109             .longOpt("trust-store")
110             .hasArg()
111             .desc("File with trusted certificate bundle in PKCS12 format")
112             .build()
113     ),
114     TRUST_STORE_PASSWORD(
115         Option.builder("tp")
116             .longOpt("trust-store-password")
117             .hasArg()
118             .desc("Trust store password")
119             .build()
120     ),
121     IDLE_TIMEOUT_SEC(
122         Option.builder("i")
123             .longOpt("idle-timeout-sec")
124             .hasArg()
125             .desc(
126                 """Idle timeout for remote hosts. After given time without any data exchange the
127                 |connection might be closed.""".trimMargin()
128             )
129             .build()
130     ),
131     MAXIMUM_PAYLOAD_SIZE_BYTES(
132         Option.builder("m")
133             .longOpt("max-payload-size")
134             .hasArg()
135             .desc("Maximum supported payload size in bytes")
136             .build()
137     ),
138     LOG_LEVEL(
139         Option.builder("ll")
140             .longOpt("log-level")
141             .hasArg()
142             .desc("Log level")
143             .build()
144     ),
145     DUMMY_MODE(
146         Option.builder("u")
147             .longOpt("dummy")
148             .desc("If present will start in dummy mode (dummy external services)")
149             .build()
150     );
151
152     fun environmentVariableName(prefix: String = DEFAULT_ENV_PREFIX): String =
153         option.longOpt.toUpperCase().replace('-', '_').let { mainPart ->
154             "${prefix}_${mainPart}"
155         }
156
157     companion object {
158         private const val DEFAULT_ENV_PREFIX = "VESHV"
159     }
160 }