github.com/googleapis/api-linter@v1.65.2/docs/rules/0234/request-requests-field.md (about)

     1  ---
     2  rule:
     3    aip: 234
     4    name: [core, '0234', request-requests-field]
     5    summary: Batch Update RPCs should have a `requests` field in the request.
     6  permalink: /234/request-requests-field
     7  redirect_from:
     8    - /0234/request-requests-field
     9  ---
    10  
    11  # Batch Update methods: Requests field
    12  
    13  This rule enforces that all `BatchUpdate` methods have a repeated `requests`
    14  field, the type of which is the standard Update request (`Update*Request`)
    15  in the request message, as mandated in [AIP-234][].
    16  
    17  ## Details
    18  
    19  This rule looks at any message matching `BatchUpdate*Request` and complains if
    20  the `requests` field is missing, if it has any type other than `Update*Request`,
    21  or if it is not `repeated`.
    22  
    23  ## Examples
    24  
    25  **Incorrect** code for this rule:
    26  
    27  ```proto
    28  // Incorrect.
    29  message BatchUpdateBooksRequest {
    30    string parent = 1 [
    31      (google.api.resource_reference).child_type = "library.googleapis.com/Book"
    32    ];
    33  
    34    repeated UpdateBookRequest req = 2;  // Field name should be `requests`.
    35  }
    36  ```
    37  
    38  ```proto
    39  // Incorrect.
    40  message BatchUpdateBooksRequest {
    41    string parent = 1 [
    42      (google.api.resource_reference).child_type = "library.googleapis.com/Book"
    43    ];
    44  
    45    UpdateBookRequest requests = 2;  // Field should be repeated.
    46  }
    47  ```
    48  
    49  **Correct** code for this rule:
    50  
    51  ```proto
    52  // Correct.
    53  message BatchUpdateBooksRequest {
    54    string parent = 1 [
    55      (google.api.resource_reference).child_type = "library.googleapis.com/Book"
    56    ];
    57  
    58    repeated UpdateBookRequest requests = 2;
    59  }
    60  ```
    61  
    62  ## Disabling
    63  
    64  If you need to violate this rule, use a leading comment above the message (if
    65  the `requests` field is missing) or above the field (if it is the wrong type).
    66  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    67  
    68  ```proto
    69  // (-- api-linter: core::0234::request-requests-field=disabled
    70  //     aip.dev/not-precedent: We need to do this because reasons. --)
    71  message BatchUpdateBooksRequest {
    72    string parent = 1 [
    73      (google.api.resource_reference).child_type = "library.googleapis.com/Book"
    74    ];
    75  
    76    repeated string books = 2; // should be "repeated UpdateBookRequest requests"
    77  }
    78  ```
    79  
    80  If you need to violate this rule for an entire file, place the comment at the
    81  top of the file.
    82  
    83  [aip-234]: https://aip.dev/234
    84  [aip.dev/not-precedent]: https://aip.dev/not-precedent