github.com/googleapis/api-linter@v1.65.2/docs/rules/0165/response-purge-sample-field.md (about) 1 --- 2 rule: 3 aip: 165 4 name: [core, '0165', response-purge-sample-field] 5 summary: Purge RPCs must have a `purge_sample` field in the response. 6 permalink: /165/response-purge-sample-field 7 redirect_from: 8 - /0165/response-purge-sample-field 9 --- 10 11 # Purge responses: Purge sample field 12 13 This rule enforces that all `Purge` methods have a `repeated string 14 purge_sample` field in the response message, as mandated in [AIP-165][]. 15 16 ## Details 17 18 This rule looks at any message matching `Purge*Response` and complains if 19 either the `purge_sample` field is missing, or if it has any type other than 20 `repeated string`. 21 22 ## Examples 23 24 **Incorrect** code for this rule: 25 26 ```proto 27 // Incorrect. 28 // Should include a `repeated string purge_sample` field. 29 message PurgeBooksResponse { 30 int32 purge_count = 1; 31 } 32 ``` 33 34 ```proto 35 // Incorrect. 36 message PurgeBooksResponse { 37 int64 purge_count = 1; 38 39 // Field type should be `repeated string`. 40 repeated bytes purge_sample = 2 [ 41 (google.api.resource_reference).type = "library.googleapis.com/Book" 42 ]; 43 } 44 ``` 45 46 **Correct** code for this rule: 47 48 ```proto 49 // Correct. 50 message PurgeBooksResponse { 51 int32 purge_count = 1; 52 53 repeated string purge_sample = 2 [ 54 (google.api.resource_reference).type = "library.googleapis.com/Book" 55 ]; 56 } 57 ``` 58 59 ## Disabling 60 61 If you need to violate this rule, use a leading comment above the message (if 62 the `purge_sample` field is missing) or above the field (if it is the wrong 63 type). Remember to also include an [aip.dev/not-precedent][] comment explaining 64 why. 65 66 ```proto 67 message PurgeBooksResponse { 68 int32 purge_count = 1; 69 70 // (-- api-linter: core::0165::response-purge-sample-field=disabled 71 // aip.dev/not-precedent: We need to do this because reasons. --) 72 repeated bytes purge_sample = 2 [ 73 (google.api.resource_reference).type = "library.googleapis.com/Book" 74 ]; 75 } 76 ``` 77 78 If you need to violate this rule for an entire file, place the comment at the 79 top of the file. 80 81 [aip-165]: https://aip.dev/165 82 [aip.dev/not-precedent]: https://aip.dev/not-precedent