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