@@ -37,19 +37,27 @@ def get_caps():
37
37
return jsonify (res ), res_code
38
38
39
39
40
- def parse_batch_request (req ):
41
- """
42
- Checks a batch request dict for the required fields:
40
+ batch_args = """
41
+ Each individual batch subrequest is a list of dicts containing keys:
43
42
44
- - method is required and must be one of GET/DELETE/POST/PUT
45
- - path is required and must begin with a /
43
+ - ` method` is required and must be one of GET/DELETE/POST/PUT
44
+ - ` path` is required and must begin with a /
46
45
- for POST/PUT requests there must be exactly one of:
47
- - a json value under the 'json' key
48
- - a base64-encoded body under the 'b64' key
49
- - a raw bytes value under the 'bytes' key (not recommended for json)
50
- - headers may be provided, and must be a dict of k/v string pairs if provided.
46
+ - a json value under the `json` key
47
+ - a base64-encoded body under the `b64` key
48
+ - a raw bytes value under the `bytes` key (not recommended for json)
49
+ - `headers` may be provided, and must be a dict of k/v string pairs if provided.
50
+
51
+ If non-conforming data is encountered then the request is terminated with a Bad Request error
52
+ code.
53
+ """
54
+
55
+
56
+ def parse_batch_request (req ):
57
+ f"""
58
+ Checks a batch request dict for the required fields.
51
59
52
- If non-conforming data is encountered then a BAD_REQUEST request abort is raised.
60
+ { batch_args }
53
61
54
62
Returns (method, path, headers, json, body). `headers` will be a dict (empty if no headers were
55
63
provided); `json`/`body` will be None for GET/DELETE requests; `json` will simply be the `json`
@@ -124,6 +132,12 @@ def batch(_sequential=False):
124
132
be attempted. There is no guarantee on the order in which requests will be carried out. (For
125
133
sequential, related requests invoke via /sequence instead).
126
134
135
+ # Body
136
+
137
+ {batch_args}
138
+
139
+ # Return value
140
+
127
141
Returns a list of responses in the same order as the provided requests; each response consists
128
142
of a dict containing:
129
143
- code -- the numeric http response code (e.g. 200 for success)
@@ -171,6 +185,8 @@ def sequence():
171
185
Like batch, responses are returned in the same order as requests, but unlike batch there may be
172
186
fewer elements in the response list (if requests were stopped because of a non-2xx response).
173
187
In such a case, the final, non-2xx response is still included as the final response value.
188
+
189
+ See [`/batch`](#post-batch) for arguments and response.
174
190
"""
175
191
176
192
return batch (_sequential = True )
0 commit comments