github.com/googleapis/api-linter@v1.65.2/docs/rules/0165/request-parent-field.md (about) 1 --- 2 rule: 3 aip: 165 4 name: [core, '0165', request-parent-field] 5 summary: Purge RPCs must have a `parent` field in the request. 6 permalink: /165/request-parent-field 7 redirect_from: 8 - /0165/request-parent-field 9 --- 10 11 # Purge requests: Parent field 12 13 This rule enforces that all `Purge` methods have a `string parent` 14 field in the request message, as mandated in [AIP-165][], unless the resource is 15 top-level. 16 17 ## Details 18 19 This rule looks at any message matching `Purge*Request` and complains if 20 either the `parent` field is missing, or if it has any type other than `string`. 21 22 This rule is skipped for top-level resources, since they have no parent. 23 24 ## Examples 25 26 **Incorrect** code for this rule: 27 28 ```proto 29 // Incorrect. 30 // Should include a `string parent` field. 31 message PurgeBooksRequest { 32 string filter = 2 [(google.api.field_behavior) = REQUIRED]; 33 34 bool force = 3; 35 } 36 ``` 37 38 ```proto 39 // Incorrect. 40 message PurgeBooksRequest { 41 // Field type should be `string`. 42 bytes parent = 1 [ 43 (google.api.field_behavior) = REQUIRED, 44 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 45 ]; 46 47 string filter = 2 [(google.api.field_behavior) = REQUIRED]; 48 49 bool force = 3; 50 } 51 ``` 52 53 **Correct** code for this rule: 54 55 ```proto 56 // Correct. 57 message PurgeBooksRequest { 58 string parent = 1 [ 59 (google.api.field_behavior) = REQUIRED, 60 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 61 ]; 62 63 string filter = 2 [(google.api.field_behavior) = REQUIRED]; 64 65 bool force = 3; 66 } 67 ``` 68 69 ## Disabling 70 71 If you need to violate this rule, use a leading comment above the message (if 72 the `parent` field is missing) or above the field (if it is the wrong type). 73 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 74 75 ```proto 76 message PurgeBooksRequest { 77 // (-- api-linter: core::0165::request-parent-field=disabled 78 // aip.dev/not-precedent: We need to do this because reasons. --) 79 bytes parent = 1 [ 80 (google.api.field_behavior) = REQUIRED, 81 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 82 ]; 83 84 string filter = 2 [(google.api.field_behavior) = REQUIRED]; 85 86 bool force = 3; 87 } 88 ``` 89 90 If you need to violate this rule for an entire file, place the comment at the 91 top of the file. 92 93 [aip-165]: https://aip.dev/165 94 [aip.dev/not-precedent]: https://aip.dev/not-precedent