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

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