forked from projectsyn/lieutenant-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi.yaml
542 lines (542 loc) · 16.9 KB
/
openapi.yaml
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
openapi: '3.0.2'
info:
title: Lieutenant API
description: Project Syn Management API
contact:
name: VSHN AG
email: [email protected]
url: https://vshn.ch
version: 0.0.1
license:
name: BSD 3-Clause License
url: https://choosealicense.com/licenses/bsd-3-clause/
servers:
- url: https://api.syn.vshn.net/
description: Project Syn Lieutenant Production API
- url: https://api-dev.syn.vshn.net/
description: Project Syn Lieutenant Test API
- url: /
description: Local development
security:
- BearerAuth: []
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
Id:
type: string
description: >
A unique object identifier string. Automatically generated by the API on creation (in the form
"<letter>-<adjective>-<noun>-<digits>" where all letters are lowercase, max 63 characters in total).
readOnly: true
TenantProperties:
type: object
description: |-
A tenant defition object.
It can belong to another tenant to allow for tenant hierarchies.
The Git repository is usually managed by the API and autogenerated.
All properties except name are optional on creation.
properties:
displayName:
type: string
description: Display name of the tenant
example: Acme Corp.
tenant:
type: string
description: The tenant this tenant belongs to
example: multicorp
nullable: true
gitRepo:
$ref: '#/components/schemas/GitRepo'
TenantId:
type: object
required:
- id
properties:
id:
$ref: '#/components/schemas/Id'
Tenant:
allOf:
- $ref: '#/components/schemas/TenantId'
- $ref: '#/components/schemas/TenantProperties'
ClusterProperties:
type: object
required:
- tenant
description: |-
A cluster defition object.
The Git repository is usually managed by the API and autogenerated.
The sshDeployKey will be managed by Steward
properties:
displayName:
type: string
description: Display Name of the cluster
example: My very important cluster
facts:
$ref: '#/components/schemas/ClusterFacts'
gitRepo:
$ref: '#/components/schemas/GitRepo'
tenant:
type: string
description: Id of the tenant this cluster belongs to
example: aezoo6
installURL:
type: string
readOnly: true
description: URL to fetch install manifests for Steward cluster agent. This will only be set if the cluster's token is still valid.
example: https://api.syn.vshn.net/install/steward.json?token=<secretToken>
ClusterId:
type: object
required:
- id
properties:
id:
$ref: '#/components/schemas/Id'
ClusterFacts:
type: object
description: Facts about a cluster object. Statically configured key/value pairs.
example:
distribution: openshift4
cloud: aws
region: eu-west-1
Cluster:
allOf:
- $ref: '#/components/schemas/ClusterId'
- $ref: '#/components/schemas/ClusterProperties'
Reason:
type: object
required:
- reason
description: A reason for responses
properties:
reason:
type: string
description: The reason message
example: Because of reasons
Inventory:
type: object
required:
- cluster
description: Inventory data of a cluster
properties:
cluster:
type: string
inventory:
type: object
GitRepo:
type: object
description: Configuration Git repository, usually generated by the API
properties:
url:
type: string
description: Full URL of the git repo
example: ssh://[email protected]/acmecorp/gitops-mycluster.git
type:
type: string
description: Specifies if a repo should be managed by the git controller. A value of 'unmanaged' means it's not manged by the controller
example: auto
default: auto
deployKey:
type: string
description: SSH public key / deploy key for clusterconfiguration catalog Git repository. This property is managed by Steward.
example: |
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDG9a5WwLuwcxMRydNqI4ofuzXucrBKpGOvPV9PO4guj
hostKeys:
type: string
description: SSH known hosts of the git server (multiline possible for multiple keys)
example: |
gitlab.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjquxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf
gitlab.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFSMqzJeV9rUzU4kWitGjeR4PWSa29SPqJ1fVkhtj3Hw9xjLVXVYrU9QlYWrOLXBpQ6KWjbjTDTdDkoohFzgbEY=
responses:
Default:
description: A default response with a reason.
content:
application/json:
schema:
$ref: '#/components/schemas/Reason'
parameters:
TenantIdParameter:
name: tenantId
in: path
required: true
description: Distinct id of the tenant.
schema:
$ref: '#/components/schemas/Id'
ClusterIdParameter:
name: clusterId
in: path
required: true
description: Distinct id of the cluster.
schema:
$ref: '#/components/schemas/Id'
tags:
- name: tenant
description: Management of tenants
- name: cluster
description: Management of clusters
- name: bootstrapping
description: Cluster bootstrapping
- name: inventory
description: Cluster inventory time based data
- name: system
description: API system
paths:
/tenants:
get:
operationId: listTenants
summary: Returns a list of tenants
description: List of all tenants available in the API
tags:
- tenant
responses:
'200':
description: Tenant listing. Empty array if no tenants available.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Tenant'
example:
- id: aezoo6
displayName: Big Corp.
gitRepo: https://github.com/bigcorp/commodore-config.git
- id: os3ce3
displayName: Acme Corp. (Subtenant of Big Corp)
tenant: aezoo6
gitRepo: https://github.com/acmecorp/commodore-config.git
default:
$ref: '#/components/responses/Default'
post:
operationId: createTenant
summary: Creates a new tenant
description: |-
Create a tenant in the API.
The ID is generated by the API (in the form `t-<adjective>-<noun>-<digits>` where
all the words are lowercase, max 63 characters in total).
It generates the `Tenant` object in the configured namespace (usually the same namespace where the API runs).
The customer config Git repository (the `<GitRepoSpec>`) is automatically
generated based on default configuration or using the provided values.
If `gitRepo` is already set on creation, no `<GitRepoSpec>` will be added.
tags:
- tenant
requestBody:
required: true
description: Create a new tenant
content:
application/json:
schema:
$ref: '#/components/schemas/TenantProperties'
responses:
'201':
description: Tenant created
content:
application/json:
schema:
$ref: '#/components/schemas/Tenant'
example:
id: aezoo6
displayName: Acme Corp.
tenant: multicorp
gitRepo: https://github.com/acmecorp/commodore-config.git
'400':
description: Tenant can't be created
content:
application/json:
schema:
$ref: '#/components/schemas/Reason'
'405':
description: Tenant already exists
default:
$ref: '#/components/responses/Default'
/tenants/{tenantId}:
get:
operationId: getTenant
summary: Returns all values of a tenant
description: Returns all values of a tenant
tags:
- tenant
parameters:
- $ref: '#/components/parameters/TenantIdParameter'
responses:
'200':
description: Tenant found
content:
application/json:
schema:
$ref: '#/components/schemas/Tenant'
'404':
description: A tenant with the specified id wasn't found.
default:
$ref: '#/components/responses/Default'
patch:
operationId: updateTenant
summary: Updates a tenant
description: Updates a tenant
tags:
- tenant
parameters:
- $ref: '#/components/parameters/TenantIdParameter'
requestBody:
description: Update tenant with properties to be changed (RFC 7396)
required: true
content:
application/merge-patch+json:
schema:
$ref: '#/components/schemas/TenantProperties'
responses:
'200':
description: Tenant updated
content:
application/json:
schema:
$ref: '#/components/schemas/Tenant'
'403':
description: Tenant update forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Reason'
default:
$ref: '#/components/responses/Default'
delete:
operationId: deleteTenant
summary: Deletes a tenant
description: Deletes a tenant
tags:
- tenant
parameters:
- $ref: '#/components/parameters/TenantIdParameter'
responses:
'204':
description: Tenant deleted
'403':
description: Tenant deletion forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Reason'
default:
$ref: '#/components/responses/Default'
/clusters:
get:
operationId: listClusters
summary: Returns a list of clusters
description: List of clusters available in the API
tags:
- cluster
parameters:
- in: query
name: tenant
schema:
type: string
description: Filter clusters by tenant id
example: aezoo6
responses:
'200':
description: Cluster listing. Empty array if no tenants available.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Cluster'
default:
$ref: '#/components/responses/Default'
post:
operationId: createCluster
summary: Creates a new cluster
description: |-
Create a cluster in the API.
The ID is generated by the API (in the form `c-<adjective>-<noun>-<digits>` where
all the words are lowercase, max 63 characters in total).
It checks if the tenant exists before creating the object, otherwise fails.
It generates the `Cluster` object and its `<GitRepoSpec>` and `bootstrapToken` values.
tags:
- cluster
requestBody:
description: Create a new Cluster
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ClusterProperties'
responses:
'201':
description: Cluster created
content:
application/json:
schema:
$ref: '#/components/schemas/Cluster'
'400':
description: Cluster can't be created
content:
application/json:
schema:
$ref: '#/components/schemas/Reason'
'405':
description: Cluster already exists
default:
$ref: '#/components/responses/Default'
/clusters/{clusterId}:
get:
operationId: getCluster
summary: Returns all values of a cluster
description: Returns all values of a cluster
tags:
- cluster
parameters:
- $ref: '#/components/parameters/ClusterIdParameter'
responses:
'200':
description: Cluster found
content:
application/json:
schema:
$ref: '#/components/schemas/Cluster'
'404':
description: A cluster with the specified id wasn't found.
default:
$ref: '#/components/responses/Default'
patch:
operationId: updateCluster
summary: Updates a cluster
description: Updates a cluster
tags:
- cluster
parameters:
- $ref: '#/components/parameters/ClusterIdParameter'
requestBody:
description: Update cluster with properties to be changed (RFC 7396)
required: true
content:
application/merge-patch+json:
schema:
$ref: '#/components/schemas/ClusterProperties'
responses:
'200':
description: Cluster updated
content:
application/json:
schema:
$ref: '#/components/schemas/Cluster'
'403':
description: Cluster update forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Reason'
default:
$ref: '#/components/responses/Default'
delete:
operationId: deleteCluster
summary: Deletes a cluster
description: Deletes a cluster
tags:
- cluster
parameters:
- $ref: '#/components/parameters/ClusterIdParameter'
responses:
'204':
description: Cluster deleted
'403':
description: Cluster deletion forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Reason'
default:
$ref: '#/components/responses/Default'
/install/steward.json:
get:
operationId: installSteward
summary: Returns the Steward JSON installation manifest
description: |-
Autogenerated JSON containing all the needed parameters for having Steward up and running.
It Iterates through all available Cluster objects to find the object matching the token in the field `spec.bootstrapToken.token`.
It checks if the token is valid (fields `spec.bootstrapToken.valid` and field `spec.bootstrapToken.validUntil`).
If valid delivers the JSON and sets the field `spec.bootstrapToken.valid` to `false`.
security: []
tags:
- bootstrapping
parameters:
- in: query
name: token
schema:
type: string
description: Initial bootstrap token
responses:
'200':
description: Kubernetes manifests to install Steward, the cluster agent
content:
application/json:
schema:
type: object
'401':
description: Token invalid
'404':
description: Cluster not found
default:
$ref: '#/components/responses/Default'
/inventory:
get:
operationId: queryInventory
summary: Returns inventory data according to query
description: Search inventory data
tags:
- inventory
parameters:
- in: query
name: q
schema:
type: string
description: InfluxQL query string
example: SELECT LAST(version,cloud) FROM mycluster
responses:
'200':
description: Query succeeded
content:
application/json:
schema:
$ref: '#/components/schemas/Inventory'
default:
$ref: '#/components/responses/Default'
post:
operationId: updateInventory
summary: Write inventory data
description: Write inventory data
tags:
- inventory
requestBody:
description: Inventory data of a cluster
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Inventory'
responses:
'201':
description: Inventory data stored
default:
$ref: '#/components/responses/Default'
/healthz:
get:
operationId: healthz
summary: API health check
description: API health check
security: []
tags:
- system
responses:
'200':
description: All is fine
content:
text/plain:
schema:
type: string
example: ok
default:
$ref: '#/components/responses/Default'