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