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