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