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

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