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

     1  ---
     2  rule:
     3    aip: 235
     4    name: [core, '0235', request-parent-field]
     5    summary: Batch Delete RPCs must have a `parent` field in the request.
     6  permalink: /235/request-parent-field
     7  redirect_from:
     8    - /0235/request-parent-field
     9  ---
    10  
    11  # Batch Delete methods: Parent field
    12  
    13  This rule enforces that all `BatchDelete` methods have a `string parent` field in
    14  the request message, as mandated in [AIP-235][].
    15  
    16  ## Details
    17  
    18  This rule looks at any message matching `BatchDelete*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 BatchDeleteBooksRequest {
    29    string publisher = 1;  // Field name should be `parent`.
    30  
    31    repeated string names = 2 [
    32      (google.api.field_behavior) = REQUIRED,
    33      (google.api.resource_reference).type = "library.googleapis.com/Book"
    34    ];
    35  }
    36  ```
    37  
    38  ```proto
    39  // Incorrect.
    40  message BatchDeleteBooksRequest {
    41    bytes parent = 1;  // Field type should be `string`.
    42  
    43    repeated string names = 2 [
    44      (google.api.field_behavior) = REQUIRED,
    45      (google.api.resource_reference).type = "library.googleapis.com/Book"
    46    ];
    47  }
    48  ```
    49  
    50  **Correct** code for this rule:
    51  
    52  ```proto
    53  // Correct.
    54  message BatchDeleteBooksRequest {
    55    string parent = 1 [
    56      (google.api.resource_reference).child_type = "library.googleapis.com/Book"
    57    ];
    58  
    59    repeated string names = 2 [
    60      (google.api.field_behavior) = REQUIRED,
    61      (google.api.resource_reference).type = "library.googleapis.com/Book"
    62    ];
    63  }
    64  ```
    65  
    66  ## Disabling
    67  
    68  If you need to violate this rule, use a leading comment above the message (if
    69  the `parent` field is missing) or above the field (if it is the wrong type).
    70  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    71  
    72  ```proto
    73  // (-- api-linter: core::0235::request-parent-field=disabled
    74  //     aip.dev/not-precedent: We need to do this because reasons. --)
    75  message BatchDeleteBooksRequest {
    76    string publisher = 1;  // Field name should be `parent`.
    77  
    78    repeated string names = 2 [
    79      (google.api.field_behavior) = REQUIRED,
    80      (google.api.resource_reference).type = "library.googleapis.com/Book"
    81    ];
    82  }
    83  ```
    84  
    85  If you need to violate this rule for an entire file, place the comment at the
    86  top of the file.
    87  
    88  [aip-235]: https://aip.dev/235
    89  [aip.dev/not-precedent]: https://aip.dev/not-precedent