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

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