github.com/googleapis/api-linter@v1.65.2/docs/rules/0134/response-message-name.md (about) 1 --- 2 rule: 3 aip: 134 4 name: [core, '0134', response-message-name] 5 summary: Update methods must return the resource. 6 permalink: /134/response-message-name 7 redirect_from: 8 - /0134/response-message-name 9 --- 10 11 # Update methods: Resource response message 12 13 This rule enforces that all `Update` RPCs have a response message of the 14 resource, as mandated in [AIP-134][]. 15 16 ## Details 17 18 This rule looks at any message matching beginning with `Update`, and complains 19 if the name of the corresponding output message does not match the name of the 20 RPC with the prefix `Update` 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 `Update` 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 UpdateBook(UpdateBookRequest) returns (UpdateBookResponse) { 37 option (google.api.http) = { 38 patch: "/v1/{book.name=publishers/*/books/*}" 39 body: "book" 40 }; 41 } 42 ``` 43 44 **Correct** code for this rule: 45 46 ```proto 47 // Correct. 48 rpc UpdateBook(UpdateBookRequest) returns (Book) { 49 option (google.api.http) = { 50 patch: "/v1/{book.name=publishers/*/books/*}" 51 body: "book" 52 }; 53 } 54 ``` 55 56 ### Long-running operation 57 58 **Incorrect** code for this rule: 59 60 ```proto 61 // Incorrect. 62 rpc UpdateBook(UpdateBookRequest) returns (google.longrunning.Operation) { 63 option (google.api.http) = { 64 patch: "/v1/{book.name=publishers/*/books/*}" 65 body: "book" 66 }; 67 option (google.longrunning.operation_info) = { 68 response_type: "UpdateBookResponse" // Should be "Book". 69 metadata_type: "UpdateBookMetadata" 70 }; 71 } 72 ``` 73 74 **Correct** code for this rule: 75 76 ```proto 77 // Correct. 78 rpc UpdateBook(UpdateBookRequest) returns (google.longrunning.Operation) { 79 option (google.api.http) = { 80 patch: "/v1/{book.name=publishers/*/books/*}" 81 body: "book" 82 }; 83 option (google.longrunning.operation_info) = { 84 response_type: "Book" 85 metadata_type: "UpdateBookMetadata" 86 }; 87 } 88 ``` 89 90 ## Disabling 91 92 If you need to violate this rule, use a leading comment above the method. 93 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 94 95 ```proto 96 // (-- api-linter: core::0134::response-message-name=disabled 97 // aip.dev/not-precedent: We need to do this because reasons. --) 98 rpc UpdateBook(UpdateBookRequest) returns (UpdateBookResponse) { 99 option (google.api.http) = { 100 patch: "/v1/{book.name=publishers/*/books/*}" 101 body: "book" 102 }; 103 } 104 ``` 105 106 If you need to violate this rule for an entire file, place the comment at the 107 top of the file. 108 109 [aip-134]: https://aip.dev/134 110 [aip.dev/not-precedent]: https://aip.dev/not-precedent