github.com/googleapis/api-linter@v1.65.2/docs/rules/0132/request-parent-behavior.md (about) 1 --- 2 rule: 3 aip: 132 4 name: [core, '0132', request-parent-behavior] 5 summary: | 6 List RPCs should annotate the `parent` field with `google.api.field_behavior`. 7 permalink: /132/request-parent-behavior 8 redirect_from: 9 - /0132/request-parent-behavior 10 --- 11 12 # List methods: Field behavior 13 14 This rule enforces that all `List` standard methods have 15 `google.api.field_behavior` set to `REQUIRED` on their `string parent` field, 16 as mandated in [AIP-132][]. 17 18 ## Details 19 20 This rule looks at any message matching `List*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 ListBooksRequest { 31 // The `google.api.field_behavior` annotation should also be included. 32 string parent = 1 [(google.api.resource_reference) = { 33 type: "library.googleapis.com/Publisher" 34 }]; 35 int32 page_size = 2; 36 string page_token = 3; 37 } 38 ``` 39 40 **Correct** code for this rule: 41 42 ```proto 43 // Correct. 44 message ListBooksRequest { 45 string parent = 1 [ 46 (google.api.field_behavior) = REQUIRED, 47 (google.api.resource_reference).type = "library.googleapis.com/Publisher" 48 ]; 49 int32 page_size = 2; 50 string page_token = 3; 51 } 52 ``` 53 54 ## Disabling 55 56 If you need to violate this rule, use a leading comment above the field. 57 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 58 59 ```proto 60 // (-- api-linter: core::0132::request-parent-behavior=disabled 61 // aip.dev/not-precedent: We need to do this because reasons. --) 62 message ListBooksRequest { 63 string parent = 1 [(google.api.resource_reference) = { 64 type: "library.googleapis.com/Publisher" 65 }]; 66 int32 page_size = 2; 67 string page_token = 3; 68 } 69 ``` 70 71 If you need to violate this rule for an entire file, place the comment at the 72 top of the file. 73 74 [aip-132]: https://aip.dev/132 75 [aip.dev/not-precedent]: https://aip.dev/not-precedent