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