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