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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
# Example YAML to get you started quickly.
# Be aware that YAML has indentation based scoping.
# Code completion support is available so start typing for available options.
swagger: '2.0'
# This is your document metadata
info:
version: "4.0.7"
title: CDAP Broker API
paths:
/:
get:
description: shows some information about this service
responses:
200:
description: successful response
schema:
$ref: '#/definitions/info'
/application:
get:
description: get all applications registered with this broker
responses:
200:
description: successful response
schema:
type: array
items:
$ref: '#/definitions/appname'
/application/delete:
post:
description: endpoint to delete multiple applications at once. Returns an array of status codes, where statuscode[i] = response returned from DELETE(application/i)
parameters:
- name: postbody
in: body
description: required post body
required: true
schema:
$ref: '#/definitions/multideleteput'
responses:
200:
description: successful response
schema:
type: array
items:
$ref: '#/definitions/returncode'
/application/{appname}:
parameters:
- name: appname
in: path
description: Name of the application.
required: true
type: string
format: text
get:
description: Returns the representation of the application resource, including the links for healthcheck and metrics.
responses:
200:
description: Successful response
schema:
$ref: '#/definitions/Application'
404:
description: no app with name 'appname' registered with this broker.
put:
description: Register an app for service and configuration discovery. This will light up a metrics and health endpoint for this app. `appname` is assumed to also be the key in consul.
consumes:
- application/json
produces:
- application/json
parameters:
- name: putbody
in: body
description: required put body
required: true
schema:
$ref: '#/definitions/appput'
responses:
200:
description: Successful response
schema:
$ref: '#/definitions/Application'
400:
description: put was performed but the appname was already registered with the broker, or Invalid PUT body
delete:
description: Remove an app for service and configuration discovery. This will remove the metrics and health endpoints for this app.
responses:
200:
description: Successful response
404:
description: no app with name 'appname' registered with this broker.
/application*/{appname}:
parameters:
- name: appname
in: path
description: Name of the application.
required: true
type: string
format: text
put:
description: (This is a hacky way of supporting "oneOf" because Swagger does not support oneOf https://github.com/OAI/OpenAPI-Specification/issues/333. This is the same endpoint as PUT /application/appname, except the PUT body is different.)
Register a hydrator app for service and configuration discovery. This will light up a metrics and health endpoint for this app. `appname` is assumed to also be the key in consul.
consumes:
- application/json
produces:
- application/json
parameters:
- name: putbody
in: body
description: required put body
required: true
schema:
$ref: '#/definitions/hydratorappput'
responses:
200:
description: Successful response
schema:
$ref: '#/definitions/Application'
400:
description: put was performed but the appname was already registered with the broker, or Invalid PUT body
/application/{appname}/metrics:
get:
# This is array of GET operation parameters:
description: Get live (real-time) app specific metrics for the running app appname. Metrics are customized per each app by the component developer
parameters:
# An example parameter that is in query and is required
- name: appname
in: path
description: Name of the application to get metrics for.
required: true
type: string
format: test
# Expected responses for this operation:
responses:
200:
description: Successful response
schema:
$ref: '#/definitions/MetricsObject'
404:
description: no app with name 'appname' registered with this broker.
/application/{appname}/healthcheck:
get:
# This is array of GET operation parameters:
description: Perform a healthcheck on the running app appname.
parameters:
# An example parameter that is in query and is required
- name: appname
in: path
description: Name of the application to get the healthcheck for.
required: true
type: string
format: test
# Expected responses for this operation:
responses:
# Response code
200:
description: Successful response, healthcheck pass
404:
description: no app with name 'appname' registered with this broker, or the healthcheck has failed (though I would like to disambiguiate from the first case, CDAP returns a 404 for this).
/application/{appname}/reconfigure:
parameters:
- name: appname
in: path
description: Name of the application.
required: true
type: string
format: text
put:
description: Reconfigures the application.
parameters:
- name: putbody
in: body
description: required put body
required: true
schema:
$ref: '#/definitions/reconfigput'
responses:
200:
description: Successful response
400:
description: Bad request. Can happen with 1) {appname} is not registered with the broker, 2) the required PUT body is wrong, or 3) the smart interface was chosen and none of the config keys match anything in app_config or app_preferences
definitions:
MetricsObject:
type: object
description: key,value object where the key is 'appmetrics' and the value is an app dependent json and specified by the component developer
properties:
appmetrics:
type: object
Application:
type: object
properties:
appname:
description: application name
type: string
healthcheckurl:
description: fully qualified url to perform healthcheck
type: string
metricsurl:
description: fully qualified url to get metrics from
type: string
url:
description: fully qualified url of the resource
type: string
connectionurl:
description: input URL that you can POST data into (URL of the CDAP stream)
type: string
serviceendpoints:
description: a list of HTTP services exposed by this CDAP application
type: array
items:
$ref: '#/definitions/service_method'
reconfigput:
type: object
properties:
reconfiguration_type:
description: the type of reconfiguration
type: string
enum: ["program-flowlet-app-config", "program-flowlet-app-preferences", "program-flowlet-smart"]
config:
description: the config JSON
type: object
required: ["reconfiguration_type", "config"]
multideleteput:
type: object
properties:
appnames:
type: array
items:
$ref: '#/definitions/appname'
appname:
description: an application name
type: string
hydratorappput:
type: object
properties:
cdap_application_type:
description: denotes whether this is a program-flowlet style application or a hydrator pipeline. For hydrator, this value must be "hydrator-pipeline"
type: string
enum: ["hydrator-pipeline"]
namespace:
description: the cdap namespace this is deployed into
type: string
pipeline_config_json_url:
description: the URL of the config.json for this pipeline
type: string
streamname:
description: name of the CDAP stream to ingest data into this app. Should come from the developer and Tosca model.
type: string
dependencies:
description: represents a list of dependencies to be loaded for this pipeline. Not required.
type: array
items:
$ref: '#/definitions/hydratordep'
required: ["cdap_application_type", "namespace", "pipeline_config_json_url", "streamname"]
appput:
type: object
properties:
cdap_application_type:
description: denotes whether this is a program-flowlet style application or a hydrator pipeline. For program-flowlet style apps, this value must be "program-flowlet"
type: string
enum: ["program-flowlet"]
streamname:
description: name of the CDAP stream to ingest data into this app. Should come from the developer and Tosca model.
type: string
namespace:
description: the cdap namespace this is deployed into
type: string
jar_url:
description: the URL that the JAR you're deploying resides
type: string
artifact_name:
description: the name of the CDAP artifact to be added
type: string
artifact_ver:
description: the version of the artifact. Must be in X.Y.Z form
app_config:
description: the application config JSON
type: object
app_preferences:
description: the application preferences JSON
type: object
programs:
type: array
items:
$ref: '#/definitions/programs'
program_preferences:
type: array
items:
$ref: '#/definitions/programpref'
services:
type: array
items:
$ref: '#/definitions/service_endpoint'
service_endpoint:
description: descirbes a service endpoint, including the service name, the method name, and the method type (GET, PUT, etc, most of the time will be GET)
type: object
properties:
service_name:
type: string
description: the name of the service
service_endpoint:
type: string
description: the name of the endpoint on the service
endpoint_method:
type: string
description: GET, POST, PUT, etc
service_method:
description: a URL and HTTP method exposed via a CDAP service
type: object
properties:
url:
type: string
description: the fully qualified URL in CDAP for this service
method:
type: string
description: HTTP method you can perform on the URL, e.g., GET, PUT, etc
programs:
description: the list of programs in this CDAP app
type: object
properties:
program_type:
description: must be one of flows, mapreduce, schedules, spark, workflows, workers, or services
type: string
program_id:
description: the name of the program
type: string
returncode:
description: an httpreturncode
type: integer
hydratordep:
description: represents a hydrator pipeline dependency. An equivelent to the following CURLs are formed with the below four params shown in CAPS "curl -v -w"\n" -X POST http://cdapurl:11015/v3/namespaces/setelsewhere/artifacts/ARTIFACT_NAME -H "Artifact-Extends:ARTIFACT_EXTENDS_HEADER" -H “Artifact-Version:ARTIFACT_VERSION_HEADER” --data-binary @(DOWNLOADED FROM ARTIFACT_URL)","curl -v -w"\n" -X PUT http://cdapurl:11015/v3/namespaces/setelsewhere/artifacts/ARTIFACT_NAME/versions/ARTIFACT_VERSION_HEADER/properties -d (DOWNLOADED FROM UI_PROPERTIES_URL)"
properties:
artifact_extends_header:
description: the value of the header that gets passed in for artifact-extends, e.g., "Artifact-Extends:system:cdap-data-pipeline[4.0.1,5.0.0)"
type: string
artifact_name:
description: the name of the artifact
type: string
artifact_version_header :
description: the value of the header that gets passed in for artifact-version, e.g., "Artifact-Version:1.0.0-SNAPSHOT"
type: string
artifact_url:
description: the URL of the artifact JAR
type: string
ui_properties_url:
description: the URL of the properties.json if the custom artifact has UI properties. This is optional.
type: string
required: ["artifact_extends_header", "artifact_name", "artifact_version_header", "artifact_url"]
programpref:
description: the list of programs in this CDAP app
type: object
properties:
program_type:
description: must be one of flows, mapreduce, schedules, spark, workflows, workers, or services
type: string
program_id:
description: the name of the program
type: string
program_pref:
description: the preference JSON to set for this program
type: object
info:
description: some broker information
type: object
properties:
managed cdap url:
description: the url of the CDAP cluster API this broker is managing
type: string
number of applications registered:
type: integer
uptime (s):
type: integer
cdap GUI port:
type: integer
description: The GUI port of the CDAP cluster this broker is managing. Mostly to help users of this API check their application in cdap. Note, will return UNKNOWN_CDAP_VERSION if it cannot be determined.
cdap cluster version:
type: string
description: the version of the CDAP cluster this broker is managing. Note, will return UKNOWN_CDAP_VERSION if it cannot be determined.
broker API version:
type: string
description: the API version of this running broker
|