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