Web Services Definition » History » Version 32
Kurt Gerber, 08 Aug 2019 13:59
1 | 10 | Kurt Gerber | h1. API / Web Services Requirements |
---|---|---|---|
2 | 2 | Kurt Gerber | |
3 | h2. Request services |
||
4 | 11 | Kurt Gerber | |
5 | 1 | Kurt Gerber | The existing API is documented here: https://qcat.readthedocs.io/en/latest/api/docs.html |
6 | |||
7 | 12 | Kurt Gerber | h3. Required missing request services: |
8 | 10 | Kurt Gerber | |
9 | 12 | Kurt Gerber | * There is an endpoint to get the configuration for a specific questionnaire and edition: https://https://qcat.wocat.net/en/api/v2/configuration/technologies/2018/ |
10 | 10 | Kurt Gerber | |
11 | 30 | Sebastian Manger | 1. Whithout the 'edition' endpoint, it should respond with an array of available editions. |
12 | 10 | Kurt Gerber | |
13 | 30 | Sebastian Manger | *Endpoint:* @/api/v2/configuration/technologies/@ |
14 | 1 | Kurt Gerber | |
15 | 30 | Sebastian Manger | *Allowed method:* @GET@ |
16 | 1 | Kurt Gerber | |
17 | 30 | Sebastian Manger | *Request Header:* |
18 | * @Authorization: Token AUTH_TOKEN@ |
||
19 | * @Accept: application/json@ or @Accept: application/xml@ |
||
20 | * @Content-Type: application/json@ or @Content-Type: application/xml@ |
||
21 | 1 | Kurt Gerber | |
22 | 30 | Sebastian Manger | *Response:* List of editions for given configuration, e.g. |
23 | * @ {"editions": ["2018", "2006"] @ |
||
24 | 1 | Kurt Gerber | |
25 | |||
26 | 30 | Sebastian Manger | 2. Without the specific configuration endpoint (like 'technologies'), the response should be an array of available configurations. |
27 | 1 | Kurt Gerber | |
28 | |||
29 | 30 | Sebastian Manger | *Endpoint:* @/api/v2/configuration/@ |
30 | 1 | Kurt Gerber | |
31 | 30 | Sebastian Manger | *Allowed method:* @GET@ |
32 | 1 | Kurt Gerber | |
33 | 30 | Sebastian Manger | *Request Header:* |
34 | * @Authorization: Token AUTH_TOKEN@ |
||
35 | * @Accept: application/json@ or @Accept: application/xml@ |
||
36 | * @Content-Type: application/json@ or @Content-Type: application/xml@ |
||
37 | 16 | Kurt Gerber | |
38 | 30 | Sebastian Manger | *Response:* List of configurations, e.g. |
39 | * @ {"configurations": ["technologies", "approaches", "unccd"] @ |
||
40 | 17 | Kurt Gerber | |
41 | 30 | Sebastian Manger | h2. Requirements for services to add / update cases |
42 | 15 | Kurt Gerber | |
43 | 30 | Sebastian Manger | The following new webservice endpoints must be developed. |
44 | 19 | Kurt Gerber | |
45 | 30 | Sebastian Manger | h3. 1. Authentification endpoint |
46 | 19 | Kurt Gerber | |
47 | 30 | Sebastian Manger | This needs a new technical concept. Goals: |
48 | 15 | Kurt Gerber | |
49 | 30 | Sebastian Manger | * Existing authentication must still work (without need to refresh the token), but only for "non-app" requests |
50 | * Requests from the "app" must periodically refresh the authentication |
||
51 | * For all requests from the app, the header "User-Agent: app" (or something similar) must be set. |
||
52 | 1 | Kurt Gerber | |
53 | 30 | Sebastian Manger | Current idea: provide a new authentication backend; skip existing authentication for requests from the app based on some POST flag. |
54 | 31 | Kurt Gerber | *Question/Idea:* What about JSON Web Token (JWT)? |
55 | 32 | Kurt Gerber | |
56 | 1 | Kurt Gerber | h3. 2. Endpoint to create new case |
57 | 17 | Kurt Gerber | |
58 | 14 | Kurt Gerber | |
59 | 17 | Kurt Gerber | *Endpoint:* @/api/v2/en/questionnaires/<configuration>/<edition>/create@ |
60 | 1 | Kurt Gerber | |
61 | 18 | Kurt Gerber | *Allowed method:* @POST@ |
62 | 17 | Kurt Gerber | |
63 | 27 | Kurt Gerber | *POST data:* a valid questionnaire based on the corresponding "configuration template":https://qcat.readthedocs.io/en/latest/api/v2.html#structure-of-configuration |
64 | 17 | Kurt Gerber | |
65 | 1 | Kurt Gerber | *Request Header:* |
66 | 19 | Kurt Gerber | * @Authorization: Token AUTH_TOKEN@ |
67 | * @usertoken: <usertoken>@ |
||
68 | * @Accept: application/json@ or @Accept: application/xml@ |
||
69 | * @Content-Type: application/json@ or @Content-Type: application/xml@ |
||
70 | |||
71 | |||
72 | *Response:* |
||
73 | 20 | Kurt Gerber | <pre><code class="json"> |
74 | 19 | Kurt Gerber | {"success":"true", |
75 | 20 | Kurt Gerber | "code": "technologies_4534" |
76 | 22 | Kurt Gerber | } |
77 | 20 | Kurt Gerber | </code></pre> |
78 | |||
79 | |||
80 | h3. 3. image/file upload |
||
81 | |||
82 | This should be handled the same as already done the ui version. |
||
83 | |||
84 | Adding an image uploads it directly with POST to https://qcat.wocat.net/en/upload |
||
85 | |||
86 | As response it gets a JSON like this: |
||
87 | <pre><code class="json"> |
||
88 | { |
||
89 | "success": true, |
||
90 | "uid": "cfb23a06-385a-47c5-8a94-83cae1fd90b7", |
||
91 | "interchange": [ |
||
92 | "[/upload/9d/a/9da8b521-7130-48df-ba31-549016a748e5.jpg, (default)]", |
||
93 | "[/upload/0a/3/0a3fea13-1485-4ec8-92ee-351eef561d2d.jpg, (small)]", |
||
94 | "[/upload/17/0/170251f9-a9ea-4945-a714-0beaebb7c750.jpg, (medium)]", |
||
95 | 19 | Kurt Gerber | "[/upload/cf/b/cfb23a06-385a-47c5-8a94-83cae1fd90b7.jpg, (large)]" |
96 | 1 | Kurt Gerber | ], |
97 | "url": "/upload/cf/b/cfb23a06-385a-47c5-8a94-83cae1fd90b7.jpg" |
||
98 | } |
||
99 | </code></pre> |
||
100 | 25 | Kurt Gerber | |
101 | The value of the key "uid" is what is then really stored in the 'image' key field of the corresponding questionnaire. |
||
102 | |||
103 | |||
104 | h3. 4. Endpoint to edit a case |
||
105 | |||
106 | *Endpoint:* @/api/v2/en/questionnaires/{configuration}/{edition}/edit/{identifier}@ |
||
107 | |||
108 | %{background:#F2D5A0} Opening a case in draft mode to edit has to take care of different things:% |
||
109 | * %{background:#F2D5A0}Only the newest version of a case can be edited% |
||
110 | * %{background:#F2D5A0}Only if the case is public or in draft mode% |
||
111 | |||
112 | 27 | Kurt Gerber | *Open question:* %{background:#F2D5A0}Locking mechanism in the environment of apps going offline has to be discussed% |
113 | 25 | Kurt Gerber | |
114 | *Request header:* |
||
115 | * @Authorization: Token AUTH_TOKEN@ |
||
116 | * @usertoken: <usertoken>@ |
||
117 | * @Accept: application/json@ or @Accept: application/xml@ |
||
118 | * @Content-Type: application/json@ or @Content-Type: application/xml@ |
||
119 | |||
120 | *Allowed method:* @GET, POST@ |
||
121 | |||
122 | *GET:* |
||
123 | * Response would be the case in 'draft mode' |
||
124 | |||
125 | *POST:* |
||
126 | |||
127 | *POST data:* a valid, updated questionnaire based on the corresponding "configuration template":https://qcat.readthedocs.io/en/latest/api/v2.html#structure-of-configuration |
||
128 | |||
129 | *Response:* |
||
130 | <pre><code class="json"> |
||
131 | {"success":"true", |
||
132 | "code": "technologies_4534" |
||
133 | } |
||
134 | </code></pre> |
||
135 | |||
136 | |||
137 | h3. 5. Endpoint to get mydata |
||
138 | |||
139 | *Endpoint:* @/api/v2/en/questionnaires/mydata@ |
||
140 | |||
141 | 27 | Kurt Gerber | *Allowed method:* @GET@ |
142 | 25 | Kurt Gerber | |
143 | *Request Header:* |
||
144 | * @Authorization: Token AUTH_TOKEN@ |
||
145 | * @usertoken: <usertoken>@ |
||
146 | 1 | Kurt Gerber | * @Accept: application/json@ or @Accept: application/xml@ |
147 | * @Content-Type: application/json@ or @Content-Type: application/xml@ |
||
148 | |||
149 | *Response:* List of public or draft cases of which the user is the compiler |