github.com/googleapis/api-linter@v1.65.2/docs/rules/0162/tag-revision-request-name-reference.md (about)

     1  ---
     2  rule:
     3    aip: 162
     4    name: [core, '0162', tag-revision-request-name-reference]
     5    summary: |
     6      Tag Revision requests should annotate the `name` field with `google.api.resource_reference`.
     7  permalink: /162/tag-revision-request-name-reference
     8  redirect_from:
     9    - /0162/tag-revision-request-name-reference
    10  ---
    11  
    12  # Tag Revision requests: Name resource reference
    13  
    14  This rule enforces that all Tag Revision requests have
    15  `google.api.resource_reference` on their `string name` field, as mandated in
    16  [AIP-162][].
    17  
    18  ## Details
    19  
    20  This rule looks at the `name` field of any message matching `Tag*RevisionRequest`
    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 TagBookRevisionRequest {
    30    // The `google.api.resource_reference` annotation should also be included.
    31    string name = 1 [(google.api.field_behavior) = REQUIRED];
    32  
    33    string tag = 2 [(google.api.field_behavior) = REQUIRED];
    34  }
    35  ```
    36  
    37  **Correct** code for this rule:
    38  
    39  ```proto
    40  // Correct.
    41  message TagBookRevisionRequest {
    42    string name = 1 [
    43      (google.api.field_behavior) = REQUIRED,
    44      (google.api.resource_reference).type = "library.googleapis.com/Book"
    45    ];
    46  
    47    string tag = 2 [(google.api.field_behavior) = REQUIRED];
    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  message TagBookRevisionRequest {
    58    // (-- api-linter: core::0162::tag-revision-request-name-reference=disabled
    59    //     aip.dev/not-precedent: We need to do this because reasons. --)
    60    string name = 1 [(google.api.field_behavior) = REQUIRED];
    61  
    62    string tag = 2 [(google.api.field_behavior) = REQUIRED];
    63  }
    64  ```
    65  
    66  If you need to violate this rule for an entire file, place the comment at the
    67  top of the file.
    68  
    69  [aip-162]: https://aip.dev/162
    70  [aip.dev/not-precedent]: https://aip.dev/not-precedent