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