summaryrefslogtreecommitdiff
path: root/swagger.yml
blob: 58f2e60264e8bce88c8c2eb0a84a3f0c66b3c581 (plain)
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
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
swagger: '2.0'
info:
  description: >-
    This is a Weles server.   You can find out more about Weles at
    [http://tbd.tbd](http://tbd.tbd).
  version: v1
  title: Weles
  termsOfService: 'http://tbd.tbd/terms/'
  contact:
    email: tbd@tbd.com
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
host: 'localhost:8088'
basePath: /api/v1
consumes:
  - application/json
produces:
  - application/json
tags:
  - name: jobs
    description: Info and management of Weles jobs.
  - name: artifacts
    description: Info about all artifacts used by Weles jobs.
  - name: general
    description: Info about Weles (e.g. version)
schemes:
  - http
paths:
  /jobs:
    post:
      tags:
        - jobs
      summary: Add new job
      description: adds new Job in Weles using recipe passed in YAML format.
      operationId: JobCreator
      consumes:
        - multipart/form-data
      parameters:
        - in: formData
          name: yamlfile
          type: file
          required: true
          description: is Job description yaml file.
      produces:
        - application/json
      responses:
        '201':
          description: Created
          schema:
            $ref: '#/definitions/JobID'
        '415':
          $ref: '#/responses/UnsupportedMediaType'
        '422':
          $ref: '#/responses/UnprocessableEntity'
        '500':
          $ref: '#/responses/InternalServer'
  '/jobs/{JobID}/cancel':
    post:
      tags:
        - jobs
      summary: Cancel existing job
      description: JobCanceler stops execution of Job identified by JobID.
      operationId: JobCanceler
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: path
          required: true
          name: JobID
          type: integer
          format: uint64
      responses:
        '204':
          description: No Content
        '404':
          $ref: '#/responses/NotFound'
        '403':
          $ref: '#/responses/Forbidden'
        '500':
          $ref: '#/responses/InternalServer'
  /jobs/list:
    post:
      tags:
        - jobs
      summary: List jobs with filter and sort features
      description: JobLister returns information on filtered Weles Jobs.
      operationId: JobLister
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: body
          name: jobFilterAndSort
          description: Job Filter and Sort object.
          required: false
          schema:
            description: Data for filtering and sorting Weles Jobs lists.
            type: object
            properties:
              Filter:
                $ref: '#/definitions/JobFilter'
              Sorter:
                $ref: '#/definitions/JobSorter'
        - in: query
          name: after
          description: JobID of the last element from previous page.
          type: integer
          format: uint64
        - in: query
          name: before
          description: JobID of first element from next page.
          type: integer
          format: uint64
        - in: query
          name: limit
          description: Custom page limit. Denotes number of JobInfo structures that will be returned.
          type: integer
          format: int32
      responses:
        '200':
          description: OK
          schema:
            type: array
            items:
              $ref: '#/definitions/JobInfo'
          headers:
            Previous:
              type: string
              format: URI
              description: >
                URI to request previous page of data. Please note that the same body must be used as in initial request.
            Next:
              type: string
              format: URI
              description: >
                URI to request next page of data. Please note that the same body must be used as in initial request.
            TotalRecords:
              type: integer
              format: uint64
              description: >
                count of records currently fulfilling the requested JobFilter. Please note that this value may change when requesting for the same data at a different moment in time.
        '206':
          description: Partial Content
          schema:
            type: array
            items:
              $ref: '#/definitions/JobInfo'
          headers:
            Previous:
              type: string
              format: URI
              description: >
                URI to request previous page of data. Please note that the same body must be used as in initial request.
            Next:
              type: string
              format: URI
              description: >
                URI to request next page of data. Please note that the same body must be used as in initial request.
            TotalRecords:
              type: integer
              format: uint64
              description: >
                 count of records currently fulfilling requested JobFilter. Please note that this value may change when requesting for the same data at a different moment in time.
            RemainingRecords:
              type: integer
              format: uint64
              description: >
                number of records after current page. Please note that this value may change when requesting for the same data at a different moment in time.
        '400':
          $ref: '#/responses/BadRequest'
        '404':
          $ref: '#/responses/NotFound'
        '500':
          $ref: '#/responses/InternalServer'
  /artifacts/list:
    post:
      tags:
        - artifacts
      summary: List artifacts with filter and sort features
      description: ArtifactLister returns information on filtered Weles artifacts.
      operationId: ArtifactLister
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: body
          name: artifactFilterAndSort
          description: Artifact Filter and Sort object.
          required: false
          schema:
            description: Data for filtering and sorting Weles Jobs lists.
            type: object
            properties:
              Filter:
                $ref: '#/definitions/ArtifactFilter'
              Sorter:
                $ref: '#/definitions/ArtifactSorter'
        - in: query
          name: after
          description: ID of the last element from previous page.
          type: integer
          format: int64
        - in: query
          name: before
          description: ID of first element from next page.
          type: integer
          format: int64
        - in: query
          name: limit
          description: Custom page limit. Denotes number of ArtifactInfo structures that will be returned.
          type: integer
          format: int32
      responses:
        '200':
          description: OK
          schema:
            type: array
            items:
              $ref: '#/definitions/ArtifactInfo'
          headers:
            Previous:
              type: string
              format: URI
              description: >
                URI to request next page of data. Please note that the same body must be used as in initial request.
            Next:
              type: string
              format: URI
              description: >
                URI to request next page of data. Please note that the same body must be used as in initial request.
            TotalRecords:
              type: integer
              format: uint64
              description: >
                count of records currently fulfilling the requested ArtifactFilter. Please note that this value may change when requesting for the same data at a different moment in time.
        '206':
          description: Partial Content
          schema:
            type: array
            items:
              $ref: '#/definitions/ArtifactInfo'
          headers:
            Previous:
              type: string
              format: URI
              description: >
                URI to request next page of data. Please note that the same body must be used as in initial request.
            Next:
              type: string
              format: URI
              description: >
                URI to request next page of data. Please note that the same body must be used as in initial request.
            TotalRecords:
              type: integer
              format: uint64
              description: >
                count of records currently fulfilling the requested ArtifactFilter. Please note that this value may change when requesting for the same data at a different moment in time.
            RemainingRecords:
              type: integer
              format: uint64
              description: >
                number of records after current page. Please note that this value may change when requesting for the same data at a different moment in time.
        '400':
          $ref: '#/responses/BadRequest'
        '404':
          $ref: '#/responses/NotFound'
        '500':
          $ref: '#/responses/InternalServer'
  /version:
    get:
      tags:
        - general
      summary: Show current version of Weles internals
      description: Version and state of API (e.g. v1 obsolete, v2 stable,
                   v3 devel) and server version.
      operationId: Version
      produces:
        - application/json
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/Version'
          headers:
            Weles-Server-Version:
              type: string
              description: Version of Weles server.
            Weles-API-Version:
              type: string
              description: Version of Weles API.
            Weles-API-State:
              type: string
              description: State of Weles API.
        '500':
          $ref: '#/responses/InternalServer'
responses:
  BadRequest:
    description: Bad Request
    schema:
      $ref: '#/definitions/ErrResponse'
  NotFound:
    description: Not Found
    schema:
      $ref: '#/definitions/ErrResponse'
  Forbidden:
    description: Forbidden
    schema:
      $ref: '#/definitions/ErrResponse'
  UnsupportedMediaType:
    description: Unsupported media type
    schema:
      $ref: '#/definitions/ErrResponse'
  UnprocessableEntity:
    description: Unprocessable entity
    schema:
      $ref: '#/definitions/ErrResponse'
  InternalServer:
    description: Internal Server error
    schema:
      $ref: '#/definitions/ErrResponse'
definitions:
  JobID:
    description: is a unique identifier for Weles Job.
    type: integer
    format: uint64
  JobStatus:
    description: |
      specifies state of the Job.

      * NEW - The new Job has been created.

      * PARSING - Provided yaml file is being parsed and interpreted.

      * DOWNLOADING - Images and/or files required for the test are being downloaded.

      * WAITING - Job is waiting for Boruta worker.

      * RUNNING - Job is being executed.

      * COMPLETED - Job is completed. This is terminal state.

      * FAILED - Job execution has failed. This is terminal state.

      * CANCELED -Job has been canceled with API call. This is terminal state.

    type: string
    enum:
      - NEW
      - PARSING
      - DOWNLOADING
      - WAITING
      - RUNNING
      - COMPLETED
      - FAILED
      - CANCELED
  JobInfo:
    description: contains information about a Job available for public API.
    type: object
    properties:
      jobID:
        $ref: '#/definitions/JobID'
        description: is a unique Job identifier
      name:
        type: string
        description: is the Job name acquired from yaml file during Job creation.
      created:
        type: string
        format: date-time
        description: is the Job creation time in UTC.
      updated:
        type: string
        format: date-time
        description: is the time of latest Jobs' status modification.
      status:
        $ref: '#/definitions/JobStatus'
        description: specifies current state of the Job.
      info:
        type: string
        description: provides additional information about current state, e.g. cause of failure
  JobFilter:
    description: is used to filter Weles Jobs.
    type: object
    properties:
      JobID:
        type: array
        items:
          $ref: '#/definitions/JobID'
      Name:
        type: array
        items:
          type: string
      CreatedAfter:
        type: string
        format: date-time
      CreatedBefore:
        type: string
        format: date-time
      UpdatedAfter:
        type: string
        format: date-time
      UpdatedBefore:
        type: string
        format: date-time
      Status:
        type: array
        items:
          $ref: '#/definitions/JobStatus'
      Info:
        type: array
        items:
          type: string
  JobSortBy:
    description: |
      denotes key for sorting Jobs list.

      * ID - default sort key.

      * CreatedDate - sorting by date of creation of the weles job.

      * UpdatedDate - sorting by date of update of the weles job.

      * JobStatus - sorting by the Job Status. Descending order will sort in the order JobStatuses are listed in the docs (from NEW at the start to CANCELED at the end). Ascending will reverse this order.

      When sorting is applied, and there are many jobs with the same date/status, they will be sorted by JobID (Ascending)
    type: string
    enum:
      - ID
      - CreatedDate
      - UpdatedDate
      - JobStatus
  SortOrder:
    description: |
      denotes direction of sorting of weles jobs or artifacts.

      * Ascending - from oldest to newest.

      * Descending - from newest to oldest.

    type: string
    enum:
      - Ascending
      - Descending
  JobSorter:
    description: |
      defines the key for sorting as well as direction of sorting.
    type: object
    properties:
      SortBy:
        $ref: '#/definitions/JobSortBy'
      SortOrder:
        $ref: '#/definitions/SortOrder'
  ArtifactType:
    description: |
      denotes type and function of an artifact.

      * IMAGE - image file.

      * RESULT - all outputs, files built during tests, etc.

      * TEST - additional files uploaded by user for conducting test.

      * YAML - yaml file describing Weles Job.

    type: string
    enum:
      - IMAGE
      - RESULT
      - TEST
      - YAML
  ArtifactPath:
    description: describes path to artifact in ArtifactDB filesystem.
    type: string
  ArtifactStatus:
    description: |
      describes artifact status and availability.

      * DOWNLOADING - artifact is currently being downloaded.

      * READY - artifact has been downloaded and is ready to use.

      * FAILED - file is not available for use (e.g. download failed).

      * PENDING - artifact download has not started yet.

    type: string
    enum:
      - DOWNLOADING
      - READY
      - FAILED
      - PENDING
  ArtifactURI:
    description: is used to identify artifact's source.
    type: string
    format: uri
  ArtifactAlias:
    description: is an alternative name of an artifact.
    type: string
  ArtifactDescription:
    description: contains information needed to create new artifact in ArtifactDB.
    type: object
    properties:
      JobID:
        $ref: '#/definitions/JobID'
        description: specifies  Job for which artifact was created.
      Type:
        $ref: '#/definitions/ArtifactType'
      Alias:
        $ref: '#/definitions/ArtifactAlias'
      URI:
        $ref: '#/definitions/ArtifactURI'
  ArtifactInfo:
    description: describes single artifact stored in ArtifactDB.
    type: object
    allOf:
     - $ref: '#/definitions/ArtifactDescription'
    properties:
      Path:
        $ref: '#/definitions/ArtifactPath'
      Status:
        $ref: '#/definitions/ArtifactStatus'
      Timestamp:
        description: is date of creating the artifact.
        type: string
        format: date-time
      ID:
        description: unique identification of the artifact.
        type: integer
        format: int64
        x-go-custom-tag: "db:\",primarykey, autoincrement\""
  ArtifactFilter:
    description: is used to filter results from ArtifactDB.
    type: object
    properties:
      JobID:
        type: array
        items:
          $ref: '#/definitions/JobID'
      Type:
        type: array
        items:
          $ref: '#/definitions/ArtifactType'
      Status:
        type: array
        items:
          $ref: '#/definitions/ArtifactStatus'
      Alias:
        type: array
        items:
          $ref: '#/definitions/ArtifactAlias'
  ErrResponse:
    description: >-
      is a standard error response containing information about the
      error. It consists of error type and message.
    type: object
    properties:
      type:
        type: string
      message:
        type: string
  ArtifactSortBy:
    description: >
      denotes the key for sorting list of all artifacts.

      * ID - sorting by artifact ID.

    type: string
    enum:
      - ID
  ArtifactSorter:
    description: |
      defines the key for sorting as well as direction of sorting.
      When ArtifactSorter is empty, artifacts are sorted by ID, Ascending.
    type: object
    properties:
      SortBy:
        $ref: '#/definitions/ArtifactSortBy'
      SortOrder:
        $ref: '#/definitions/SortOrder'
  Version:
    description: |
      defines version of Weles API (and its state) and server.
    type: object
    properties:
      Server:
        description: Version of Weles server.
        type: string
      API:
        description: Version of Weles API.
        type: string
      State:
        description: State of Weles API.
        type: string
        enum:
          - devel
          - stable
          - deprecated
externalDocs:
  description: TBD
  url: 'http://TBD.tbd'