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