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

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