Skip to content

Commit ef87b4d

Browse files
committed
Sync open source content 🐝 (from 83bbdb44fc57e1110c61288dac838e5502060f3c)
1 parent 40c1a00 commit ef87b4d

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

docs/sdks/customize/runtime/polling.mdx

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,39 @@ The `WaitForCompleted` polling method makes at most 120 API operation requests.
155155

156156
### successCriteria
157157

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.
159159

160-
Supported conditions include:
160+
Supported criterion contexts include:
161161

162-
- `$statusCode`: HTTP status code. Must be defined before response body conditions.
162+
- `$statusCode`: HTTP status code. Must be defined before response body context.
163163
- `$response.body`: HTTP response body data. A value within the data is defined with a JSONPath expression.
164164

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:
166175

167176
- `==`: Equals
168177
- `!=`: Not Equals
169178

179+
In this example:
180+
181+
```yaml
182+
x-speakeasy-polling:
183+
- name: WaitForCompleted
184+
successCriteria:
185+
- condition: $statusCode == 200
186+
- condition: $response.body#/status == "completed"
187+
```
188+
189+
The `WaitForCompleted` polling method waits until both the HTTP status code is 200 and the HTTP response body `status` property is `completed`.
190+
170191
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.
171192

172193
In this example:
@@ -179,3 +200,26 @@ x-speakeasy-polling:
179200
```
180201

181202
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

Comments
 (0)