You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sdks/customize/runtime/polling.mdx
+48-4Lines changed: 48 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,18 +155,39 @@ The `WaitForCompleted` polling method makes at most 120 API operation requests.
155
155
156
156
### successCriteria
157
157
158
-
Configure the polling method success criteria. This configuration is required for all polling methods. The criteria themselves are a limited subset of [OpenAPI Arazzo criterion](https://spec.openapis.org/arazzo/latest.html#criterion-object). Each condition is a logical AND operation, evaluated in configuration order.
158
+
Configure the polling method success criteria. This configuration is required for all polling methods and is a limited subset of [OpenAPI Arazzo criterion](https://spec.openapis.org/arazzo/latest.html#criterion-object). Each criterion is evaluated in configuration order as a logical AND with prior criterion.
159
159
160
-
Supported conditions include:
160
+
Supported criterion contexts include:
161
161
162
-
- `$statusCode`: HTTP status code. Must be defined before response body conditions.
162
+
- `$statusCode`: HTTP status code. Must be defined before response body context.
163
163
- `$response.body`: HTTP response body data. A value within the data is defined with a JSONPath expression.
164
164
165
-
Supported operators include:
165
+
Supported criterion types include:
166
+
167
+
- `simple`: Assert against a context value using logical operators, such as equals. Default when no `type` is defined.
168
+
- `regex`: Assert against a context value using a regular expression pattern.
169
+
170
+
#### simple criterion
171
+
172
+
Define context, logical operator, and the value via `condition`.
173
+
174
+
Supported `simple` type logical operators include:
The `WaitForCompleted` polling method waits until both the HTTP status code is 200 and the HTTP response body `status` property is `completed`.
190
+
170
191
Certain language implementations, such as Go, also support using error status codes as success criteria. In these cases any SDK error that would have been returned to the SDK client are swallowed instead.
171
192
172
193
In this example:
@@ -179,3 +200,26 @@ x-speakeasy-polling:
179
200
```
180
201
181
202
The `WaitForNotFound` polling method immediately returns without error when the API operation returns a 404 Not Found HTTP status code.
203
+
204
+
#### regex criterion
205
+
206
+
Define context via `context` and the regular expression pattern via `condition`.
207
+
208
+
<Callout title="Note" type="info">
209
+
The regular expression pattern must be compatible with the target language.
210
+
For example, the Go language uses the RE2 regular expression engine.
211
+
</Callout>
212
+
213
+
In this example:
214
+
215
+
```yaml
216
+
x-speakeasy-polling:
217
+
- name: WaitForCompleted
218
+
successCriteria:
219
+
- condition: $statusCode == 200
220
+
- context: $response.body#/status
221
+
condition: "^(completed|ready)$"
222
+
type: regex
223
+
```
224
+
225
+
The `WaitForCompleted` polling method waits until both the HTTP status code is 200 and the HTTP response body `status` property is either `completed` or `ready`.
0 commit comments