summaryrefslogtreecommitdiffstats
path: root/testapi/docs/developer/devguide/testapi-client.rst
blob: ea08ad974d7920954ba74f8cbf898d90f85447d3 (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
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
.. (c) 2017 ZTE Corp.

==============
TestAPI client
==============

TestAPIClient is a command-line client for TestAPI that
brings the command set for pod, project, testcase, results,
deploy result and scenario together in a single shell with a uniform command
structure.


Installation
------------

User can install this client from the source.

.. code-block:: shell

  python install testapi/testapi-client/setup.py install

After the installation, user has to set the environment variables

.. code-block:: shell

   source  testapi/testapi-client/etc/client.creds


Authentication Process
----------------------

User needs to provide the username and the password with the testapi
command.

.. code-block:: shell

    $ testapi -u [username] -p [password]
    (testapi) pod create


or

.. code-block:: shell

    testapi pode create -u [username] -p [password] [pod-schema]

First one, user can continue the progress after the authentication.
cli will create a new session to handle the request.

In second one, cli won't create a session. one time command.

Token is also used for the authorization purpose. User has to obtain the
valid token from the TestAPI comminity and set it in the following file
: **testapi/testapi-client/etc/client.creds**

.. code-block:: shell

   source  testapi/testapi-client/etc/client.creds


Command Structure
-----------------

TestAPIClient follows a common command Structure.

.. code-block:: shell

    testapi [resource-name] [function] [-u] [username] [-p] [password] [command-arguments]

.. NOTE::
  resource-name : include first order parent name and resource name.

  example:
  scenario installer, scenario version, scenario project, scenario custom,
  scenario trustindicator, scenario score, pod , project, testcase, result,
  deployresult and scenario.

.. NOTE::
  -u and -p are optional commands. The user can decide on them.

There are many arguments for each commands. User can get them using help command in the
cli.

.. code-block:: shell

  pod create --help/-h

Pod
^^^

Create
""""""

Authentication required

.. code-block:: shell

    testapi pod create [-u] [username] [-p] [password] [pod-schema]

or

.. code-block:: shell

    $ testapi [-u] [username] [-p] [password]
    (testapi) pod create [pod-schema]

.. NOTE::
  pod-schema - '{"role": "", "name": "", "details": "", "mode": ""}'

Get
"""

Authentication is not required

.. code-block:: shell

    testapi pod get [-name] [key-word]

.. NOTE::
   -name is not mandatory. The user can use the -name option to reduce the
   search result otherwise they will get the details about all pods.

Get one
"""""""

Authentication is not required

.. code-block:: shell

    testapi pod getone [name-keyword]

.. NOTE::
   name-keyword is mandatory.


Delete
""""""

Authentication is required

.. code-block:: shell

    testapi pod delete [-u] [username] [-p] [password] [pod-name]

or

.. code-block:: shell

    $ testapi [-u] [username] [-p] [password]
    (testapi) pod delete [pod-name]

.. NOTE::
   pod-name is mandatory.


Project
^^^^^^^

Create
""""""

Authentication required

.. code-block:: shell

    testapi project create [-u] [username] [-p] [password] [project-schema]

or

.. code-block:: shell

    $ testapi [-u] [username] [-p] [password]
    (testapi) project create [project-schema]

.. NOTE::
  project-schema - '{"description": "", "name": ""}'


Get
"""

Authentication is not required

.. code-block:: shell

    testapi project get [-name] [key-word]

.. NOTE::
   -name is not mandatory. The user can use the -name option to reduce the
   search result otherwise they will get the details about all projects.

Get one
"""""""

Authentication is not required

.. code-block:: shell

    testapi project getone [name-keyword]

.. NOTE::
   name-keyword is mandatory.

Update
""""""

Authentication required

.. code-block:: shell

    testapi project put [-u] [username] [-p] [password] [project-name]
    [project-schema]

or

.. code-block:: shell

    $ testapi [-u] [username] [-p] [password]
    (testapi) project put [project-name] [project-schema]

.. NOTE::
  project-schema - '{"name": "", "description": ""}'


Testcase
^^^^^^^^

Create
""""""

Authentication required

.. code-block:: shell

    testapi testcase create [-u] [username] [-p] [password]
    [--project-name] [testcase-schema]

or

.. code-block:: shell

    $ testapi [-u] [username] [-p] [password]
    (testapi) testcase create [--project-name] [testcase-schema]

.. NOTE::
  testcase-schema - '{"run": "", "name": "", "ci_loop": "", "tags": "",
  "url": "", "catalog_description": "", "tier": "",
  "dependencies": "", "version": "", "criteria": "",
  "domains": "", "trust": "", "blocking": "",
  "description": ""}'


Get
"""

Authentication is not required

.. code-block:: shell

    testapi testcase get [--project-name]

.. NOTE::
   --project-name is mandatory.

Get one
"""""""

Authentication is not required

.. code-block:: shell

    testapi testcase getone [--project-name] [name]

.. NOTE::
   name and project-name are mandatory.

Update
""""""

Authentication required

.. code-block:: shell

    testapi testcase put [-u] [username] [-p] [password] [--project-name]
    [name] [testcase-schema]

or

.. code-block:: shell

    $ testapi [-u] [username] [-p] [password]
    (testapi) testcase put [--project-name] [name] [testcase-schema]

.. NOTE::
  testcase-schema - '{"run": "", "name": "", "ci_loop": "", "tags": "",
  "url": "", "catalog_description": "", "tier": "",
  "dependencies": "", "version": "", "criteria": "",
  "domains": "", "trust": "", "blocking": "",
  "description": ""}


Result
^^^^^^^

Create
""""""

Token is required. Set token as an environment variable.

.. code-block:: shell

    testapi result create [-u] [username] [-p] [password] [result-schema]

or

.. code-block:: shell

    $ testapi [-u] [username] [-p] [password]
    (testapi) result create [result-schema]

.. NOTE::
  result-schema - '{"project_name": "", "scenario": "", "stop_date": "",
  "case_name": "", "build_tag": "", "version": "",
  "pod_name": "", "criteria": "", "installer": "",
  "start_date": "", "details": ""}'


Get
"""

Authentication is not required

.. code-block:: shell

    testapi result get [-cli-arguments] [arguments-value]

.. NOTE::
   List of commandline arguments

   * -case : Search results using tesetcase
   * -build-tag : Search results using build tag
   * -from : Search results using from date
   * -last : Search results using last date
   * -scenario : Search results using scenario
   * -period : Search results using period
   * -project : Search results using project
   * -to : Search results using to
   * ---version : Search results using version
   * -criteria : Search results using criteria
   * -installer : Search results using installer
   * -pod : Search results using pod
   * -page : Search results using page

Get one
"""""""

Token is required. Set token as an environment variable.

.. code-block:: shell

    testapi result getone [result_id]

.. NOTE::
   result_id is mandatory.

Deploy Result
^^^^^^^^^^^^^

Create
""""""

Token is required. Set token as an environment variable.


.. code-block:: shell

    testapi deployresult [-u] [username] [-p] [password]
    [--project-name] [deployresult-schema]

or

.. code-block:: shell

    $ testapi [-u] [username] [-p] [password]
    (testapi) deployresult create [deployresult-schema]

.. NOTE::
  deployresult-schema - '{"run": "", "name": "", "ci_loop": "", "tags": "",
  "url": "", "catalog_description": "", "tier": "",
  "dependencies": "", "version": "", "criteria": "",
  "domains": "", "trust": "", "blocking": "",
  "description": ""}'


Get
"""

Authentication is not required

.. code-block:: shell

    testapi deployresult get [-cli-arguments] [arguments-value]

.. NOTE::
   List of command line arguments

   * -job-name : Search results using job
   * -build-id : Search results using build id
   * -from : Search results using from date
   * -last : Search results using last date
   * -scenario : Search results using scenario
   * -period : Search results using period
   * -to : Search results using to
   * ---version : Search results using version
   * -criteria : Search results using criteria
   * -installer : Search results using installer
   * -pod-name : Search results using pod
   * -page : Search results using page

Get one
"""""""

Authentication is not required

.. code-block:: shell

    testapi deployresult getone [deployresult_id]

.. NOTE::
   deployresult_id is mandatory.