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

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