github.com/googleapis/api-linter@v1.65.2/docs/rules/0164/response-message-name.md (about) 1 --- 2 rule: 3 aip: 164 4 name: [core, '0164', response-message-name] 5 summary: Undelete methods must return the resource. 6 permalink: /164/response-message-name 7 redirect_from: 8 - /0164/response-message-name 9 --- 10 11 # Undelete methods: Response message 12 13 This rule enforces that all `Undelete` RPCs have a response message of 14 the resource, as mandated in [AIP-164][]. 15 16 ## Details 17 18 This rule looks at any message beginning with `Undelete`, and complains 19 if the name of the corresponding output message does not match the name of the 20 RPC with the prefix `Undelete` removed. 21 22 It also permits a response of `google.longrunning.Operation`; in this case, it 23 checks the `response_type` in the `google.longrunning.operation_info` 24 annotation and ensures that _it_ corresponds to the name of the RPC with the 25 prefix `Undelete` removed. 26 27 ## Examples 28 29 ### Standard 30 31 **Incorrect** code for this rule: 32 33 ```proto 34 // Incorrect. 35 // Should be `Book`. 36 rpc UndeleteBook(UndeleteBookRequest) returns (UndeleteBookResponse) { 37 option (google.api.http) = { 38 post: "/v1/{name=publishers/*/books/*}:undelete" 39 body: "*" 40 }; 41 } 42 ``` 43 44 **Correct** code for this rule: 45 46 ```proto 47 // Correct. 48 rpc UndeleteBook(UndeleteBookRequest) returns (Book) { 49 option (google.api.http) = { 50 post: "/v1/{name=publishers/*/books/*}:undelete" 51 body: "*" 52 }; 53 } 54 ``` 55 56 ### Long-running operation 57 58 **Incorrect** code for this rule: 59 60 ```proto 61 // Incorrect. 62 rpc UndeleteBook(UndeleteBookRequest) returns (google.longrunning.Operation) { 63 option (google.api.http) = { 64 post: "/v1/{name=publishers/*/books/*}:undelete" 65 body: "*" 66 }; 67 option (google.longrunning.operation_info) = { 68 // Should be "Book". 69 response_type: "UndeleteBookResponse" 70 metadata_type: "UndeleteBookMetadata" 71 }; 72 } 73 ``` 74 75 **Correct** code for this rule: 76 77 ```proto 78 // Correct. 79 rpc UndeleteBook(UndeleteBookRequest) returns (google.longrunning.Operation) { 80 option (google.api.http) = { 81 post: "/v1/{name=publishers/*/books/*}:undelete" 82 body: "*" 83 }; 84 option (google.longrunning.operation_info) = { 85 response_type: "Book" 86 metadata_type: "UndeleteBookMetadata" 87 }; 88 } 89 ``` 90 91 ## Disabling 92 93 If you need to violate this rule, use a leading comment above the method. 94 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 95 96 ```proto 97 // (-- api-linter: core::0164::response-message-name=disabled 98 // aip.dev/not-precedent: We need to do this because reasons. --) 99 rpc UndeleteBook(UndeleteBookRequest) returns (UndeleteBookResponse) { 100 option (google.api.http) = { 101 post: "/v1/{name=publishers/*/books/*}:undelete" 102 body: "*" 103 }; 104 } 105 ``` 106 107 If you need to violate this rule for an entire file, place the comment at the 108 top of the file. 109 110 [aip-164]: https://aip.dev/164 111 [aip.dev/not-precedent]: https://aip.dev/not-precedent