Repository: googleapis/api-linter
Pull request #643 (2020-10-05 20:52:52)

Add rules for batch-method parent resource reference
Part of #612.


Patch:
diff --git a/docs/rules/0231/request-names-field.md b/docs/rules/0231/request-names-field.md
index 50652da..46e6737 100644
--- a/docs/rules/0231/request-names-field.md
+++ b/docs/rules/0231/request-names-field.md
@@ -29,7 +29,10 @@ accepted in its place.
 ```proto
 // Incorrect.
 message BatchGetBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated string books = 2;  // Field name should be `names`.
 }
 ```
@@ -37,7 +40,10 @@ message BatchGetBooksRequest {
 ```proto
 // Incorrect.
 message BatchGetBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   string names = 2;  // Field should be repeated.
 }
 ```
@@ -47,8 +53,14 @@ message BatchGetBooksRequest {
 ```proto
 // Correct.
 message BatchGetBooksRequest {
-  string parent = 1;
-  repeated string names = 2;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
diff --git a/docs/rules/0231/request-names-reference.md b/docs/rules/0231/request-names-reference.md
index 81ac7cc..6fec975 100644
--- a/docs/rules/0231/request-names-reference.md
+++ b/docs/rules/0231/request-names-reference.md
@@ -27,8 +27,12 @@ complains if it does not have a `google.api.resource_reference` annotation.
 ```proto
 // Incorrect.
 message BatchGetBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   // The `google.api.resource_reference` annotation should also be included.
-  repeated string names = 1 [(google.api.field_behavior) = REQUIRED];
+  repeated string names = 2 [(google.api.field_behavior) = REQUIRED];
 }
 ```
 
@@ -37,7 +41,11 @@ message BatchGetBooksRequest {
 ```proto
 // Correct.
 message BatchGetBooksRequest {
-  repeated string names = 1 [
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated string names = 2 [
     (google.api.field_behavior) = REQUIRED,
     (google.api.resource_reference).type = "library.googleapis.com/Book"
   ];
@@ -51,9 +59,13 @@ Remember to also include an [aip.dev/not-precedent][] comment explaining why.
 
 ```proto
 message BatchGetBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   // (-- api-linter: core::0231::request-names-reference=disabled
   //     aip.dev/not-precedent: We need to do this because reasons. --)
-  repeated string names = 1 [(google.api.field_behavior) = REQUIRED];
+  repeated string names = 2 [(google.api.field_behavior) = REQUIRED];
 }
 ```
 
diff --git a/docs/rules/0231/request-parent-field.md b/docs/rules/0231/request-parent-field.md
index d918003..b7315be 100644
--- a/docs/rules/0231/request-parent-field.md
+++ b/docs/rules/0231/request-parent-field.md
@@ -27,7 +27,11 @@ either the `parent` field is missing, or if it has any type other than
 // Incorrect.
 message BatchGetBooksRequest {
   string publisher = 1;  // Field name should be `parent`.
-  repeated string names = 2;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
@@ -35,7 +39,11 @@ message BatchGetBooksRequest {
 // Incorrect.
 message BatchGetBooksRequest {
   bytes parent = 1;  // Field type should be `string`.
-  repeated string names = 2;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
@@ -44,8 +52,14 @@ message BatchGetBooksRequest {
 ```proto
 // Correct.
 message BatchGetBooksRequest {
-  string parent = 1;
-  repeated string names = 2;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
@@ -60,7 +74,11 @@ Remember to also include an [aip.dev/not-precedent][] comment explaining why.
 //     aip.dev/not-precedent: We need to do this because reasons. --)
 message BatchGetBooksRequest {
   string publisher = 1;  // Field name should be `parent`.
-  repeated string names = 2;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
diff --git a/docs/rules/0231/request-parent-reference.md b/docs/rules/0231/request-parent-reference.md
new file mode 100644
index 0000000..d121257
--- /dev/null
+++ b/docs/rules/0231/request-parent-reference.md
@@ -0,0 +1,78 @@
+---
+rule:
+  aip: 231
+  name: [core, '0231', request-parent-reference]
+  summary: |
+    Batch Get requests should annotate the `parent` field with `google.api.resource_reference`.
+permalink: /231/request-parent-reference
+redirect_from:
+  - /0231/request-parent-reference
+---
+
+# Batch Get methods: Parent resource reference
+
+This rule enforces that all `BatchGet` requests have
+`google.api.resource_reference` on their `string parent` field, as mandated in
+[AIP-231][].
+
+## Details
+
+This rule looks at the `parent` field of any message matching `BatchGet*Request` and
+complains if it does not have a `google.api.resource_reference` annotation.
+
+## Examples
+
+**Incorrect** code for this rule:
+
+```proto
+// Incorrect.
+message BatchGetBooksRequest {
+  // The `google.api.resource_reference` annotation should also be included.
+  string parent = 1;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
+}
+```
+
+**Correct** code for this rule:
+
+```proto
+// Correct.
+message BatchGetBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
+}
+```
+
+## Disabling
+
+If you need to violate this rule, use a leading comment above the field.
+Remember to also include an [aip.dev/not-precedent][] comment explaining why.
+
+```proto
+message BatchGetBooksRequest {
+  // (-- api-linter: core::0231::request-parent-reference=disabled
+  //     aip.dev/not-precedent: We need to do this because reasons. --)
+  string parent = 1;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
+}
+```
+
+If you need to violate this rule for an entire file, place the comment at the
+top of the file.
+
+[aip-231]: https://aip.dev/231
+[aip.dev/not-precedent]: https://aip.dev/not-precedent
diff --git a/docs/rules/0233/request-parent-field.md b/docs/rules/0233/request-parent-field.md
index 84b7bf3..7ab0f40 100644
--- a/docs/rules/0233/request-parent-field.md
+++ b/docs/rules/0233/request-parent-field.md
@@ -44,7 +44,10 @@ message BatchCreateBooksRequest {
 ```proto
 // Correct.
 message BatchCreateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated CreateBookRequest requests = 2;
 }
 ```
diff --git a/docs/rules/0233/request-parent-reference.md b/docs/rules/0233/request-parent-reference.md
new file mode 100644
index 0000000..ff1fbd4
--- /dev/null
+++ b/docs/rules/0233/request-parent-reference.md
@@ -0,0 +1,69 @@
+---
+rule:
+  aip: 233
+  name: [core, '0233', request-parent-reference]
+  summary: |
+    Batch Create requests should annotate the `parent` field with `google.api.resource_reference`.
+permalink: /233/request-parent-reference
+redirect_from:
+  - /0233/request-parent-reference
+---
+
+# Batch Create methods: Parent resource reference
+
+This rule enforces that all `BatchCreate` requests have
+`google.api.resource_reference` on their `string parent` field, as mandated in
+[AIP-233][].
+
+## Details
+
+This rule looks at the `parent` field of any message matching `BatchCreate*Request` and
+complains if it does not have a `google.api.resource_reference` annotation.
+
+## Examples
+
+**Incorrect** code for this rule:
+
+```proto
+// Incorrect.
+message BatchCreateBooksRequest {
+  // The `google.api.resource_reference` annotation should also be included.
+  string parent = 1;
+
+  repeated CreateBookRequest requests = 2;
+}
+```
+
+**Correct** code for this rule:
+
+```proto
+// Correct.
+message BatchCreateBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated CreateBookRequest requests = 2;
+}
+```
+
+## Disabling
+
+If you need to violate this rule, use a leading comment above the field.
+Remember to also include an [aip.dev/not-precedent][] comment explaining why.
+
+```proto
+message BatchCreateBooksRequest {
+  // (-- api-linter: core::0233::request-parent-reference=disabled
+  //     aip.dev/not-precedent: We need to do this because reasons. --)
+  string parent = 1;
+
+  repeated CreateBookRequest requests = 2;
+}
+```
+
+If you need to violate this rule for an entire file, place the comment at the
+top of the file.
+
+[aip-233]: https://aip.dev/233
+[aip.dev/not-precedent]: https://aip.dev/not-precedent
diff --git a/docs/rules/0233/request-requests-field.md b/docs/rules/0233/request-requests-field.md
index 9487049..861d023 100644
--- a/docs/rules/0233/request-requests-field.md
+++ b/docs/rules/0233/request-requests-field.md
@@ -27,7 +27,10 @@ or if it is not `repeated`.
 ```proto
 // Incorrect.
 message BatchCreateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated CreateBookRequest req = 2;  // Field name should be `requests`.
 }
 ```
@@ -35,7 +38,10 @@ message BatchCreateBooksRequest {
 ```proto
 // Incorrect.
 message BatchCreateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   CreateBookRequest requests = 2;  // Field should be repeated.
 }
 ```
@@ -45,7 +51,10 @@ message BatchCreateBooksRequest {
 ```proto
 // Correct.
 message BatchCreateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated CreateBookRequest requests = 2;
 }
 ```
@@ -60,7 +69,10 @@ Remember to also include an [aip.dev/not-precedent][] comment explaining why.
 // (-- api-linter: core::0233::request-requests-field=disabled
 //     aip.dev/not-precedent: We need to do this because reasons. --)
 message BatchCreateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated string books = 2; // should be "repeated CreateBookRequest requests"
 }
 ```
diff --git a/docs/rules/0234/request-parent-field.md b/docs/rules/0234/request-parent-field.md
index 041a97d..9dd9cc9 100644
--- a/docs/rules/0234/request-parent-field.md
+++ b/docs/rules/0234/request-parent-field.md
@@ -44,7 +44,10 @@ message BatchUpdateBooksRequest {
 ```proto
 // Correct.
 message BatchUpdateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated UpdateBookRequest requests = 2;
 }
 ```
diff --git a/docs/rules/0234/request-parent-reference.md b/docs/rules/0234/request-parent-reference.md
new file mode 100644
index 0000000..8ac8bd7
--- /dev/null
+++ b/docs/rules/0234/request-parent-reference.md
@@ -0,0 +1,69 @@
+---
+rule:
+  aip: 234
+  name: [core, '0234', request-parent-reference]
+  summary: |
+    Batch Update requests should annotate the `parent` field with `google.api.resource_reference`.
+permalink: /234/request-parent-reference
+redirect_from:
+  - /0234/request-parent-reference
+---
+
+# Batch Update methods: Parent resource reference
+
+This rule enforces that all `BatchUpdate` requests have
+`google.api.resource_reference` on their `string parent` field, as mandated in
+[AIP-234][].
+
+## Details
+
+This rule looks at the `parent` field of any message matching `BatchUpdate*Request` and
+complains if it does not have a `google.api.resource_reference` annotation.
+
+## Examples
+
+**Incorrect** code for this rule:
+
+```proto
+// Incorrect.
+message BatchUpdateBooksRequest {
+  // The `google.api.resource_reference` annotation should also be included.
+  string parent = 1;
+
+  repeated UpdateBookRequest requests = 2;
+}
+```
+
+**Correct** code for this rule:
+
+```proto
+// Correct.
+message BatchUpdateBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated UpdateBookRequest requests = 2;
+}
+```
+
+## Disabling
+
+If you need to violate this rule, use a leading comment above the field.
+Remember to also include an [aip.dev/not-precedent][] comment explaining why.
+
+```proto
+message BatchUpdateBooksRequest {
+  // (-- api-linter: core::0234::request-parent-reference=disabled
+  //     aip.dev/not-precedent: We need to do this because reasons. --)
+  string parent = 1;
+
+  repeated UpdateBookRequest requests = 2;
+}
+```
+
+If you need to violate this rule for an entire file, place the comment at the
+top of the file.
+
+[aip-234]: https://aip.dev/234
+[aip.dev/not-precedent]: https://aip.dev/not-precedent
diff --git a/docs/rules/0234/request-requests-field.md b/docs/rules/0234/request-requests-field.md
index 90dacaf..239cc7e 100644
--- a/docs/rules/0234/request-requests-field.md
+++ b/docs/rules/0234/request-requests-field.md
@@ -27,7 +27,10 @@ or if it is not `repeated`.
 ```proto
 // Incorrect.
 message BatchUpdateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated UpdateBookRequest req = 2;  // Field name should be `requests`.
 }
 ```
@@ -35,7 +38,10 @@ message BatchUpdateBooksRequest {
 ```proto
 // Incorrect.
 message BatchUpdateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   UpdateBookRequest requests = 2;  // Field should be repeated.
 }
 ```
@@ -45,7 +51,10 @@ message BatchUpdateBooksRequest {
 ```proto
 // Correct.
 message BatchUpdateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated UpdateBookRequest requests = 2;
 }
 ```
@@ -60,7 +69,10 @@ Remember to also include an [aip.dev/not-precedent][] comment explaining why.
 // (-- api-linter: core::0234::request-requests-field=disabled
 //     aip.dev/not-precedent: We need to do this because reasons. --)
 message BatchUpdateBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated string books = 2; // should be "repeated UpdateBookRequest requests"
 }
 ```
diff --git a/docs/rules/0235/request-names-behavior.md b/docs/rules/0235/request-names-behavior.md
index 406f01d..a200b2b 100644
--- a/docs/rules/0235/request-names-behavior.md
+++ b/docs/rules/0235/request-names-behavior.md
@@ -28,8 +28,12 @@ value of `REQUIRED`.
 ```proto
 // Incorrect.
 message BatchDeleteBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   // The `google.api.field_behavior` annotation should also be included.
-  repeated string names = 1 [(google.api.resource_reference) = {
+  repeated string names = 2 [(google.api.resource_reference) = {
     type: "library.googleapis.com/Book"
   }];
 }
@@ -40,7 +44,11 @@ message BatchDeleteBooksRequest {
 ```proto
 // Correct.
 message BatchDeleteBooksRequest {
-  repeated string names = 1 [
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated string names = 2 [
     (google.api.field_behavior) = REQUIRED,
     (google.api.resource_reference).type = "library.googleapis.com/Book"
   ];
@@ -54,9 +62,13 @@ Remember to also include an [aip.dev/not-precedent][] comment explaining why.
 
 ```proto
 message BatchDeleteBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   // (-- api-linter: core::0235::request-names-behavior=disabled
   //     aip.dev/not-precedent: We need to do this because reasons. --)
-  repeated string names = 1 [(google.api.resource_reference) = {
+  repeated string names = 2 [(google.api.resource_reference) = {
     type: "library.googleapis.com/Book"
   }];
 }
diff --git a/docs/rules/0235/request-names-field.md b/docs/rules/0235/request-names-field.md
index c98f02a..f00feca 100644
--- a/docs/rules/0235/request-names-field.md
+++ b/docs/rules/0235/request-names-field.md
@@ -29,7 +29,10 @@ accepted in its place.
 ```proto
 // Incorrect.
 message BatchDeleteBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated string books = 2;  // Field name should be `names`.
 }
 ```
@@ -37,7 +40,10 @@ message BatchDeleteBooksRequest {
 ```proto
 // Incorrect.
 message BatchDeleteBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   string names = 2;  // Field should be repeated.
 }
 ```
@@ -47,8 +53,14 @@ message BatchDeleteBooksRequest {
 ```proto
 // Correct.
 message BatchDeleteBooksRequest {
-  string parent = 1;
-  repeated string names = 2;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
@@ -62,7 +74,10 @@ Remember to also include an [aip.dev/not-precedent][] comment explaining why.
 // (-- api-linter: core::0235::request-names-field=disabled
 //     aip.dev/not-precedent: We need to do this because reasons. --)
 message BatchDeleteBooksRequest {
-  string parent = 1;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   repeated string books = 2;
 }
 ```
diff --git a/docs/rules/0235/request-names-reference.md b/docs/rules/0235/request-names-reference.md
index 56fa34a..9169cd4 100644
--- a/docs/rules/0235/request-names-reference.md
+++ b/docs/rules/0235/request-names-reference.md
@@ -27,8 +27,12 @@ complains if it does not have a `google.api.resource_reference` annotation.
 ```proto
 // Incorrect.
 message BatchDeleteBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   // The `google.api.resource_reference` annotation should also be included.
-  repeated string names = 1 [(google.api.field_behavior) = REQUIRED];
+  repeated string names = 2 [(google.api.field_behavior) = REQUIRED];
 }
 ```
 
@@ -37,7 +41,11 @@ message BatchDeleteBooksRequest {
 ```proto
 // Correct.
 message BatchDeleteBooksRequest {
-  repeated string names = 1 [
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated string names = 2 [
     (google.api.field_behavior) = REQUIRED,
     (google.api.resource_reference).type = "library.googleapis.com/Book"
   ];
@@ -51,9 +59,13 @@ Remember to also include an [aip.dev/not-precedent][] comment explaining why.
 
 ```proto
 message BatchDeleteBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
   // (-- api-linter: core::0235::request-names-reference=disabled
   //     aip.dev/not-precedent: We need to do this because reasons. --)
-  repeated string names = 1 [(google.api.field_behavior) = REQUIRED];
+  repeated string names = 2 [(google.api.field_behavior) = REQUIRED];
 }
 ```
 
diff --git a/docs/rules/0235/request-parent-field.md b/docs/rules/0235/request-parent-field.md
index 4410835..40defc1 100644
--- a/docs/rules/0235/request-parent-field.md
+++ b/docs/rules/0235/request-parent-field.md
@@ -27,7 +27,11 @@ either the `parent` field is missing, or if it has any type other than
 // Incorrect.
 message BatchDeleteBooksRequest {
   string publisher = 1;  // Field name should be `parent`.
-  repeated string names = 2;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
@@ -35,7 +39,11 @@ message BatchDeleteBooksRequest {
 // Incorrect.
 message BatchDeleteBooksRequest {
   bytes parent = 1;  // Field type should be `string`.
-  repeated string names = 2;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
@@ -44,8 +52,14 @@ message BatchDeleteBooksRequest {
 ```proto
 // Correct.
 message BatchDeleteBooksRequest {
-  string parent = 1;
-  repeated string names = 2;
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
@@ -60,7 +74,11 @@ Remember to also include an [aip.dev/not-precedent][] comment explaining why.
 //     aip.dev/not-precedent: We need to do this because reasons. --)
 message BatchDeleteBooksRequest {
   string publisher = 1;  // Field name should be `parent`.
-  repeated string names = 2;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
 }
 ```
 
diff --git a/docs/rules/0235/request-parent-reference.md b/docs/rules/0235/request-parent-reference.md
new file mode 100644
index 0000000..d780c5a
--- /dev/null
+++ b/docs/rules/0235/request-parent-reference.md
@@ -0,0 +1,78 @@
+---
+rule:
+  aip: 235
+  name: [core, '0235', request-parent-reference]
+  summary: |
+    Batch Delete requests should annotate the `parent` field with `google.api.resource_reference`.
+permalink: /235/request-parent-reference
+redirect_from:
+  - /0235/request-parent-reference
+---
+
+# Batch Delete methods: Parent resource reference
+
+This rule enforces that all `BatchDelete` requests have
+`google.api.resource_reference` on their `string parent` field, as mandated in
+[AIP-235][].
+
+## Details
+
+This rule looks at the `parent` field of any message matching `BatchDelete*Request` and
+complains if it does not have a `google.api.resource_reference` annotation.
+
+## Examples
+
+**Incorrect** code for this rule:
+
+```proto
+// Incorrect.
+message BatchDeleteBooksRequest {
+  // The `google.api.resource_reference` annotation should also be included.
+  string parent = 1;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
+}
+```
+
+**Correct** code for this rule:
+
+```proto
+// Correct.
+message BatchDeleteBooksRequest {
+  string parent = 1 [
+    (google.api.resource_reference).child_type = "library.googleapis.com/Book"
+  ];
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
+}
+```
+
+## Disabling
+
+If you need to violate this rule, use a leading comment above the field.
+Remember to also include an [aip.dev/not-precedent][] comment explaining why.
+
+```proto
+message BatchDeleteBooksRequest {
+  // (-- api-linter: core::0235::request-parent-reference=disabled
+  //     aip.dev/not-precedent: We need to do this because reasons. --)
+  string parent = 1;
+
+  repeated string names = 2 [
+    (google.api.field_behavior) = REQUIRED,
+    (google.api.resource_reference).type = "library.googleapis.com/Book"
+  ];
+}
+```
+
+If you need to violate this rule for an entire file, place the comment at the
+top of the file.
+
+[aip-235]: https://aip.dev/235
+[aip.dev/not-precedent]: https://aip.dev/not-precedent
diff --git a/rules/aip0231/aip0231.go b/rules/aip0231/aip0231.go
index 78c1ddd..81c7ec5 100644
--- a/rules/aip0231/aip0231.go
+++ b/rules/aip0231/aip0231.go
@@ -36,6 +36,7 @@ func AddRules(r lint.RuleRegistry) error {
 		requestNamesBehavior,
 		requestNamesReference,
 		requestParentField,
+		requestParentReference,
 		resourceField,
 		uriSuffix,
 	)
diff --git a/rules/aip0231/request_parent_reference.go b/rules/aip0231/request_parent_reference.go
new file mode 100644
index 0000000..79101a6
--- /dev/null
+++ b/rules/aip0231/request_parent_reference.go
@@ -0,0 +1,37 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aip0231
+
+import (
+	"github.com/googleapis/api-linter/lint"
+	"github.com/googleapis/api-linter/rules/internal/utils"
+	"github.com/jhump/protoreflect/desc"
+)
+
+var requestParentReference = &lint.FieldRule{
+	Name: lint.NewRuleName(231, "request-parent-reference"),
+	OnlyIf: func(f *desc.FieldDescriptor) bool {
+		return isBatchGetRequestMessage(f.GetOwner()) && f.GetName() == "parent"
+	},
+	LintField: func(f *desc.FieldDescriptor) []lint.Problem {
+		if ref := utils.GetResourceReference(f); ref == nil {
+			return []lint.Problem{{
+				Message:    "Batch Get methods: The `parent` field should include a `google.api.resource_reference` annotation.",
+				Descriptor: f,
+			}}
+		}
+		return nil
+	},
+}
diff --git a/rules/aip0233/aip0233.go b/rules/aip0233/aip0233.go
index 4e5d651..7fef05f 100644
--- a/rules/aip0233/aip0233.go
+++ b/rules/aip0233/aip0233.go
@@ -34,6 +34,7 @@ func AddRules(r lint.RuleRegistry) error {
 		httpUriSuffix,
 		httpVerb,
 		requestParentField,
+		requestParentReference,
 		requestRequestsBehavior,
 		requestRequestsField,
 		responseResourceField,
diff --git a/rules/aip0233/request_parent_reference.go b/rules/aip0233/request_parent_reference.go
new file mode 100644
index 0000000..d3a016a
--- /dev/null
+++ b/rules/aip0233/request_parent_reference.go
@@ -0,0 +1,37 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aip0233
+
+import (
+	"github.com/googleapis/api-linter/lint"
+	"github.com/googleapis/api-linter/rules/internal/utils"
+	"github.com/jhump/protoreflect/desc"
+)
+
+var requestParentReference = &lint.FieldRule{
+	Name: lint.NewRuleName(233, "request-parent-reference"),
+	OnlyIf: func(f *desc.FieldDescriptor) bool {
+		return isBatchCreateRequestMessage(f.GetOwner()) && f.GetName() == "parent"
+	},
+	LintField: func(f *desc.FieldDescriptor) []lint.Problem {
+		if ref := utils.GetResourceReference(f); ref == nil {
+			return []lint.Problem{{
+				Message:    "Batch Create methods: The `parent` field should include a `google.api.resource_reference` annotation.",
+				Descriptor: f,
+			}}
+		}
+		return nil
+	},
+}
diff --git a/rules/aip0234/aip0234.go b/rules/aip0234/aip0234.go
index f3f6d8e..ec93ff6 100644
--- a/rules/aip0234/aip0234.go
+++ b/rules/aip0234/aip0234.go
@@ -33,6 +33,7 @@ func AddRules(r lint.RuleRegistry) error {
 		pluralMethodName,
 		requestMessageName,
 		requestParentField,
+		requestParentReference,
 		requestRequestsBehavior,
 		requestRequestsField,
 		responseMessageName,
diff --git a/rules/aip0234/request_parent_reference.go b/rules/aip0234/request_parent_reference.go
new file mode 100644
index 0000000..9438d1f
--- /dev/null
+++ b/rules/aip0234/request_parent_reference.go
@@ -0,0 +1,37 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aip0234
+
+import (
+	"github.com/googleapis/api-linter/lint"
+	"github.com/googleapis/api-linter/rules/internal/utils"
+	"github.com/jhump/protoreflect/desc"
+)
+
+var requestParentReference = &lint.FieldRule{
+	Name: lint.NewRuleName(234, "request-parent-reference"),
+	OnlyIf: func(f *desc.FieldDescriptor) bool {
+		return isBatchUpdateRequestMessage(f.GetOwner()) && f.GetName() == "parent"
+	},
+	LintField: func(f *desc.FieldDescriptor) []lint.Problem {
+		if ref := utils.GetResourceReference(f); ref == nil {
+			return []lint.Problem{{
+				Message:    "Batch Update methods: The `parent` field should include a `google.api.resource_reference` annotation.",
+				Descriptor: f,
+			}}
+		}
+		return nil
+	},
+}
diff --git a/rules/aip0235/aip0235.go b/rules/aip0235/aip0235.go
index b4f4037..d80f2a0 100644
--- a/rules/aip0235/aip0235.go
+++ b/rules/aip0235/aip0235.go
@@ -36,6 +36,7 @@ func AddRules(r lint.RuleRegistry) error {
 		requestNamesField,
 		requestNamesReference,
 		requestParentField,
+		requestParentReference,
 		requestRequestsBehavior,
 	)
 }
diff --git a/rules/aip0235/request_parent_reference.go b/rules/aip0235/request_parent_reference.go
new file mode 100644
index 0000000..105464c
--- /dev/null
+++ b/rules/aip0235/request_parent_reference.go
@@ -0,0 +1,37 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aip0235
+
+import (
+	"github.com/googleapis/api-linter/lint"
+	"github.com/googleapis/api-linter/rules/internal/utils"
+	"github.com/jhump/protoreflect/desc"
+)
+
+var requestParentReference = &lint.FieldRule{
+	Name: lint.NewRuleName(235, "request-parent-reference"),
+	OnlyIf: func(f *desc.FieldDescriptor) bool {
+		return isBatchDeleteRequestMessage(f.GetOwner()) && f.GetName() == "parent"
+	},
+	LintField: func(f *desc.FieldDescriptor) []lint.Problem {
+		if ref := utils.GetResourceReference(f); ref == nil {
+			return []lint.Problem{{
+				Message:    "Batch Delete methods: The `parent` field should include a `google.api.resource_reference` annotation.",
+				Descriptor: f,
+			}}
+		}
+		return nil
+	},
+}


Test patch:
diff --git a/rules/aip0231/request_parent_reference_test.go b/rules/aip0231/request_parent_reference_test.go
new file mode 100644
index 0000000..b860f93
--- /dev/null
+++ b/rules/aip0231/request_parent_reference_test.go
@@ -0,0 +1,49 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aip0231
+
+import (
+	"testing"
+
+	"github.com/googleapis/api-linter/rules/internal/testutils"
+)
+
+func TestRequestParentReference(t *testing.T) {
+	for _, test := range []struct {
+		name        string
+		MessageName string
+		FieldName   string
+		FieldOpts   string
+		problems    testutils.Problems
+	}{
+		{"Valid", "BatchGetBooks", "parent", ` [(google.api.resource_reference) = { type: "foo" }]`, testutils.Problems{}},
+		{"Missing", "BatchGetBooks", "parent", "", testutils.Problems{{Message: "google.api.resource_reference"}}},
+		{"IrrelevantMessage", "GetBooks", "parent", "", testutils.Problems{}},
+		{"IrrelevantField", "BatchGetBooks", "names", "", testutils.Problems{}},
+	} {
+		t.Run(test.name, func(t *testing.T) {
+			f := testutils.ParseProto3Tmpl(t, `
+				import "google/api/resource.proto";
+				message {{.MessageName}}Request {
+					repeated string {{.FieldName}} = 1{{.FieldOpts}};
+				}
+			`, test)
+			field := f.GetMessageTypes()[0].GetFields()[0]
+			if diff := test.problems.SetDescriptor(field).Diff(requestParentReference.Lint(f)); diff != "" {
+				t.Errorf(diff)
+			}
+		})
+	}
+}
diff --git a/rules/aip0233/request_parent_reference_test.go b/rules/aip0233/request_parent_reference_test.go
new file mode 100644
index 0000000..7a6bcdf
--- /dev/null
+++ b/rules/aip0233/request_parent_reference_test.go
@@ -0,0 +1,49 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aip0233
+
+import (
+	"testing"
+
+	"github.com/googleapis/api-linter/rules/internal/testutils"
+)
+
+func TestRequestParentReference(t *testing.T) {
+	for _, test := range []struct {
+		name        string
+		MessageName string
+		FieldName   string
+		FieldOpts   string
+		problems    testutils.Problems
+	}{
+		{"Valid", "BatchCreateBooks", "parent", ` [(google.api.resource_reference) = { type: "foo" }]`, testutils.Problems{}},
+		{"Missing", "BatchCreateBooks", "parent", "", testutils.Problems{{Message: "google.api.resource_reference"}}},
+		{"IrrelevantMessage", "CreateBooks", "parent", "", testutils.Problems{}},
+		{"IrrelevantField", "BatchCreateBooks", "names", "", testutils.Problems{}},
+	} {
+		t.Run(test.name, func(t *testing.T) {
+			f := testutils.ParseProto3Tmpl(t, `
+				import "google/api/resource.proto";
+				message {{.MessageName}}Request {
+					repeated string {{.FieldName}} = 1{{.FieldOpts}};
+				}
+			`, test)
+			field := f.GetMessageTypes()[0].GetFields()[0]
+			if diff := test.problems.SetDescriptor(field).Diff(requestParentReference.Lint(f)); diff != "" {
+				t.Errorf(diff)
+			}
+		})
+	}
+}
diff --git a/rules/aip0234/request_parent_reference_test.go b/rules/aip0234/request_parent_reference_test.go
new file mode 100644
index 0000000..4cb3796
--- /dev/null
+++ b/rules/aip0234/request_parent_reference_test.go
@@ -0,0 +1,49 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aip0234
+
+import (
+	"testing"
+
+	"github.com/googleapis/api-linter/rules/internal/testutils"
+)
+
+func TestRequestParentReference(t *testing.T) {
+	for _, test := range []struct {
+		name        string
+		MessageName string
+		FieldName   string
+		FieldOpts   string
+		problems    testutils.Problems
+	}{
+		{"Valid", "BatchUpdateBooks", "parent", ` [(google.api.resource_reference) = { type: "foo" }]`, testutils.Problems{}},
+		{"Missing", "BatchUpdateBooks", "parent", "", testutils.Problems{{Message: "google.api.resource_reference"}}},
+		{"IrrelevantMessage", "UpdateBooks", "parent", "", testutils.Problems{}},
+		{"IrrelevantField", "BatchUpdateBooks", "names", "", testutils.Problems{}},
+	} {
+		t.Run(test.name, func(t *testing.T) {
+			f := testutils.ParseProto3Tmpl(t, `
+				import "google/api/resource.proto";
+				message {{.MessageName}}Request {
+					repeated string {{.FieldName}} = 1{{.FieldOpts}};
+				}
+			`, test)
+			field := f.GetMessageTypes()[0].GetFields()[0]
+			if diff := test.problems.SetDescriptor(field).Diff(requestParentReference.Lint(f)); diff != "" {
+				t.Errorf(diff)
+			}
+		})
+	}
+}
diff --git a/rules/aip0235/request_parent_reference_test.go b/rules/aip0235/request_parent_reference_test.go
new file mode 100644
index 0000000..bdcb3fc
--- /dev/null
+++ b/rules/aip0235/request_parent_reference_test.go
@@ -0,0 +1,49 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aip0235
+
+import (
+	"testing"
+
+	"github.com/googleapis/api-linter/rules/internal/testutils"
+)
+
+func TestRequestParentReference(t *testing.T) {
+	for _, test := range []struct {
+		name        string
+		MessageName string
+		FieldName   string
+		FieldOpts   string
+		problems    testutils.Problems
+	}{
+		{"Valid", "BatchDeleteBooks", "parent", ` [(google.api.resource_reference) = { type: "foo" }]`, testutils.Problems{}},
+		{"Missing", "BatchDeleteBooks", "parent", "", testutils.Problems{{Message: "google.api.resource_reference"}}},
+		{"IrrelevantMessage", "DeleteBooks", "parent", "", testutils.Problems{}},
+		{"IrrelevantField", "BatchDeleteBooks", "names", "", testutils.Problems{}},
+	} {
+		t.Run(test.name, func(t *testing.T) {
+			f := testutils.ParseProto3Tmpl(t, `
+				import "google/api/resource.proto";
+				message {{.MessageName}}Request {
+					repeated string {{.FieldName}} = 1{{.FieldOpts}};
+				}
+			`, test)
+			field := f.GetMessageTypes()[0].GetFields()[0]
+			if diff := test.problems.SetDescriptor(field).Diff(requestParentReference.Lint(f)); diff != "" {
+				t.Errorf(diff)
+			}
+		})
+	}
+}