github.com/googleapis/api-linter@v1.65.2/docs/rules/0162/rollback-request-revision-id-behavior.md (about)

     1  ---
     2  rule:
     3    aip: 162
     4    name: [core, '0162', rollback-request-revision-id-behavior]
     5    summary: |
     6      Rollback requests should annotate the `revision_id` field with `google.api.field_behavior`.
     7  permalink: /162/rollback-request-revision-id-behavior
     8  redirect_from:
     9    - /0162/rollback-request-revision-id-behavior
    10  ---
    11  
    12  # Rollback requests: Revision ID field behavior
    13  
    14  This rule enforces that all `Rollback` requests have
    15  `google.api.field_behavior` set to `REQUIRED` on their `string revision_id` field, as
    16  mandated in [AIP-162][].
    17  
    18  ## Details
    19  
    20  This rule looks at any message matching `Rollback*Request` and complains if the
    21  `revision_id` field does not have a `google.api.field_behavior` annotation with a
    22  value of `REQUIRED`.
    23  
    24  ## Examples
    25  
    26  **Incorrect** code for this rule:
    27  
    28  ```proto
    29  // Incorrect.
    30  message RollbackBookRequest {
    31    string name = 1 [
    32      (google.api.field_behavior) = REQUIRED,
    33      (google.api.resource_reference).type = "library.googleapis.com/Book"
    34    ];
    35  
    36    // The `google.api.field_behavior` annotation should be included.
    37    string revision_id = 2;
    38  }
    39  ```
    40  
    41  **Correct** code for this rule:
    42  
    43  ```proto
    44  // Correct.
    45  message RollbackBookRequest {
    46    string name = 1 [
    47      (google.api.field_behavior) = REQUIRED,
    48      (google.api.resource_reference).type = "library.googleapis.com/Book"
    49    ];
    50  
    51    string revision_id = 2 [(google.api.field_behavior) = REQUIRED];
    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 RollbackBookRequest {
    62    string name = 1 [
    63      (google.api.field_behavior) = REQUIRED,
    64      (google.api.resource_reference).type = "library.googleapis.com/Book"
    65    ];
    66  
    67    // (-- api-linter: core::0162::rollback-request-revision-id-behavior=disabled
    68    //     aip.dev/not-precedent: We need to do this because reasons. --)
    69    string revision_id = 2;
    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-162]: https://aip.dev/162
    77  [aip.dev/not-precedent]: https://aip.dev/not-precedent