github.com/googleapis/api-linter@v1.65.2/docs/rules/0152/response-message-name.md (about) 1 --- 2 rule: 3 aip: 152 4 name: [core, '0152', response-message-name] 5 summary: Run methods must return a long-running operation. 6 permalink: /152/response-message-name 7 redirect_from: 8 - /0152/response-message-name 9 --- 10 11 # Run methods: Response message 12 13 This rule enforces that all `Run` RPCs return a long-running operation that 14 resolves to a response with a corresponding name, as mandated in [AIP-152][]. 15 16 ## Details 17 18 This rule looks at any method beginning with `Run`, and complains if the 19 response is not a long-running operation that resolves to a response matching 20 the name of the method with a `Response` suffix. 21 22 ## Examples 23 24 **Incorrect** code for this rule: 25 26 ```proto 27 // Incorrect. 28 // Should be `google.longrunning.Operation`. 29 rpc RunWriteBookJob(RunWriteBookJobRequest) returns (RunWriteBookJobResponse) { 30 option (google.api.http) = { 31 post: "/v1/{name=publishers/*/writeBookJobs/*}:run" 32 body: "*" 33 }; 34 } 35 ``` 36 37 **Incorrect** code for this rule: 38 39 ```proto 40 // Incorrect. 41 rpc RunWriteBookJob(RunWriteBookJobRequest) returns (google.longrunning.Operation) { 42 option (google.api.http) = { 43 post: "/v1/{name=publishers/*/writeBookJobs/*}:run" 44 body: "*" 45 }; 46 option (google.longrunning.operation_info) = { 47 // Should be "RunWriteBookJobResponse". 48 response_type: "WriteBookJob" 49 metadata_type: "RunWriteBookJobMetadata" 50 }; 51 } 52 ``` 53 54 **Correct** code for this rule: 55 56 ```proto 57 // Correct. 58 rpc RunWriteBookJob(RunWriteBookJobRequest) returns (google.longrunning.Operation) { 59 option (google.api.http) = { 60 post: "/v1/{name=publishers/*/writeBookJobs/*}:run" 61 body: "*" 62 }; 63 option (google.longrunning.operation_info) = { 64 response_type: "RunWriteBookJobResponse" 65 metadata_type: "RunWriteBookJobMetadata" 66 }; 67 } 68 ``` 69 70 ## Disabling 71 72 If you need to violate this rule, use a leading comment above the method. 73 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 74 75 ```proto 76 // (-- api-linter: core::0152::response-message-name=disabled 77 // aip.dev/not-precedent: We need to do this because reasons. --) 78 rpc RunWriteBookJob(RunWriteBookJobRequest) returns (RunWriteBookJobResponse) { 79 option (google.api.http) = { 80 post: "/v1/{name=publishers/*/writeBookJobs/*}:run" 81 body: "*" 82 }; 83 } 84 ``` 85 86 If you need to violate this rule for an entire file, place the comment at the 87 top of the file. 88 89 [aip-152]: https://aip.dev/152 90 [aip.dev/not-precedent]: https://aip.dev/not-precedent