github.com/googleapis/api-linter@v1.65.2/docs/rules/0165/request-parent-behavior.md (about) 1 --- 2 rule: 3 aip: 165 4 name: [core, '0165', request-parent-behavior] 5 summary: | 6 Purge requests should annotate the `parent` field with `google.api.field_behavior`. 7 permalink: /165/request-parent-behavior 8 redirect_from: 9 - /0165/request-parent-behavior 10 --- 11 12 # Purge requests: Parent field behavior 13 14 This rule enforces that all `Purge` requests have 15 `google.api.field_behavior` set to `REQUIRED` on their `string parent` field, as 16 mandated in [AIP-165][]. 17 18 ## Details 19 20 This rule looks at any message matching `Purge*Request` and complains if the 21 `parent` field does not have a `google.api.field_behavior` annotation with a 22 value of `REQUIRED`. 23 24 ## Examples 25 26 **Incorrect** code for this rule: 27 28 ```proto 29 // Incorrect. 30 message PurgeBooksRequest { 31 // The `google.api.field_behavior` annotation should also be included. 32 string parent = 1 [ 33 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 34 ]; 35 36 string filter = 2 [(google.api.field_behavior) = REQUIRED]; 37 38 bool force = 3; 39 } 40 ``` 41 42 **Correct** code for this rule: 43 44 ```proto 45 // Correct. 46 message PurgeBooksRequest { 47 string parent = 1 [ 48 (google.api.field_behavior) = REQUIRED, 49 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 50 ]; 51 52 string filter = 2 [(google.api.field_behavior) = REQUIRED]; 53 54 bool force = 3; 55 } 56 ``` 57 58 ## Disabling 59 60 If you need to violate this rule, use a leading comment above the field. 61 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 62 63 ```proto 64 message PurgeBooksRequest { 65 // (-- api-linter: core::0165::request-parent-behavior=disabled 66 // aip.dev/not-precedent: We need to do this because reasons. --) 67 string parent = 1 [ 68 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 69 ]; 70 71 string filter = 2 [(google.api.field_behavior) = REQUIRED]; 72 73 bool force = 3; 74 } 75 ``` 76 77 If you need to violate this rule for an entire file, place the comment at the 78 top of the file. 79 80 [aip-165]: https://aip.dev/165 81 [aip.dev/not-precedent]: https://aip.dev/not-precedent