github.com/googleapis/api-linter@v1.65.2/docs/rules/0133/response-lro.md (about)

     1  ---
     2  rule:
     3    aip: 133
     4    name: [core, '0133', response-lro]
     5    summary: |
     6      Declarative-friendly create methods should use long-running operations.
     7  permalink: /133/response-lro
     8  redirect_from:
     9    - /0133/response-lro
    10  ---
    11  
    12  # Long-running create
    13  
    14  This rule enforces that declarative-friendly create methods use long-running
    15  operations, as mandated in [AIP-133][].
    16  
    17  ## Details
    18  
    19  This rule looks at any `Create` method connected to a resource with a
    20  `google.api.resource` annotation that includes `style: DECLARATIVE_FRIENDLY`,
    21  and complains if it does not use long-running operations.
    22  
    23  ## Examples
    24  
    25  **Incorrect** code for this rule:
    26  
    27  ```proto
    28  // Incorrect.
    29  // Assuming that Book is styled declarative-friendly, CreateBook should
    30  // return a long-running operation.
    31  rpc CreateBook(CreateBookRequest) returns (Book) {
    32    option (google.api.http) = {
    33      post: "/v1/{parent=publishers/*}/books"
    34      body: "book"
    35    };
    36  }
    37  ```
    38  
    39  **Correct** code for this rule:
    40  
    41  ```proto
    42  // Correct.
    43  // Assuming that Book is styled declarative-friendly...
    44  rpc CreateBook(CreateBookRequest) returns (google.longrunning.Operation) {
    45    option (google.api.http) = {
    46      post: "/v1/{parent=publishers/*}/books"
    47      body: "book"
    48    };
    49    option (google.longrunning.operation_info) = {
    50      response_type: "Book"
    51      metadata_type: "OperationMetadata"
    52    };
    53  }
    54  ```
    55  
    56  ## Disabling
    57  
    58  If you need to violate this rule, use a leading comment above the message.
    59  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    60  
    61  ```proto
    62  // (-- api-linter: core::0133::response-lro=disabled
    63  //     aip.dev/not-precedent: We need to do this because reasons. --)
    64  rpc CreateBook(CreateBookRequest) returns (Book) {
    65    option (google.api.http) = {
    66      post: "/v1/{parent=publishers/*}/books"
    67      body: "book"
    68    };
    69  }
    70  ```
    71  
    72  **Note:** Violations of declarative-friendly rules should be rare, as tools are
    73  likely to expect strong consistency.
    74  
    75  If you need to violate this rule for an entire file, place the comment at the
    76  top of the file.
    77  
    78  [aip-133]: https://aip.dev/133
    79  [aip.dev/not-precedent]: https://aip.dev/not-precedent