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

     1  ---
     2  rule:
     3    aip: 132
     4    name: [core, '0132', request-parent-reference]
     5    summary: |
     6      List RPCs should annotate the `parent` field with `google.api.resource_reference`.
     7  permalink: /132/request-parent-reference
     8  redirect_from:
     9    - /0132/request-parent-reference
    10  ---
    11  
    12  # List methods: Resource reference
    13  
    14  This rule enforces that all `List` standard methods have
    15  `google.api.resource_reference` on their `string parent` field, as mandated in
    16  [AIP-132][].
    17  
    18  ## Details
    19  
    20  This rule looks at the `parent` field of any message matching `List*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 ListBooksRequest {
    30    // The `google.api.resource_reference` annotation should also be included.
    31    string parent = 1 [(google.api.field_behavior) = REQUIRED];
    32    int32 page_size = 2;
    33    string page_token = 3;
    34  }
    35  ```
    36  
    37  **Correct** code for this rule:
    38  
    39  ```proto
    40  // Correct.
    41  message ListBooksRequest {
    42    string parent = 1 [
    43      (google.api.field_behavior) = REQUIRED,
    44      (google.api.resource_reference).type = "library.googleapis.com/Publisher"
    45    ];
    46    int32 page_size = 2;
    47    string page_token = 3;
    48  }
    49  ```
    50  
    51  ## Disabling
    52  
    53  If you need to violate this rule, use a leading comment above the field.
    54  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    55  
    56  ```proto
    57  // (-- api-linter: core::0132::request-parent-reference=disabled
    58  //     aip.dev/not-precedent: We need to do this because reasons. --)
    59  message ListBooksRequest {
    60    string parent = 1 [(google.api.field_behavior) = REQUIRED];
    61  }
    62  ```
    63  
    64  If you need to violate this rule for an entire file, place the comment at the
    65  top of the file.
    66  
    67  [aip-132]: https://aip.dev/132
    68  [aip.dev/not-precedent]: https://aip.dev/not-precedent