github.com/googleapis/api-linter@v1.65.2/docs/rules/0151/response-unary.md (about) 1 --- 2 rule: 3 aip: 151 4 name: [core, '0151', response-unary] 5 summary: Long-running operations must not use streaming. 6 permalink: /151/response-unary 7 redirect_from: 8 - /0151/response-unary 9 --- 10 11 # Paginated methods: Unary responses 12 13 This rule enforces that all long-running operation methods use unary responses, 14 as mandated in [AIP-151][]. 15 16 ## Details 17 18 This rule looks at any message returning a `google.longrunning.Operation`, and 19 complains if the method uses gRPC server streaming (the `stream` keyword). 20 21 ## Examples 22 23 **Incorrect** code for this rule: 24 25 ```proto 26 // Incorrect. 27 // Streaming is prohibited on long-running operations. 28 rpc ReadBook(ReadBookRequest) returns (stream google.longrunning.Operation) { 29 option (google.api.http) = { 30 post: "/v1/{parent=publishers/*/books/*}:read" 31 body: "*" 32 }; 33 } 34 ``` 35 36 **Correct** code for this rule: 37 38 ```proto 39 // Correct. 40 rpc ReadBook(ReadBookRequest) returns (google.longrunning.Operation) { 41 option (google.api.http) = { 42 post: "/v1/{parent=publishers/*/books/*}:read" 43 body: "*" 44 }; 45 } 46 ``` 47 48 ## Disabling 49 50 If you need to violate this rule, use a leading comment above the message or 51 above the field. Remember to also include an [aip.dev/not-precedent][] comment 52 explaining why. 53 54 ```proto 55 // (-- api-linter: core::0151::response-unary 56 // aip.dev/not-precedent: We need to do this because reasons. --) 57 rpc ReadBook(ReadBookRequest) returns (stream google.longrunning.Operation) { 58 option (google.api.http) = { 59 post: "/v1/{parent=publishers/*/books/*}:read" 60 body: "*" 61 }; 62 } 63 ``` 64 65 If you need to violate this rule for an entire file, place the comment at the 66 top of the file. 67 68 [aip-151]: https://aip.dev/151 69 [aip.dev/not-precedent]: https://aip.dev/not-precedent