1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
use super::catalog;
use super::config_entry;
use super::health;
use lazy_static::lazy_static;
use serde_derive::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
type ServiceKind = String;
lazy_static! {
pub static ref SERVICE_KIND_TYPICAL: ServiceKind = {
String::new()
};
pub static ref SERVICE_KIND_CONNECT_PROXY: ServiceKind = {
String::from("connect-proxy")
};
pub static ref SERVICE_KIND_MESH_GATEWAY: ServiceKind = {
String::from("mesh-gateway")
};
pub static ref SERVICE_KIND_TERMINATING_GATEWAY: ServiceKind = {
String::from("terminating-gateway")
};
}
type UpstreamDestType = String;
lazy_static! {
pub static ref UPSTREAM_DEST_TYPE_SERVICE: UpstreamDestType = {
String::from("service")
};
pub static ref UPSTREAM_DEST_TYPE_PREPARED_QUERY: UpstreamDestType = {
String::from("prepared_query")
};
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct AgentCheck {
pub Node: Option<String>,
pub CheckID: Option<String>,
pub Name: Option<String>,
pub Status: Option<String>,
pub Notes: Option<String>,
pub Output: Option<String>,
pub ServiceID: Option<String>,
pub ServiceName: Option<String>,
pub Type: Option<String>,
pub Definition: Option<health::HealthCheckDefinition>,
pub Namespace: String,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct Filter {
pub filter: String,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct AgentWeights {
pub Passing: Option<usize>,
pub Warning: Option<usize>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct AgentService {
pub Kind: Option<ServiceKind>,
pub ID: Option<String>,
pub Service: Option<String>,
pub Tags: Option<Vec<String>>,
pub Meta: Option<HashMap<String, String>>,
pub Port: Option<usize>,
pub Address: Option<String>,
pub TaggedAddresses: Option<HashMap<String, catalog::ServiceAddress>>,
pub Weights: Option<AgentWeights>,
pub EnableTagOverride: Option<bool>,
pub CreateIndex: Option<u64>,
pub ModifyIndex: Option<u64>,
pub ContentHash: Option<String>,
pub Proxy: Option<AgentServiceConnectProxyConfig>,
pub Connect: Option<AgentServiceConnect>,
pub Namespace: Option<String>,
pub Datacenter: Option<String>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct AgentServiceChecksInfo {
pub AggregatedStatus: Option<String>,
pub Service: Option<AgentService>,
pub Checks: Option<health::HealthChecks>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct AgentServiceConnect {
pub Native: Option<bool>,
pub SidecarService: Box<Option<AgentServiceRegistration>>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct AgentServiceConnectProxyConfig {
pub DestinationServiceName: Option<String>,
pub DestinationServiceID: Option<String>,
pub LocalServiceAddress: Option<String>,
pub LocalServicePort: Option<String>,
pub Mode: Option<config_entry::ProxyMode>,
pub TransparentProxy: Option<String>,
pub Config: Option<HashMap<String, Value>>,
pub Upstreams: Option<Vec<Upstream>>,
pub MeshGateway: Option<config_entry::MeshGatewayConfig>,
pub Expose: Option<config_entry::ExposeConfig>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct AgentServiceRegistration {
pub Kind: Option<ServiceKind>,
pub ID: Option<String>,
pub Name: Option<String>,
pub Tags: Option<Vec<String>>,
pub Port: Option<usize>,
pub Address: Option<String>,
pub TaggedAddresses: Option<HashMap<String, catalog::ServiceAddress>>,
pub EnableTagOverride: Option<bool>,
pub Meta: Option<HashMap<String, String>>,
pub Weights: Option<AgentWeights>,
pub Check: Option<AgentServiceCheck>,
pub Checks: Option<AgentServiceChecks>,
pub Proxy: Option<AgentServiceConnectProxyConfig>,
pub Connect: Option<AgentServiceConnect>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct ServiceRegisterOpts {
#[serde(rename = "replace-existing-checks")]
pub ReplaceExistingChecks: bool,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct Upstream {
pub DestinationType: Option<UpstreamDestType>,
pub DestinationNamespace: Option<String>,
pub DestinationName: Option<String>,
pub Datacenter: Option<String>,
pub LocalBindAddress: Option<String>,
pub LocalBindPort: Option<usize>,
pub Config: HashMap<String, Value>,
pub MeshGateway: Option<config_entry::MeshGatewayConfig>,
pub CentrallyConfigured: Option<bool>,
}
type AgentServiceChecks = Vec<AgentServiceCheck>;
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct AgentServiceCheck {
pub CheckID: Option<String>,
pub Name: Option<String>,
pub Args: Option<Vec<String>>,
pub DockerContainerID: Option<String>,
pub Shell: Option<String>,
pub Interval: Option<String>,
pub Timeout: Option<String>,
pub TTL: Option<String>,
pub HTTP: Option<String>,
pub Header: Option<HashMap<String, String>>,
pub Method: Option<String>,
pub Body: Option<String>,
pub TCP: Option<String>,
pub Status: Option<String>,
pub Notes: Option<String>,
pub TLSServerName: Option<String>,
pub TLSSkipVerify: Option<bool>,
pub GRPC: Option<String>,
pub GRPCUseTLS: Option<bool>,
pub AliasNode: Option<String>,
pub AliasService: Option<String>,
pub SuccessBeforePassing: Option<i64>,
pub FailuresBeforeCritical: Option<i64>,
pub DeregisterCriticalServiceAfter: Option<String>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct MetricsInfo {
pub Timestamp: Option<String>,
pub Gauges: Option<Vec<GaugeValue>>,
pub Points: Option<Vec<PointValue>>,
pub Counters: Option<Vec<SampledValue>>,
pub Samples: Option<Vec<SampledValue>>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct GaugeValue {
pub Name: Option<String>,
pub Value: Option<f32>,
pub Labels: Option<HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct PointValue {
pub Name: Option<String>,
pub Points: Option<Vec<f32>>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(non_snake_case)]
pub struct SampledValue {
pub Name: Option<String>,
pub Count: Option<i64>,
pub Sum: Option<f64>,
pub Min: Option<f64>,
pub Max: Option<f64>,
pub Mean: Option<f64>,
pub Stddev: Option<f64>,
pub Labels: Option<HashMap<String, String>>,
}