summaryrefslogtreecommitdiffstats
path: root/testapi/docs/developer/devguide/testapi-client-import.rst
blob: ad41029079107d04b2a4928f49987ae912538a39 (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
.. 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 import
=====================

**Python module to communicate with the TestAPI Server**

This project aims to provide a python module which can
communicate with the TestAPI Server. The user can use this client
to fetch/post/modify the resources on the TestAPI Server.

Usage
-----

Pod
^^^

GET
"""

Get a list of all the declared pods from the TestAPI server.

.. code-block:: shell

    from testapiclient.client import pods

    pod_client = pods.PodsClient()
    pod_client.get()

The user can filter the results by the name attribute. Backend will
use a regular expression to find the list of pods which are
related to given name.

.. code-block:: shell

    from testapiclient.client import pods

    pod_client = pods.PodsClient()
    pod_client.get(name='pod1')

.. NOTE::
  Response format: [{"_id": "", "creator": "", "role": "", "name": "",
  "details": "", "mode": "", "creation_date": ""}]


GET ONE
"""""""

Get a specific pod by its name.

.. code-block:: shell

    from testapiclient.client import pods

    pod_client = pods.PodsClient()
    pod_client.get_one('name')

.. NOTE::
  Response format: {"_id": "", "creator": "", "role": "", "name": "",
  "details": "", "mode": "", "creation_date": ""}

CREATE
""""""
This method used to create a project on the server.
The user should provide the user parameter and the password
parameter while initiating the PodsClient.

Input for the function :

  * pod-json : Json object of the project

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

  *  role should be either "community-ci" or "production-ci"
  *  mode should be either "metal" or "virtual"

.. code-block:: shell

    from testapiclient.client import pods

    pod_client = pods.PodsClient(user='test', password='pass')
    pod_client.create({'name': 'test-api', 'mode':'metal',
                    'role':'community_ci', 'details':''})


Project
^^^^^^^

GET
"""

Get a list of all the declared projects from the TestAPI server.

.. code-block:: shell

    from testapiclient.client import projects

    project_client = projects.ProjectsClient()
    project_client.get()

User can filter the results by the name attribute. Backend will
use a regular expression to find the list of projects which are
related to given name.

.. code-block:: shell

    from testapiclient.client import projects

    project_client = projects.ProjectsClient()
    project_client.get(name='project1')

.. NOTE::
  Response format: [{"_id": "", "creator": "", "description": "",
  "name": "", "creation_date": ""}]

GET ONE
"""""""

Get a specific project by its name.

.. code-block:: shell

    from testapiclient.client import projects

    project_client = projects.ProjectsClient()
    project_client.get_one('name')

.. NOTE::
  Response format: {"_id": "", "creator": "", "description": "",
  "name": "", "creation_date": ""}

CREATE
""""""

This method used to create a project on the server.
The user should provide the user parameter and the password
parameter while initiating the ProjectsClient.

Input for the function :

  * project-json : Json object of the project

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

.. code-block:: shell

    from testapiclient.client import projects

    project_client = projects.ProjectsClient(user='test', password='pass')
    project_client.create({'name': 'functest', 'description':'sample text'}

UPDATE
""""""

This method used to update an existing project on the server.
The user should provide the user parameter and the password
parameter while initiating the ProjectsClient.

Input for the function :

  * project-name: name of the project which user want to update.
  * project-json: Json object of the project

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

.. code-block:: shell

    from testapiclient.client import projects

    project_client = projects.ProjectsClient(user='test', password='pass')
    project_client.update('functest', {'name': 'functest',
    'description':'updated text'})