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

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