github.com/googleapis/api-linter@v1.65.2/docs/rules/0151/operation-info.md (about) 1 --- 2 rule: 3 aip: 151 4 name: [core, '0151', operation-info] 5 summary: LRO methods must include an `operation_info` annotation. 6 permalink: /151/operation-info 7 redirect_from: 8 - /0151/operation-info 9 --- 10 11 # Long-running operation info 12 13 This rule enforces that methods returning long-running operations include an 14 annotation specifying their response type and metadata type, as mandated in 15 [AIP-151][]. 16 17 ## Details 18 19 This rule looks at any method with a return type of 20 `google.longrunning.Operation`, and complains if the 21 `google.longrunning.operation_info` annotation is not present. 22 23 ## Examples 24 25 **Incorrect** code for this rule: 26 27 ```proto 28 // Incorrect. 29 rpc WriteBook(WriteBookRequest) returns (google.longrunning.Operation) { 30 option (google.api.http) = { 31 post: "/v1/{name=publishers/*/books}:write" 32 body: "*" 33 }; 34 // There should be a google.longrunning.operation_info annotation. 35 } 36 ``` 37 38 **Correct** code for this rule: 39 40 ```proto 41 // Correct. 42 rpc WriteBook(WriteBookRequest) returns (google.longrunning.Operation) { 43 option (google.api.http) = { 44 post: "/v1/{name=publishers/*/books}:write" 45 body: "*" 46 }; 47 option (google.longrunning.operation_info) = { 48 response_type: "WriteBookResponse" 49 metadata_type: "WriteBookMetadata" 50 }; 51 } 52 ``` 53 54 ## Disabling 55 56 If you need to violate this rule, use a leading comment above the method. 57 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 58 59 ```proto 60 // (-- api-linter: core::0151::operation-info=disabled 61 // aip.dev/not-precedent: We need to do this because reasons. --) 62 rpc WriteBook(WriteBookRequest) returns (google.longrunning.Operation) { 63 option (google.api.http) = { 64 post: "/v1/{name=publishers/*/books}:write" 65 body: "*" 66 }; 67 } 68 ``` 69 70 If you need to violate this rule for an entire file, place the comment at the 71 top of the file. 72 73 [aip-151]: https://aip.dev/151 74 [aip.dev/not-precedent]: https://aip.dev/not-precedent