github.com/googleapis/api-linter@v1.65.2/docs/rules/0164/resource-expire-time-field.md (about) 1 --- 2 rule: 3 aip: 164 4 name: [core, '0164', resource-expire-time-field] 5 summary: Resources supporting soft delete must have an `expire_time` field. 6 permalink: /164/resource-expire-time-field 7 redirect_from: 8 - /0164/resource-expire-time-field 9 --- 10 11 # Resources supporting soft delete: `expire_time` field required 12 13 This rule enforces that all resources supporting soft delete have an 14 `google.protobuf.Timestamp expire_time` field, as mandated in [AIP-164][]. 15 16 ## Details 17 18 This rule looks at any resource with a corresponding `Undelete*` method, and 19 complains if it does not have a `google.protobuf.Timestamp expire_time` field. 20 21 ## Examples 22 23 **Incorrect** code for this rule: 24 25 ```proto 26 // Incorrect. 27 service Library { 28 rpc UndeleteBook(UndeleteBookRequest) returns (Book) { 29 option (google.api.http) = { 30 post: "/v1/{name=publishers/*/books/*}:undelete" 31 body: "*" 32 }; 33 } 34 } 35 36 message Book { 37 option (google.api.resource) = { 38 type: "library.googleapis.com/Book" 39 pattern: "publishers/{publisher}/books/{book}" 40 }; 41 42 string name = 1; 43 44 // Should have an `expire_time` field. 45 } 46 ``` 47 48 **Correct** code for this rule: 49 50 ```proto 51 // Correct. 52 service Library { 53 rpc UndeleteBook(UndeleteBookRequest) returns (Book) { 54 option (google.api.http) = { 55 post: "/v1/{name=publishers/*/books/*}:undelete" 56 body: "*" 57 }; 58 }; 59 } 60 61 message Book { 62 option (google.api.resource) = { 63 type: "library.googleapis.com/Book" 64 pattern: "publishers/{publisher}/books/{book}" 65 }; 66 67 string name = 1; 68 69 google.protobuf.Timestamp expire_time = 2; 70 } 71 ``` 72 73 ## Disabling 74 75 If you need to violate this rule, use a leading comment above the resource. 76 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 77 78 ```proto 79 service Library { 80 rpc UndeleteBook(UndeleteBookRequest) returns (Book) { 81 option (google.api.http) = { 82 post: "/v1/{name=publishers/*/books/*}:undelete" 83 body: "*" 84 }; 85 }; 86 } 87 88 // (-- api-linter: core::0164::resource-expire-time-field=disabled 89 // aip.dev/not-precedent: We need to do this because reasons. --) 90 message Book { 91 option (google.api.resource) = { 92 type: "library.googleapis.com/Book" 93 pattern: "publishers/{publisher}/books/{book}" 94 }; 95 96 string name = 1; 97 } 98 ``` 99 100 If you need to violate this rule for an entire file, place the comment at the 101 top of the file. 102 103 [aip-164]: https://aip.dev/164 104 [aip.dev/not-precedent]: https://aip.dev/not-precedent