github.com/googleapis/api-linter@v1.65.2/docs/rules/0214/ttl-type.md (about) 1 --- 2 rule: 3 aip: 214 4 name: [core, '0214', ttl-type] 5 summary: The `ttl` field should be a `google.protobuf.Duration`. 6 permalink: /214/ttl-type 7 redirect_from: 8 - /0214/ttl-type 9 --- 10 11 # Resource expiry 12 13 This rule enforces that `ttl` fields use `google.protobuf.Duration`, as 14 mandated in [AIP-214][]. 15 16 ## Details 17 18 This rule looks at fields named `ttl`, and complains if they are a type other 19 than `google.protobuf.Duration`. 20 21 ## Examples 22 23 **Incorrect** code for this rule: 24 25 ```proto 26 // Incorrect. 27 message Book { 28 string name = 1; 29 oneof expiration { 30 google.protobuf.Timestamp expire_time = 2; 31 int32 ttl = 3; // Should be `google.protobuf.Duration`. 32 } 33 } 34 ``` 35 36 **Correct** code for this rule: 37 38 ```proto 39 // Correct. 40 message Book { 41 string name = 1; 42 oneof expiration { 43 google.protobuf.Timestamp expire_time = 2; 44 google.protobuf.Duration ttl = 3; 45 } 46 } 47 ``` 48 49 ## Disabling 50 51 If you need to violate this rule, use a leading comment above the enum. 52 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 53 54 ```proto 55 message Book { 56 string name = 1; 57 oneof expiration { 58 google.protobuf.Timestamp expire_time = 2; 59 // (-- api-linter: core::0214::ttl-type=disabled 60 // aip.dev/not-precedent: We need to do this because reasons. --) 61 int32 ttl = 3; // Should be `google.protobuf.Duration`. 62 } 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-214]: https://aip.dev/214 70 [aip.dev/not-precedent]: https://aip.dev/not-precedent