blob: 0e0b4b43b598dcc981254083000faba05f0c040c [file] [log] [blame]
Jian Li52c11222018-06-07 11:39:17 +09001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.openstacktelemetry.api.config;
17
Jian Li69600e02018-12-24 13:21:18 +090018import org.onosproject.net.Annotations;
19
20import java.util.List;
21import java.util.Map;
22import java.util.Optional;
23
Jian Li52c11222018-06-07 11:39:17 +090024/**
Jian Li69600e02018-12-24 13:21:18 +090025 * An interface for telemetry config.
Jian Li52c11222018-06-07 11:39:17 +090026 */
Jian Li69600e02018-12-24 13:21:18 +090027public interface TelemetryConfig extends Annotations {
Jian Li52c11222018-06-07 11:39:17 +090028
Jian Li69600e02018-12-24 13:21:18 +090029 /**
30 * Telemetry configuration type.
31 */
32 enum ConfigType {
33 /**
34 * Indicates KAFKA telemetry config.
35 */
36 KAFKA,
Jian Li52c11222018-06-07 11:39:17 +090037
Jian Li69600e02018-12-24 13:21:18 +090038 /**
39 * Indicates GRPC telemetry config.
40 */
41 GRPC,
42
43 /**
44 * Indicates REST telemetry config.
45 */
46 REST,
47
48 /**
49 * Indicates InfluxDB telemetry config.
50 */
51 INFLUXDB,
52
53 /**
54 * Indicates prometheus telemetry config.
55 */
56 PROMETHEUS,
57
58 /**
59 * Indicates unknown telemetry config.
60 */
61 UNKNOWN
Jian Li52c11222018-06-07 11:39:17 +090062 }
Jian Li69600e02018-12-24 13:21:18 +090063
64 /**
65 * Returns the telemetry configuration name.
66 *
67 * @return configuration name
68 */
69 String name();
70
71 /**
72 * Returns the telemetry configuration type.
73 *
74 * @return configuration type
75 */
76 ConfigType type();
77
78 /**
79 * Returns all the parent configurations from which this configuration inherits
80 * properties.
81 *
82 * @return list of parent configurations
83 */
84 List<TelemetryConfig> parents();
85
86 /**
87 * Returns the off-platform application manufacturer name.
88 *
89 * @return manufacturer name
90 */
91 String manufacturer();
92
93 /**
94 * Returns the off-platform application software version.
95 *
96 * @return software version
97 */
98 String swVersion();
99
100 /**
101 * Returns the service enable flag.
102 *
103 * @return enable flag
104 */
105 boolean enabled();
106
107 /**
108 * Returns the set of annotations as map of key/value properties.
109 *
110 * @return map of properties
111 */
112 Map<String, String> properties();
113
114 /**
115 * Gets the value of the given property name.
116 *
117 * @param name property name
118 * @return the value of the property,
119 * or null if the property is not defined in this configuration nor
120 * in any of its ancestors
121 */
122 String getProperty(String name);
123
124 /**
125 * Get the value of the given property name.
126 *
127 * @param name property name
128 * @param defaultValue to use if the property is not defined in this configuration
129 * nor in any of its ancestors
130 * @return the value of the property,
131 * or null if the property is not defined in this configuration nor
132 * in any of its ancestors
133 */
134 default String getProperty(String name, String defaultValue) {
135 return Optional.ofNullable(getProperty(name)).orElse(defaultValue);
136 }
137
138 /**
139 * Merges the specified config properties into this one, giving preference to
140 * the other config when dealing with conflicts.
141 *
142 * @param other other configuration
143 * @return merged configuration
144 */
145 TelemetryConfig merge(TelemetryConfig other);
Jian Li16f1f532018-12-27 17:45:09 +0900146
147 /**
148 * Obtains the cloned instance with updated properties.
149 *
150 * @param properties telemetry config properties
151 * @return a cloned instance
152 */
153 TelemetryConfig updateProperties(Map<String, String> properties);
154
155 /**
156 * Obtains the cloned instance with updated enabled value.
157 *
158 * @param enabled service flag
159 * @return a cloned instance
160 */
161 TelemetryConfig updateEnabled(boolean enabled);
Jian Li52c11222018-06-07 11:39:17 +0900162}