github.com/googleapis/api-linter@v1.65.2/docs/rules/0203/resource-name-identifier.md (about) 1 --- 2 rule: 3 aip: 203 4 name: [core, '0203', resource-name-identifier] 5 summary: Resource name field must have field behavior IDENTIFIER. 6 permalink: /203/resource-name-identifier 7 redirect_from: 8 - /0203/resource-name-identifier 9 --- 10 11 # Resource name: IDENTIFIER 12 13 This rule enforces that the field on a resource representing the resource's name 14 is annotated with with `(google.api.field_behavior) = IDENTIFIER`, as mandated 15 by [AIP-203][]. 16 17 ## Details 18 19 This rule looks at every resource message and complains if the resource name 20 field is not annotated with `(google.api.field_behavior) = IDENTIFER`. 21 22 ## Examples 23 24 **Incorrect** code for this rule: 25 26 ```proto 27 message Book { 28 option (google.api.resource) = { 29 type: "library.googleapis.com/Book" 30 pattern: "books/{book}" 31 }; 32 // Missing IDENTIFIER field behavior. 33 string name = 1; 34 } 35 ``` 36 37 **Correct** code for this rule: 38 39 ```proto 40 // Correct. 41 message Book { 42 option (google.api.resource) = { 43 type: "library.googleapis.com/Book" 44 pattern: "books/{book}" 45 }; 46 string name = 1 [(google.api.field_behavior) = IDENTIFIER]; 47 } 48 ``` 49 50 ## Disabling 51 52 If you need to violate this rule, use a leading comment above the field. 53 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 54 55 ```proto 56 message Book { 57 option (google.api.resource) = { 58 type: "library.googleapis.com/Book" 59 pattern: "books/{book}" 60 }; 61 // (-- api-linter: core::0203::resource-name-identifier=disabled 62 // aip.dev/not-precedent: We need to do this because reasons. --) 63 string name = 1; 64 } 65 ``` 66 67 If you need to violate this rule for an entire file, place the comment at the 68 top of the file. 69 70 [aip-203]: https://aip.dev/203 71 [aip.dev/not-precedent]: https://aip.dev/not-precedent