github.com/googleapis/api-linter@v1.65.2/docs/rules/0135/force-field.md (about)

     1  ---
     2  rule:
     3    aip: 135
     4    name: [core, '0135', force-field]
     5    summary: Delete RPCs for resources with child collections should have a `force` field in the request.
     6  permalink: /135/force-field
     7  redirect_from:
     8    - /0135/force-field
     9  ---
    10  
    11  # Delete methods: `force` field
    12  
    13  This rule enforces that the standard `Delete` method for a resource that parents
    14  other resources in the service have a `bool force` field in the request message,
    15  as mandated in [AIP-135][].
    16  
    17  ## Details
    18  
    19  This rule looks at any message matching `Delete*Request` for a resource with
    20  child resources in the same service and complains if the `force` field is
    21  missing.
    22  
    23  ## Examples
    24  
    25  **Incorrect** code for this rule:
    26  
    27  ```proto
    28  // Incorrect.
    29  message DeletePublisherRequest {
    30    // Where Publisher parents the Book resource.
    31    string name = 1 [
    32      (google.api.resource_reference).type = "library.googleapis.com/Publisher"]; 
    33  
    34    // Missing `bool force` field.
    35  }
    36  ```
    37  
    38  **Correct** code for this rule:
    39  
    40  ```proto
    41  // Correct.
    42  message DeletePublisherRequest {
    43    // Where Publisher parents the Book resource.
    44    string name = 1 [
    45      (google.api.resource_reference).type = "library.googleapis.com/Publisher"]; 
    46  
    47    // If set to true, any books from this publisher will also be deleted.
    48    // (Otherwise, the request will only work if the publisher has no books.)
    49    bool force = 2;
    50  }
    51  ```
    52  
    53  ## Disabling
    54  
    55  If you need to violate this rule, use a leading comment above the message (if
    56  the `name` field is missing) or above the field (if it is the wrong type).
    57  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    58  
    59  ```proto
    60  // (-- api-linter: core::0135::force-field=disabled
    61  //     aip.dev/not-precedent: We need to do this because reasons. --)
    62  message DeletePublisherRequest {
    63    // Where Publisher parents the Book resource.
    64    string name = 1 [
    65      (google.api.resource_reference).type = "library.googleapis.com/Publisher"]; 
    66  }
    67  ```
    68  
    69  If you need to violate this rule for an entire file, place the comment at the
    70  top of the file.
    71  
    72  [aip-135]: https://aip.dev/135#cascading-delete
    73  [aip.dev/not-precedent]: https://aip.dev/not-precedent