blob: b76082009e846ab1f09676857da89ab56068360c [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
Jian Li667c6eb2019-01-07 23:01:12 +090064 enum Status {
65 /**
66 * Signifies that the service is in enable status.
67 */
68 ENABLED,
69
70 /**
71 * Signifies that the service is in disable status.
72 */
73 DISABLED,
74
75 /**
76 * Signifies that the service is in pending status.
77 */
78 PENDING,
79
80 /**
81 * Signifies that the service is in unknown status.
82 */
83 UNKNOWN,
84 }
85
Jian Li69600e02018-12-24 13:21:18 +090086 /**
87 * Returns the telemetry configuration name.
88 *
89 * @return configuration name
90 */
91 String name();
92
93 /**
94 * Returns the telemetry configuration type.
95 *
96 * @return configuration type
97 */
98 ConfigType type();
99
100 /**
101 * Returns all the parent configurations from which this configuration inherits
102 * properties.
103 *
104 * @return list of parent configurations
105 */
106 List<TelemetryConfig> parents();
107
108 /**
109 * Returns the off-platform application manufacturer name.
110 *
111 * @return manufacturer name
112 */
113 String manufacturer();
114
115 /**
116 * Returns the off-platform application software version.
117 *
118 * @return software version
119 */
120 String swVersion();
121
122 /**
Jian Li667c6eb2019-01-07 23:01:12 +0900123 * Returns the service status.
Jian Li69600e02018-12-24 13:21:18 +0900124 *
Jian Li667c6eb2019-01-07 23:01:12 +0900125 * @return service status
Jian Li69600e02018-12-24 13:21:18 +0900126 */
Jian Li667c6eb2019-01-07 23:01:12 +0900127 Status status();
Jian Li69600e02018-12-24 13:21:18 +0900128
129 /**
130 * Returns the set of annotations as map of key/value properties.
131 *
132 * @return map of properties
133 */
134 Map<String, String> properties();
135
136 /**
137 * Gets the value of the given property name.
138 *
139 * @param name property name
140 * @return the value of the property,
141 * or null if the property is not defined in this configuration nor
142 * in any of its ancestors
143 */
144 String getProperty(String name);
145
146 /**
147 * Get the value of the given property name.
148 *
149 * @param name property name
150 * @param defaultValue to use if the property is not defined in this configuration
151 * nor in any of its ancestors
152 * @return the value of the property,
153 * or null if the property is not defined in this configuration nor
154 * in any of its ancestors
155 */
156 default String getProperty(String name, String defaultValue) {
157 return Optional.ofNullable(getProperty(name)).orElse(defaultValue);
158 }
159
160 /**
161 * Merges the specified config properties into this one, giving preference to
162 * the other config when dealing with conflicts.
163 *
164 * @param other other configuration
165 * @return merged configuration
166 */
167 TelemetryConfig merge(TelemetryConfig other);
Jian Li16f1f532018-12-27 17:45:09 +0900168
169 /**
170 * Obtains the cloned instance with updated properties.
171 *
172 * @param properties telemetry config properties
173 * @return a cloned instance
174 */
175 TelemetryConfig updateProperties(Map<String, String> properties);
176
177 /**
Jian Li667c6eb2019-01-07 23:01:12 +0900178 * Obtains the cloned instance with updated status.
Jian Li16f1f532018-12-27 17:45:09 +0900179 *
Jian Li667c6eb2019-01-07 23:01:12 +0900180 * @param status service status
Jian Li16f1f532018-12-27 17:45:09 +0900181 * @return a cloned instance
182 */
Jian Li667c6eb2019-01-07 23:01:12 +0900183 TelemetryConfig updateStatus(Status status);
Jian Li52c11222018-06-07 11:39:17 +0900184}