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