github.com/googleapis/api-linter@v1.65.2/docs/rules/0162/rollback-request-revision-id-field.md (about) 1 --- 2 rule: 3 aip: 162 4 name: [core, '0162', rollback-request-revision-id-field] 5 summary: Rollback RPCs must have a `revision_id` field in the request. 6 permalink: /162/rollback-request-revision-id-field 7 redirect_from: 8 - /0162/rollback-request-revision-id-field 9 --- 10 11 # Rollback requests: Revision ID field 12 13 This rule enforces that all `Rollback` methods have a `string revision_id` 14 field in the request message, as mandated in [AIP-162][]. 15 16 ## Details 17 18 This rule looks at any message matching `Rollback*Request` and complains if 19 either the `revision_id` 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 revision_id` field. 28 message RollbackBookRequest { 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 RollbackBookRequest { 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 revision_id = 2 [(google.api.field_behavior) = REQUIRED]; 46 } 47 ``` 48 49 **Correct** code for this rule: 50 51 ```proto 52 // Correct. 53 message RollbackBookRequest { 54 string name = 1 [ 55 (google.api.field_behavior) = REQUIRED, 56 (google.api.resource_reference).type = "library.googleapis.com/Book" 57 ]; 58 59 string revision_id = 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 `name` 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 RollbackBookRequest { 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::rollback-request-revision-id-field=disabled 77 // aip.dev/not-precedent: We need to do this because reasons. --) 78 bytes revision_id = 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