Skip to content

Commit ba9c709

Browse files
author
Luke Sneeringer
committed
Incorporate Mike and Dan feedback.
1 parent fe91348 commit ba9c709

2 files changed

Lines changed: 44 additions & 20 deletions

File tree

aip/general/0163/aip.md.j2

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,64 @@ and cost, and could potentially have unexpected downstream effects.
77

88
## Guidance
99

10-
APIs **may** provide an option to validate, but not actually execute, a
11-
request, and provide the same response (status code, headers, and response
12-
body) that it would have provided if the request was actually executed.
13-
14-
To provide this option, the method **should** include a `validate_only` boolean
15-
field:
10+
Operations **may** provide an field to validate, but not actually execute, the
11+
request. To provide this option, the operation **should** include a `dry_run`
12+
boolean field:
1613

1714
```http
18-
POST /v1/publishers/{publisher}/books?validate_only=true HTTP/2
15+
PATCH /v1/publishers/{publisher}/books/{book}?dryRun=true HTTP/2
1916
Host: library.googleapis.com
2017
Accept: application/json
2118
```
2219

23-
- Standard operations **must** expose the `validate_only` field on the query
24-
string.
25-
- Custom operations **may** expose the `validate_only` field in the request
26-
body, on the query string, or accept either one.
20+
- Standard operations **must** expose the `dry_run` field on the query string.
21+
- Custom operations **may** expose the `dry_run` field in the request body, on
22+
the query string, or accept either one.
23+
24+
### Responses
25+
26+
An operation **may** return a `204 No Content` response when asked to perform a
27+
dry run, which **must** be an empty response.
2728

28-
The API **must** perform permission checks and any other validation that would
29-
be performed on a "live" request; a request using `validate_only` **must** fail
30-
if it determines that the actual request would fail.
29+
Alternatively, an operation **may** provide the same response (status code,
30+
headers, and response body) that it would have provided if the request was
31+
actually executed.
3132

32-
**Note:** It may occasionally be infeasible to provide the full output. For
33+
Under this approach, it may be infeasible to provide the full output. For
3334
example, if creating a resource would create an auto-generated ID, it does not
34-
make sense to do this on validation. APIs **should** omit such fields on
35-
validation requests in this situation.
35+
make sense to do this on validation. The operation **should** prefer to use
36+
`204 No Content` in this scenario, but if a populated response is needed, the
37+
operation **should** omit such fields on the response.
38+
39+
**Note:** When representing fields that can not be populated, non-zero or
40+
non-empty sentinel values **must not** be used.
41+
42+
### Validation scope
43+
44+
When performing a dry run, the service **should** check all of the following:
45+
46+
- The validity of the request according to the schema.
47+
- Referential integrity of values in the request, if applicable.
48+
- Whether the user has permission to make the request.
49+
- Whether the user has sufficient quota to make the request.
50+
51+
A request using `dry_run` **must** fail if it can be determined that the actual
52+
request would fail.
53+
54+
**Note:** An operation **may** elect not to exhaustively check certain
55+
implementation-specific details if validating them would be expensive or pose a
56+
security concern. Therefore, a successful dry run indicates that an equivalent
57+
live request is likely to succeed, but is not a full guarantee of success.
3658

3759
## Interface Definitions
3860

3961
{% tab proto %}
4062

4163
{% sample 'standard_operation.proto', 'message CreateBookRequest' %}
4264

43-
- The `validate_only` field **must** use the `bool` type.
44-
- The `validate_only` field **must not** be annotated as `REQUIRED`.
65+
- The `dry_run` field **must** use the `bool` type.
66+
- The `dry_run` field **must not** be annotated as `REQUIRED`.
67+
- In protocol buffers, the same response type is always used for a single RPC.
68+
The operation **may** return the response message with no fields populated.
4569

4670
{% endtabs %}

aip/general/0163/standard_operation.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ message CreateBookRequest {
4646

4747
// If set, validate the request and preview the review, but do not actually
4848
// post it.
49-
bool validate_only = 3;
49+
bool dry_run = 3;
5050
}
5151

5252
// A representation of a single book.

0 commit comments

Comments
 (0)