Wiki source code of User endpoint
Last modified by Outhman Moustaghfir on 2022/06/13 13:17
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | = Introduction = | ||
2 | |||
3 | We will go through all endpoints needed to manage the User entity. | ||
4 | |||
5 | |||
6 | = Endpoints = | ||
7 | |||
8 | |||
9 | |**URL [method]**|(% style="width:515px" %)**Description**|(% style="width:318px" %)**Input example**|(% style="width:430px" %)**Output example** | ||
10 | |/rest/users [GET]|(% style="width:515px" %)__Get__ a list of all users of the current environment and its children,|(% style="width:318px" %)(no input required)|(% style="width:430px" %){{code language="JSON" layout="LINENUMBERS"}}{ | ||
11 | "timestamp": 1637577153521, | ||
12 | "status": "200", | ||
13 | "data": [ | ||
14 | { | ||
15 | "userid": 1, | ||
16 | "person": { | ||
17 | "trkid": 1, | ||
18 | "firstname": "admin", | ||
19 | "lastname": "admin", | ||
20 | "mailaddress": "omoustaghfir@ixpath.com", | ||
21 | "phone": "0000000000", | ||
22 | "role": null, | ||
23 | "service": null | ||
24 | }, | ||
25 | "group": { | ||
26 | "id": 1, | ||
27 | "alias": "Root", | ||
28 | "parent": 1, | ||
29 | "permission": "562949953421311" | ||
30 | }, | ||
31 | "alias": "admin", | ||
32 | "envId": 1, | ||
33 | "password": "9f3824ae911a68ecdb3197534d26bcbf", | ||
34 | "passworddelay": 9999, | ||
35 | "language": "Fr", | ||
36 | "lastconnected": 1637139174000, | ||
37 | "lastpassword": 1542106801000, | ||
38 | "active": true, | ||
39 | "revokedelay": 99999, | ||
40 | "defaultpage": 1, | ||
41 | "firstaccess": false, | ||
42 | "logged": "1637142774420", | ||
43 | "timezone": "GMT+0", | ||
44 | "envs": [ | ||
45 | { | ||
46 | "envid": 1, | ||
47 | "parent": 1, | ||
48 | "alias": "iXPath", | ||
49 | "code": "", | ||
50 | "sendurl": false, | ||
51 | "active": true, | ||
52 | "timezone": "Europe/Paris", | ||
53 | "gitRepository": "" | ||
54 | } | ||
55 | ], | ||
56 | "envsbloque": [] | ||
57 | }, | ||
58 | { | ||
59 | "userid": 41, | ||
60 | "person": { | ||
61 | "trkid": 2, | ||
62 | "firstname": "outhman", | ||
63 | "lastname": "man", | ||
64 | "mailaddress": "auth@abcd.com", | ||
65 | "phone": "09374788998", | ||
66 | "role": null, | ||
67 | "service": null | ||
68 | }, | ||
69 | "group": { | ||
70 | "id": 2, | ||
71 | "alias": "User", | ||
72 | "parent": { | ||
73 | "id": 3, | ||
74 | "alias": "Admin", | ||
75 | "parent": 1, | ||
76 | "permission": "562949953421311" | ||
77 | }, | ||
78 | "permission": "234333415669759" | ||
79 | }, | ||
80 | "alias": "user1", | ||
81 | "envId": 25, | ||
82 | "password": "3203019f997ea9edbfc25744e7f26bff", | ||
83 | "passworddelay": 6738, | ||
84 | "language": "Fr", | ||
85 | "lastconnected": null, | ||
86 | "lastpassword": null, | ||
87 | "active": true, | ||
88 | "revokedelay": 0, | ||
89 | "defaultpage": 1, | ||
90 | "firstaccess": false, | ||
91 | "logged": null, | ||
92 | "timezone": null, | ||
93 | "envs": [ | ||
94 | { | ||
95 | "envid": 19, | ||
96 | "parent": 1, | ||
97 | "alias": "greatEnv", | ||
98 | "code": "122", | ||
99 | "sendurl": false, | ||
100 | "active": true, | ||
101 | "timezone": "GMT", | ||
102 | "gitRepository": "" | ||
103 | } | ||
104 | ], | ||
105 | "envsbloque": [ | ||
106 | { | ||
107 | "envid": 30, | ||
108 | "parent": 29, | ||
109 | "alias": "PARRR2", | ||
110 | "code": "", | ||
111 | "sendurl": false, | ||
112 | "active": true, | ||
113 | "timezone": "GMT", | ||
114 | "gitRepository": "" | ||
115 | } | ||
116 | ] | ||
117 | } | ||
118 | ] | ||
119 | }{{/code}} | ||
120 | |/rest/users/{alias} [GET]|(% style="width:515px" %)__Get__ user by the alias|(% style="width:318px" %)((( | ||
121 | the {alias} must be replaced by the alias of the aimed user. | ||
122 | |||
123 | eg : | ||
124 | |||
125 | /rest/users/admin | ||
126 | |||
127 | /rest/users/FirstUser | ||
128 | |||
129 | |||
130 | )))|(% style="width:430px" %){{code language="JSON"}}{ | ||
131 | "timestamp": 1637577423572, | ||
132 | "status": "200", | ||
133 | "data": { | ||
134 | "userid": 1, | ||
135 | "person": { | ||
136 | "trkid": 1, | ||
137 | "firstname": "admin", | ||
138 | "lastname": "admin", | ||
139 | "mailaddress": "omoustaghfir@ixpath.com", | ||
140 | "phone": "0000000000", | ||
141 | "role": null, | ||
142 | "service": null | ||
143 | }, | ||
144 | "group": { | ||
145 | "id": 1, | ||
146 | "alias": "Root", | ||
147 | "parent": 1, | ||
148 | "permission": "562949953421311" | ||
149 | }, | ||
150 | "alias": "admin", | ||
151 | "envId": 1, | ||
152 | "password": "9f3824ae911a68ecdb3197534d26bcbf", | ||
153 | "passworddelay": 9999, | ||
154 | "language": "Fr", | ||
155 | "lastconnected": 1637139174000, | ||
156 | "lastpassword": 1542106801000, | ||
157 | "active": true, | ||
158 | "revokedelay": 99999, | ||
159 | "defaultpage": 1, | ||
160 | "firstaccess": false, | ||
161 | "logged": "1637142774420", | ||
162 | "timezone": "GMT+0", | ||
163 | "envs": [ | ||
164 | { | ||
165 | "envid": 1, | ||
166 | "parent": 1, | ||
167 | "alias": "iXPath", | ||
168 | "code": "", | ||
169 | "sendurl": false, | ||
170 | "active": true, | ||
171 | "timezone": "Europe/Paris", | ||
172 | "gitRepository": "" | ||
173 | } | ||
174 | ], | ||
175 | "envsbloque": [] | ||
176 | } | ||
177 | }{{/code}} | ||
178 | |/rest/users [POST]|(% style="width:515px" %)__Add__ new user to database.|(% style="width:318px" %){{code language="JSON"}}{ | ||
179 | "alias": "user1", | ||
180 | "password": "abcdef", | ||
181 | "active": "1", | ||
182 | "language": "Fr", | ||
183 | "passworddelay": "6738", | ||
184 | "defaultpage": "1", | ||
185 | "firstaccess": "2", | ||
186 | "group": 2, | ||
187 | "person": { | ||
188 | "firstname": "outhman", | ||
189 | "lastname": "man", | ||
190 | "mailaddress": "auje@aizi.com", | ||
191 | "phone": "09374788998" | ||
192 | }, | ||
193 | "envs": [ | ||
194 | "iXPath" | ||
195 | ], | ||
196 | "envsbloque": [ | ||
197 | "AnotherEnv" | ||
198 | ] | ||
199 | }{{/code}}((( | ||
200 | |||
201 | |||
202 | __NB: All fields are required to save the new user__ | ||
203 | |||
204 | |||
205 | )))|(% style="width:430px" %)((( | ||
206 | if the user has been added successfully : | ||
207 | |||
208 | {{code language="JSON"}} | ||
209 | { | ||
210 | "timestamp": 1637577821566, | ||
211 | "status": "200", | ||
212 | "data": true | ||
213 | } | ||
214 | {{/code}} | ||
215 | |||
216 | if not, the value returned will be a message of the triggered error. | ||
217 | ))) | ||
218 | |/rest/users/{id} [POST]|(% style="width:515px" %)Update a certain user by giving the id|(% style="width:318px" %)((( | ||
219 | * the {id} must be replaced by the concerned userId, eg: /rest/users/1 | ||
220 | * a JSON form must be submitted to modify the existing user, eg: if we want to modify the "phone" the user that we added in the last example : | ||
221 | |||
222 | {{code language="JSON"}} | ||
223 | { | ||
224 | "alias": "user1", | ||
225 | "password": "abcdef", | ||
226 | "active": "1", | ||
227 | "language": "Fr", | ||
228 | "passworddelay": "6738", | ||
229 | "defaultpage": "1", | ||
230 | "firstaccess": "2", | ||
231 | "group": 2, | ||
232 | "person": { | ||
233 | "firstname": "outhman", | ||
234 | "lastname": "man", | ||
235 | "mailaddress": "auje@aizi.com", | ||
236 | "phone": "00212747889928" | ||
237 | }, | ||
238 | "envs": [ | ||
239 | "iXPath" | ||
240 | ], | ||
241 | "envsbloque": [ | ||
242 | "AnotherEnv" | ||
243 | ] | ||
244 | } | ||
245 | {{/code}} | ||
246 | |||
247 | |||
248 | |||
249 | )))|(% style="width:430px" %)((( | ||
250 | (% id="cke_bm_5352S" style="display:none" %) (%%)if the user has been updated successfully : | ||
251 | |||
252 | {{code language="JSON"}} | ||
253 | { | ||
254 | "timestamp": 1637577821566, | ||
255 | "status": "200", | ||
256 | "data": true | ||
257 | } | ||
258 | {{/code}} | ||
259 | |||
260 | if not, the value returned will be a message of the triggered error. | ||
261 | ))) | ||
262 | |/rest/users/{id} [DELETE]|(% style="width:515px" %)__Delete__ a certain user by ID|(% style="width:318px" %)the {is} must be replaced by the user's ID.|(% style="width:430px" %)((( | ||
263 | (% id="cke_bm_5929S" style="display:none" %) (%%)if the user has been deleted successfully : | ||
264 | |||
265 | {{code language="JSON"}} | ||
266 | { | ||
267 | "timestamp": 1637577821566, | ||
268 | "status": "200", | ||
269 | "data": true | ||
270 | } | ||
271 | {{/code}} | ||
272 | |||
273 | if not, the value returned will be a message of the triggered error. | ||
274 | ))) | ||
275 | |||
276 | === === | ||
277 | |||
278 | |||
279 | |||
280 |