File: watcher-api-v1-audits.inc

package info (click to toggle)
watcher 14.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,764 kB
  • sloc: python: 48,904; xml: 312; sh: 265; makefile: 75
file content (367 lines) | stat: -rw-r--r-- 7,991 bytes parent folder | download | duplicates (4)
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
.. -*- rst -*-

======
Audits
======

There are creating, listing, updating and deleting methods of Watcher Audit
resources which are implemented via the ``/v1/audits`` resource.

In the Watcher system, an ``Audit`` is a request for optimizing a ``Cluster``.

The optimization is done in order to satisfy one ``Goal`` on a given
``Cluster``.

For each ``Audit``, the Watcher system generates an ``Action Plan``.

Create Audit
============

.. rest_method::  POST /v1/audits

Creates a new Audit resource.

Mandatory attribute to be supplied: ``audit_type``.

``Audit`` can be created either based on existed ``Audit Template`` or by
itself. In the first case, there also should be supplied
``audit_template_uuid``. If ``Audit`` is created without ``Audit Template``,
``goal`` should be provided.

Normal response codes: 201

Error codes: 400,404

Request
-------

.. rest_parameters:: parameters.yaml

   - audit_template_uuid: audittemplate_uuid
   - audit_type: audit_type
   - name: audit_name
   - goal: audit_goal
   - strategy: audit_strategy
   - parameters: audit_parameters
   - interval: audit_interval
   - auto_trigger: audit_autotrigger
   - start_time: audit_starttime_req
   - end_time: audit_endtime_req
   - force: audit_force

**Example ONESHOT Audit creation request:**

.. literalinclude:: samples/audit-create-request-oneshot.json
   :language: javascript

**Example CONTINUOUS Audit creation request with a specified strategy:**

.. literalinclude:: samples/audit-create-request-continuous.json
   :language: javascript

Response
--------

The list and example below are representative of the response as of API
version 1:

.. rest_parameters:: parameters.yaml

    - uuid: uuid
    - name: audit_name
    - audit_type: audit_type
    - strategy_uuid: strategy_uuid
    - strategy_name: strategy_name
    - goal_uuid: goal_uuid
    - goal_name: goal_name
    - interval: audit_interval
    - next_run_time: audit_next_run_time
    - parameters: audit_parameters
    - auto_trigger: audit_autotrigger
    - state: audit_state
    - scope: audittemplate_scope
    - links: links
    - hostname: audit_hostname
    - start_time: audit_starttime_resp
    - end_time: audit_endtime_resp
    - force: audit_force

**Example JSON representation of an Audit:**

.. literalinclude:: samples/audit-create-response.json
   :language: javascript

List Audit
==========

.. rest_method::  GET /v1/audits

Returns a list of Audit resources.

Normal response codes: 200

Error codes: 400,401

Request
-------

.. rest_parameters:: parameters.yaml

   - goal: r_goal
   - strategy: r_strategy
   - limit: limit
   - marker: marker
   - sort_dir: sort_dir
   - sort_key: sort_key

Response
--------

.. rest_parameters:: parameters.yaml

    - uuid: uuid
    - name: audit_name
    - audit_type: audit_type
    - strategy_uuid: strategy_uuid
    - strategy_name: strategy_name
    - goal_uuid: goal_uuid
    - goal_name: goal_name
    - interval: audit_interval
    - next_run_time: audit_next_run_time
    - auto_trigger: audit_autotrigger
    - state: audit_state
    - scope: audittemplate_scope
    - links: links

**Example JSON representation of an Audit:**

.. literalinclude:: samples/audit-list-response.json
   :language: javascript

List Audit Detailed
===================

.. rest_method::  GET /v1/audits/detail

Returns a list of Audit resources with complete details.

Normal response codes: 200

Error codes: 400,401

Request
-------

.. rest_parameters:: parameters.yaml

   - goal: r_goal
   - strategy: r_strategy
   - limit: limit
   - marker: marker
   - sort_dir: sort_dir
   - sort_key: sort_key

Response
--------

.. rest_parameters:: parameters.yaml

    - uuid: uuid
    - name: audit_name
    - audit_type: audit_type
    - strategy_uuid: strategy_uuid
    - strategy_name: strategy_name
    - goal_uuid: goal_uuid
    - goal_name: goal_name
    - interval: audit_interval
    - next_run_time: audit_next_run_time
    - parameters: audit_parameters
    - auto_trigger: audit_autotrigger
    - state: audit_state
    - scope: audittemplate_scope
    - links: links
    - hostname: audit_hostname
    - start_time: audit_starttime_resp
    - end_time: audit_endtime_resp
    - force: audit_force

**Example JSON representation of an Audit:**

.. literalinclude:: samples/audit-list-detailed-response.json
   :language: javascript

Show Audit
==========

.. rest_method::  GET /v1/audits/{audit_ident}

Shows details for an Audit.

Normal response codes: 200

Error codes: 404

Request
-------

.. rest_parameters:: parameters.yaml

   - audit_ident: audit_ident

Response
--------

.. rest_parameters:: parameters.yaml

    - uuid: uuid
    - name: audit_name
    - audit_type: audit_type
    - strategy_uuid: strategy_uuid
    - strategy_name: strategy_name
    - goal_uuid: goal_uuid
    - goal_name: goal_name
    - interval: audit_interval
    - next_run_time: audit_next_run_time
    - parameters: audit_parameters
    - auto_trigger: audit_autotrigger
    - state: audit_state
    - scope: audittemplate_scope
    - links: links
    - hostname: audit_hostname
    - start_time: audit_starttime_resp
    - end_time: audit_endtime_resp
    - force: audit_force

**Example JSON representation of an Audit:**

.. literalinclude:: samples/audit-show-response.json
   :language: javascript

Cancel Audit
============

.. rest_method::  PATCH /v1/audits/{audit_ident}

Cancels an ONGOING Audit resource.

Normal response codes: 200

Error codes: 400,404

Request
-------

.. rest_parameters:: parameters.yaml

   - audit_ident: audit_ident

**Example Audit cancelling request:**

.. literalinclude:: samples/audit-cancel-request.json
   :language: javascript

Response
--------

The list and example below are representative of the response as of API
version 1:

.. rest_parameters:: parameters.yaml

    - uuid: uuid
    - name: audit_name
    - audit_type: audit_type
    - strategy_uuid: strategy_uuid
    - strategy_name: strategy_name
    - goal_uuid: goal_uuid
    - goal_name: goal_name
    - interval: audit_interval
    - next_run_time: audit_next_run_time
    - parameters: audit_parameters
    - auto_trigger: audit_autotrigger
    - state: audit_state
    - scope: audittemplate_scope
    - links: links
    - hostname: audit_hostname
    - start_time: audit_starttime_resp
    - end_time: audit_endtime_resp
    - force: audit_force

**Example JSON representation of an Audit:**

.. literalinclude:: samples/audit-cancel-response.json
   :language: javascript

Update Audit
============

.. rest_method::  PATCH /v1/audits/{audit_ident}

Updates an Audit with the given information.

.. note:
    ``audit_type`` shouldn't be changed by PATCH method.

Normal response codes: 200

Error codes: 400,404

Request
-------

.. rest_parameters:: parameters.yaml

   - audit_ident: audit_ident

**Example PATCH document updating Audit:**

.. literalinclude:: samples/audit-update-request.json
   :language: javascript

Response
--------

.. rest_parameters:: parameters.yaml

    - uuid: uuid
    - name: audit_name
    - audit_type: audit_type
    - strategy_uuid: strategy_uuid
    - strategy_name: strategy_name
    - goal_uuid: goal_uuid
    - goal_name: goal_name
    - interval: audit_interval
    - next_run_time: audit_next_run_time
    - parameters: audit_parameters
    - auto_trigger: audit_autotrigger
    - state: audit_state
    - scope: audittemplate_scope
    - links: links
    - hostname: audit_hostname
    - start_time: audit_starttime_resp
    - end_time: audit_endtime_resp
    - force: audit_force

**Example JSON representation of an Audit:**

.. literalinclude:: samples/audit-update-response.json
   :language: javascript

Delete Audit
============

.. rest_method::  DELETE /v1/audits/{audit_ident}

Deletes an Audit. Audit can be deleted only from FAILED, SUCCEEDED, CANCELLED,
SUSPENDED states.

Normal response codes: 204

Error codes: 404

Request
-------

.. rest_parameters:: parameters.yaml

   - audit_ident: audit_ident