-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathopenapi.yaml
More file actions
356 lines (331 loc) · 11.1 KB
/
openapi.yaml
File metadata and controls
356 lines (331 loc) · 11.1 KB
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# Copyright 2020, locate Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [START swagger]
swagger: "2.0"
info:
description: |-
The locate API provides consistent, expected measurement quality for M-Lab
clients.
title: "M-Lab Locate API ({{DEPLOYMENT}})"
version: "2.0.0"
host: "locate-dot-{{PROJECT}}.appspot.com"
# [END swagger]
consumes:
- "application/json"
produces:
- "application/json"
schemes:
- "https"
- "wss"
paths:
# Shared "nearest" requests without an API key.
"/v2/nearest/{name}/{type}":
get:
description: |-
Find the nearest healthy service.
All requests are scheduled as part of a "shared" resource pool. This
is a good choice for small client integrations. When the platform is
overloaded and the locate API must choose which requests to allow and
which to block, priority is given to requests using explicit API keys
to the /v2/priority/* resource.
This resource does not require an API key. All requests to this resource
are managed collectively as if they all used a single API key.
operationId: "v2-shared-nearest"
produces:
- "application/json"
parameters:
- name: name
in: path
description: The service name, e.g. "ndt", "neubot", "wehe", etc.
type: string
required: true
- name: type
in: path
description: The service type, e.g. "ndt7", "dash", "replay", etc.
type: string
required: true
responses:
# NOTE: non-number values are a schema error for the config, despite
# openapi documentation.
'200':
description: The result of the nearest request. Clients should use the
next request fields to schedule the next request in the event of
error or batch scheduling.
schema:
$ref: "#/definitions/NearestResult"
'500':
description: An error occurred while looking for the service.
Clients should use the next request fields to schedule the next
request in the event of error.
schema:
$ref: "#/definitions/ErrorResult"
tags:
- public
# Priority "nearest" requests WITH an API key.
"/v2/priority/nearest/{name}/{type}":
get:
description: |-
Find the nearest healthy service.
This resource requires an API key. When the system is under sufficient
load that the locate API must choose which requests to allow and which
to reject, these requests are prioritized over "shared" requests.
operationId: "v2-priority-nearest"
produces:
- "application/json"
parameters:
- name: name
in: path
description: service
type: string
required: true
- name: type
in: path
description: datatype
type: string
required: true
responses:
'200':
description: The result of the nearest request. Clients should use the
next request fields to schedule the next request for batch
scheduling.
schema:
$ref: "#/definitions/NearestResult"
'500':
description: An error occurred while looking for the service.
Clients should use the next request fields to schedule the next
request in the event of error.
schema:
$ref: "#/definitions/ErrorResult"
security:
- jwt_auth: []
tags:
- public
options:
description: CORS preflight request handler.
operationId: "v2-priority-nearest-cors"
parameters:
- name: name
in: path
description: service
type: string
required: true
- name: type
in: path
description: datatype
type: string
required: true
responses:
'200':
description: CORS preflight response.
tags:
- public
"/v2/platform/heartbeat":
get:
description: |-
Platform-specific path. Protected by API key authentication.
operationId: "v2-platform-heartbeat"
responses:
'200':
description: OK.
security:
- api_key: []
tags:
- platform
"/v2/platform/heartbeat-jwt":
get:
description: |-
Platform-specific path. Protected by JWT authentication with organization validation.
The JWT token must include an "org" claim that matches the organization in the hostname
of any heartbeat registration or health update messages.
operationId: "v2-platform-heartbeat-jwt"
responses:
'200':
description: OK.
'401':
description: Unauthorized - invalid JWT token or missing/invalid org claim.
'403':
description: Forbidden - organization mismatch between JWT and hostname.
security:
- jwt_auth: []
tags:
- platform
"/v2/platform/prometheus":
get:
description: |-
Platform-specific path.
operationId: "v2-platform-prometheus"
responses:
'200':
description: OK.
security:
- api_key: []
tags:
- platform
"/v2/platform/monitoring/{name}/{type}":
get:
description: |-
Platform-specific path.
operationId: "v2-platform-monitoring"
parameters:
- name: name
in: path
description: service
type: string
required: true
- name: type
in: path
description: datatype
type: string
required: true
responses:
'200':
description: OK.
tags:
- platform
"/v2/siteinfo/registrations":
get:
description: |-
Returns heartbeat registration information in various formats.
operationId: "v2-siteinfo-registrations"
produces:
- "application/json"
responses:
'200':
description: OK.
'500':
description: Error.
tags:
- siteinfo
# Legacy mlab-ns compatibility
# TODO(https://github.com/m-lab/locate/issues/185)
"/ndt":
get:
description: |-
Compatibility endpoint for the retired mlab-ns /ndt resource.
This endpoint exists solely to support known integrators that have not
yet completed their migration away from mlab-ns. It returns ndt7 server
metadata in the legacy mlab-ns JSON format.
No support is offered for this resource. It will be removed once affected
integrators confirm they no longer depend on it.
See https://github.com/m-lab/locate/issues/185.
operationId: "v1-ndt"
produces:
- "application/json"
responses:
'200':
description: The result of the request.
'204':
description: No results available.
'400':
description: Unsupported query parameter value.
'501':
description: Unsupported HTTP method.
'502':
description: The inner nearest lookup failed.
tags:
- public
definitions:
# Define the query reply without being specific about the structure.
ErrorResult:
type: object
properties:
error:
type: object
properties:
type:
type: string
description: The error type.
title:
type: string
description: A descriptive title for this error.
status:
type: integer
description: The HTTP status code of this error, e.g. 4xx or 5xx.
detail:
type: string
instance:
type: string
next_request:
$ref: "#/definitions/NextRequest"
NearestResult:
type: object
properties:
next_request:
$ref: "#/definitions/NextRequest"
description: The next request defines the earliest time that a client
should make a new request using the included URL.
results:
type: array
items:
type: object
properties:
machine:
type: string
description: The machine name that all URLs reference.
location:
type: object
additionalProperties: {}
description: The machine location metadata.
urls:
type: object
additionalProperties: {}
description: Specific service URLs with access tokens.
NextRequest:
type: object
properties:
nbf:
type: string
description: |-
"not before" defines the time after which the URL will
become valid. This value is the same time used in "nbf" field of
the underlying JSON Web Token (JWT) claim. To show this equivalence,
we use the same name.
exp:
type: string
description: |-
Expires defines the time after which the URL will be invalid.
Expires will always be greater than NotBefore. This value is the
same time used in the "exp" field of the underlying JWT claim.
url:
type: string
description: |-
URL should be used to make the next request to the location service.
securityDefinitions:
# This section configures basic authentication with an API key.
# Paths configured with api_key security require an API key for all requests.
api_key:
type: "apiKey"
description: |-
An API key for your client integration restricted to the Locate API and
allocated using a self-service [signup](https://docs.google.com/forms/d/e/1FAIpQLSeWMiPSRWHIcg5GVRG-oc5kkefLpR4Nqk4aNYBFK6Wr8jAAdw/viewform)
or allocated by M-Lab for your client integration.
name: "key"
in: "query"
# This section configures JWT authentication for heartbeat endpoints.
# Paths configured with jwt_auth security require a valid JWT token with an "org" claim.
jwt_auth:
authorizationUrl: "" # Required for swagger 2.0 oauth2, but not used by ESPv2/Apigee
flow: "implicit" # Required for swagger 2.0 oauth2, but not used by ESPv2/Apigee
type: "oauth2"
# x-google-jwks_uri and x-google-issuer identify the service that issues JWTs.
x-google-issuer: "token-exchange"
x-google-jwks_uri: "https://auth.{{PLATFORM_PROJECT}}.measurementlab.net/.well-known/jwks.json"
# x-google-audiences are the audiences JWTs are allowed to target.
# The audience must match the JWT token audience from token-exchange service.
x-google-audiences: "autojoin,locate,integration"
tags:
- name: public
description: Public API.
- name: platform
description: Platform API.