diff --git a/docs/rules/0004/resource-reference-type.md b/docs/rules/0004/resource-reference-type.md index ab81740..d0629e3 100644 --- a/docs/rules/0004/resource-reference-type.md +++ b/docs/rules/0004/resource-reference-type.md @@ -10,12 +10,12 @@ redirect_from: # Resource annotation presence -This rule enforces that any field with a `google.api.resource_reference` +This rule enforces that any field with a `(aep.api.field_info).resource_reference` annotation has a `string` type, as described in [AEP-4][]. ## Details -This rule scans all fields with a `google.api.resource_reference` annotation. +This rule scans all fields with a `(aep.api.field_info).resource_reference` annotation. If one is found, the type is checked, and the rule complains if the type is anything other than `string`. @@ -33,7 +33,7 @@ message Book { string path = 1; // This is not a resource reference; the annotation does not belong. - Author author = 2 [(google.api.resource_reference) = { + Author author = 2 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Author" }]; } @@ -55,7 +55,7 @@ message Book { message Book { string path = 1; - string author = 2 [(google.api.resource_reference) = { + string author = 2 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Author" }]; } diff --git a/docs/rules/0121/no-mutable-cycles.md b/docs/rules/0121/no-mutable-cycles.md index 6b00433..91adaa2 100644 --- a/docs/rules/0121/no-mutable-cycles.md +++ b/docs/rules/0121/no-mutable-cycles.md @@ -33,7 +33,7 @@ message Book { // Incorrect. Creates potential reference cycle. string author = 2 [ - (google.api.resource_reference).type = "library.googleapis.com/Author" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Author" ]; } @@ -47,7 +47,7 @@ message Author { // Incorrect. Creates potential reference cycle. string book = 2 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -65,7 +65,7 @@ message Book { // Correct because the other reference is OUTPUT_ONLY. string author = 2 [ - (google.api.resource_reference).type = "library.googleapis.com/Author" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Author" ]; } @@ -79,7 +79,7 @@ message Author { // Correct because an OUTPUT_ONLY reference breaks the mutation cycle. string book = 2 [ - (google.api.resource_reference).type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book", (aep.api.field_behavior) = FIELD_BEHAVIOR_OUTPUT_ONLY ]; } @@ -102,7 +102,7 @@ message Book { // (-- api-linter: core::0121::no-mutable-cycles=disabled // aep.dev/not-precedent: We need to do this because reasons. --) string author = 2 [ - (google.api.resource_reference).type = "library.googleapis.com/Author" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Author" ]; } @@ -117,7 +117,7 @@ message Author { // (-- api-linter: core::0121::no-mutable-cycles=disabled // aep.dev/not-precedent: We need to do this because reasons. --) string book = 2 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0122/resource-reference-type.md b/docs/rules/0122/resource-reference-type.md index 606b4c3..4c0b653 100644 --- a/docs/rules/0122/resource-reference-type.md +++ b/docs/rules/0122/resource-reference-type.md @@ -10,12 +10,12 @@ redirect_from: # Resource reference type -This rule enforces that all fields with the `google.api.resource_reference` +This rule enforces that all fields with the `(aep.api.field_info).resource_reference` annotation are strings, as mandated in [AEP-122][]. ## Details -This rule complains if it sees a field with a `google.api.resource_reference` +This rule complains if it sees a field with a `(aep.api.field_info).resource_reference` that has a type other than `string`. ## Examples @@ -28,7 +28,7 @@ message Book { string path = 1; // Resource references should be strings. - Author author = 2 [(google.api.resource_reference) = { + Author author = 2 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Author" }]; } @@ -41,7 +41,7 @@ message Book { message Book { string path = 1; - string author = 2 [(google.api.resource_reference) = { + string author = 2 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Author" }]; } @@ -69,7 +69,7 @@ message Book { // (-- api-linter: core::0122::resource-reference-type=disabled // aep.dev/not-precedent: We need to do this because reasons. --) - Author author = 2 [(google.api.resource_reference) = { + Author author = 2 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Author" }]; } diff --git a/docs/rules/0124/reference-same-package.md b/docs/rules/0124/reference-same-package.md index 0b8ad09..8c9d820 100644 --- a/docs/rules/0124/reference-same-package.md +++ b/docs/rules/0124/reference-same-package.md @@ -15,7 +15,7 @@ in the same package, as described in [AEP-124][]. ## Details -This rule scans all fields with `google.api.resource_reference` annotations, +This rule scans all fields with `(aep.api.field_info).resource_reference` annotations, and complains if the `type` on them refers to a resource that is defined in a different protobuf package. @@ -46,7 +46,7 @@ message Book { package google.example.libray.v1; // Typo: Different package. message GetBookRequest { - string name = 1 [(google.api.resource_reference) = { + string name = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" // Lint warning: package mismatch. }]; } @@ -70,7 +70,7 @@ message Book { } message GetBookRequest { - string name = 1 [(google.api.resource_reference) = { + string name = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; } @@ -98,7 +98,7 @@ package google.example.library.v1; message GetBookRequest { // (-- api-linter: core::0124::reference-same-package=disabled // aep.dev/not-precedent: We need to do this because reasons. --) - string name = 1 [(google.api.resource_reference) = { + string name = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; } diff --git a/docs/rules/0127/http-template-pattern.md b/docs/rules/0127/http-template-pattern.md index d60ef57..d19432f 100644 --- a/docs/rules/0127/http-template-pattern.md +++ b/docs/rules/0127/http-template-pattern.md @@ -36,7 +36,7 @@ rpc GetBook(GetBookRequest) returns (Book) { } message GetBookRequest { string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } message Book { @@ -61,7 +61,7 @@ rpc GetBook(GetBookRequest) returns (Book) { } message GetBookRequest { string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } message Book { diff --git a/docs/rules/0131/request-path-behavior.md b/docs/rules/0131/request-path-behavior.md index 0e9ec94..7737def 100644 --- a/docs/rules/0131/request-path-behavior.md +++ b/docs/rules/0131/request-path-behavior.md @@ -29,7 +29,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. // Incorrect. message GetBookRequest { // The `aep.api.field_behavior` annotation should also be included. - string path = 1 [(google.api.resource_reference) = { + string path = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; } @@ -42,7 +42,7 @@ message GetBookRequest { message GetBookRequest { string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -56,7 +56,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message GetBookRequest { // (-- api-linter: core::0131::request-path-behavior=disabled // aep.dev/not-precedent: We need to do this because reasons. --) - string path = 1 [(google.api.resource_reference) = { + string path = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; } diff --git a/docs/rules/0131/request-path-reference-type.md b/docs/rules/0131/request-path-reference-type.md index 59b0bc4..34b5703 100644 --- a/docs/rules/0131/request-path-reference-type.md +++ b/docs/rules/0131/request-path-reference-type.md @@ -3,7 +3,7 @@ rule: aep: 131 name: [core, '0131', request-path-reference-type] summary: | - The `google.api.resource_reference` on the `path` field of a Get RPC request + The `(aep.api.field_info).resource_reference` on the `path` field of a Get RPC request message should use `type`, not `child_type`. permalink: /131/request-path-reference-type redirect_from: @@ -12,13 +12,13 @@ redirect_from: # Get methods: Resource reference -This rule enforces that the `google.api.resource_reference` on the `path` field +This rule enforces that the `(aep.api.field_info).resource_reference` on the `path` field of a Get RPC request message uses `type`, not `child_type`, as suggested in [AEP-131][]. ## Details -This rule looks at the `google.api.resource_reference` annotation on the `path` +This rule looks at the `(aep.api.field_info).resource_reference` annotation on the `path` field of any message matching `Get*Request` and complains if it does not use a direct `type` reference. @@ -29,11 +29,11 @@ direct `type` reference. ```proto // Incorrect. message GetBookRequest { - // The `google.api.resource_reference` annotation should be a direct `type` + // The `(aep.api.field_info).resource_reference` annotation should be a direct `type` // reference. string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).child_type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.child_type = "library.googleapis.com/Book" ]; } ``` @@ -45,7 +45,7 @@ message GetBookRequest { message GetBookRequest { string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -61,7 +61,7 @@ message GetBookRequest { // aep.dev/not-precedent: We need to do this because reasons. --) string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).child_type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.child_type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0131/request-path-reference.md b/docs/rules/0131/request-path-reference.md index 779fdd0..9fb0c5d 100644 --- a/docs/rules/0131/request-path-reference.md +++ b/docs/rules/0131/request-path-reference.md @@ -3,7 +3,7 @@ rule: aep: 131 name: [core, '0131', request-path-reference] summary: | - Get RPCs should annotate the `path` field with `google.api.resource_reference`. + Get RPCs should annotate the `path` field with `(aep.api.field_info).resource_reference`. permalink: /131/request-path-reference redirect_from: - /0131/request-path-reference @@ -12,13 +12,13 @@ redirect_from: # Get methods: Resource reference This rule enforces that all `Get` standard methods have -`google.api.resource_reference` on their `string path` field, as mandated in +`(aep.api.field_info).resource_reference` on their `string path` field, as mandated in [AEP-131][]. ## Details This rule looks at the `path` field of any message matching `Get*Request` and -complains if it does not have a `google.api.resource_reference` annotation. +complains if it does not have a `(aep.api.field_info).resource_reference` annotation. ## Examples @@ -27,7 +27,7 @@ complains if it does not have a `google.api.resource_reference` annotation. ```proto // Incorrect. message GetBookRequest { - // The `google.api.resource_reference` annotation should also be included. + // The `(aep.api.field_info).resource_reference` annotation should also be included. string path = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; } ``` @@ -39,7 +39,7 @@ message GetBookRequest { message GetBookRequest { string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0131/request-path-required.md b/docs/rules/0131/request-path-required.md index 757dfb9..6df934c 100644 --- a/docs/rules/0131/request-path-required.md +++ b/docs/rules/0131/request-path-required.md @@ -27,7 +27,7 @@ the `path` field is missing. message GetBookRequest { string book = 1 [ // Field path should be `path`. (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -39,7 +39,7 @@ message GetBookRequest { message GetBookRequest { string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -55,7 +55,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message GetBookRequest { string book = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0131/request-required-fields.md b/docs/rules/0131/request-required-fields.md index 7fb7f54..bca81dc 100644 --- a/docs/rules/0131/request-required-fields.md +++ b/docs/rules/0131/request-required-fields.md @@ -31,7 +31,7 @@ message GetBookRequest { // Format: publishers/{publisher}/books/{book} string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { + (aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; @@ -49,7 +49,7 @@ message GetBookRequest { // Format: publishers/{publisher}/books/{book} string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { + (aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; @@ -68,7 +68,7 @@ message GetBookRequest { // Format: publishers/{publisher}/books/{book} string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { + (aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; diff --git a/docs/rules/0132/request-parent-behavior.md b/docs/rules/0132/request-parent-behavior.md index 4b81ab3..b457158 100644 --- a/docs/rules/0132/request-parent-behavior.md +++ b/docs/rules/0132/request-parent-behavior.md @@ -29,7 +29,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. // Incorrect. message ListBooksRequest { // The `aep.api.field_behavior` annotation should also be included. - string parent = 1 [(google.api.resource_reference) = { + string parent = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Publisher" }]; int32 page_size = 2; @@ -44,7 +44,7 @@ message ListBooksRequest { message ListBooksRequest { string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Publisher" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher" ]; int32 page_size = 2; string page_token = 3; @@ -60,7 +60,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. // (-- api-linter: core::0132::request-parent-behavior=disabled // aep.dev/not-precedent: We need to do this because reasons. --) message ListBooksRequest { - string parent = 1 [(google.api.resource_reference) = { + string parent = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Publisher" }]; int32 page_size = 2; diff --git a/docs/rules/0132/request-parent-reference.md b/docs/rules/0132/request-parent-reference.md index c046e11..8f3ace2 100644 --- a/docs/rules/0132/request-parent-reference.md +++ b/docs/rules/0132/request-parent-reference.md @@ -3,7 +3,7 @@ rule: aep: 132 name: [core, '0132', request-parent-reference] summary: | - List RPCs should annotate the `parent` field with `google.api.resource_reference`. + List RPCs should annotate the `parent` field with `(aep.api.field_info).resource_reference`. permalink: /132/request-parent-reference redirect_from: - /0132/request-parent-reference @@ -12,13 +12,13 @@ redirect_from: # List methods: Resource reference This rule enforces that all `List` standard methods have -`google.api.resource_reference` on their `string parent` field, as mandated in +`(aep.api.field_info).resource_reference` on their `string parent` field, as mandated in [AEP-132][]. ## Details This rule looks at the `parent` field of any message matching `List*Request` -and complains if it does not have a `google.api.resource_reference` annotation. +and complains if it does not have a `(aep.api.field_info).resource_reference` annotation. ## Examples @@ -27,7 +27,7 @@ and complains if it does not have a `google.api.resource_reference` annotation. ```proto // Incorrect. message ListBooksRequest { - // The `google.api.resource_reference` annotation should also be included. + // The `(aep.api.field_info).resource_reference` annotation should also be included. string parent = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; int32 page_size = 2; string page_token = 3; @@ -41,7 +41,7 @@ message ListBooksRequest { message ListBooksRequest { string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Publisher" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher" ]; int32 page_size = 2; string page_token = 3; diff --git a/docs/rules/0132/request-parent-valid-reference.md b/docs/rules/0132/request-parent-valid-reference.md index b20339c..de5c147 100644 --- a/docs/rules/0132/request-parent-valid-reference.md +++ b/docs/rules/0132/request-parent-valid-reference.md @@ -13,13 +13,13 @@ redirect_from: # List methods: Resource reference This rule enforces that all `List` standard methods reference a resource other -than the resource being listed with the `google.api.resource_reference` on +than the resource being listed with the `(aep.api.field_info).resource_reference` on their `string parent` field, as mandated in [AEP-132][]. ## Details This rule looks at the `parent` field of any message matching `List*Request` -and complains if the `google.api.resource_reference` annotation references +and complains if the `(aep.api.field_info).resource_reference` annotation references the resource being listed. ## Examples @@ -29,11 +29,11 @@ the resource being listed. ```proto // Incorrect. message ListBooksRequest { - // The `google.api.resource_reference` should not reference the resource + // The `(aep.api.field_info).resource_reference` should not reference the resource // being listed. string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; int32 page_size = 2; string page_token = 3; @@ -47,7 +47,7 @@ message ListBooksRequest { message ListBooksRequest { string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).child_type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.child_type = "library.googleapis.com/Book" ]; int32 page_size = 2; string page_token = 3; @@ -65,7 +65,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message ListBooksRequest { string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0132/request-required-fields.md b/docs/rules/0132/request-required-fields.md index a7bc403..fc30d21 100644 --- a/docs/rules/0132/request-required-fields.md +++ b/docs/rules/0132/request-required-fields.md @@ -31,7 +31,7 @@ message ListBooksRequest { // Format: publishers/{publisher} string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { + (aep.api.field_info).resource_reference = { child_type: "library.googleapis.com/Book" }]; @@ -49,7 +49,7 @@ message ListBooksRequest { // Format: publishers/{publisher} string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { + (aep.api.field_info).resource_reference = { child_type: "library.googleapis.com/Book" }]; @@ -68,7 +68,7 @@ message ListBooksRequest { // Format: publishers/{publisher} string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { + (aep.api.field_info).resource_reference = { child_type: "library.googleapis.com/Book" }]; diff --git a/docs/rules/0132/resource-reference-type.md b/docs/rules/0132/resource-reference-type.md index aa528c6..efc0c28 100644 --- a/docs/rules/0132/resource-reference-type.md +++ b/docs/rules/0132/resource-reference-type.md @@ -11,14 +11,14 @@ redirect_from: # List methods: Parent field resource reference This rule enforces that all `List` standard methods with a `string parent` -field use a proper `google.api.resource_reference`, that being either a +field use a proper `(aep.api.field_info).resource_reference`, that being either a `child_type` referring to the pagianted resource or a `type` referring directly to the parent resource, as mandated in [AEP-132][]. ## Details This rule looks at any message matching `List*Request` and complains if the -`google.api.resource_reference` on the `parent` field refers to the wrong +`(aep.api.field_info).resource_reference` on the `parent` field refers to the wrong resource. ## Examples @@ -30,7 +30,7 @@ resource. message ListBooksRequest { // `child_type` should be used instead of `type` when referring to the // paginated resource on a parent field. - string parent = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"]; + string parent = 1 [(aep.api.field_info).resource_reference.type = "library.googleapis.com/Book"]; int32 page_size = 2; string page_token = 3; } @@ -41,7 +41,7 @@ message ListBooksRequest { ```proto // Correct. message ListBooksRequest { - string parent = 1 [(google.api.resource_reference).child_type = "library.googleapis.com/Book"]; + string parent = 1 [(aep.api.field_info).resource_reference.child_type = "library.googleapis.com/Book"]; int32 page_size = 2; string page_token = 3; } @@ -56,7 +56,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message ListBooksRequest { // (-- api-linter: core::0132::resource-reference-type=disabled // aep.dev/not-precedent: We need to do this because reasons. --) - string parent = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"]; + string parent = 1 [(aep.api.field_info).resource_reference.type = "library.googleapis.com/Book"]; int32 page_size = 2; string page_token = 3; } diff --git a/docs/rules/0133/request-id-field.md b/docs/rules/0133/request-id-field.md index f4e8fe9..726cc3f 100644 --- a/docs/rules/0133/request-id-field.md +++ b/docs/rules/0133/request-id-field.md @@ -25,7 +25,7 @@ it lacks a client-specified ID (e.g. `string book_id`) field. ```proto // Incorrect. message CreateBookRequest { - string parent = 1 [(google.api.resource_reference) = { + string parent = 1 [(aep.api.field_info).resource_reference = { child_type: "library.googleapis.com/Book" }]; @@ -40,7 +40,7 @@ message CreateBookRequest { ```proto // Correct. message CreateBookRequest { - string parent = 1 [(google.api.resource_reference) = { + string parent = 1 [(aep.api.field_info).resource_reference = { child_type: "library.googleapis.com/Book" }]; @@ -60,7 +60,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. // (-- api-linter: core::0133::request-id-field=disabled // aep.dev/not-precedent: We need to do this because reasons. --) message CreateBookRequest { - string parent = 1 [(google.api.resource_reference) = { + string parent = 1 [(aep.api.field_info).resource_reference = { child_type: "library.googleapis.com/Book" }]; diff --git a/docs/rules/0133/request-parent-behavior.md b/docs/rules/0133/request-parent-behavior.md index 29a5c0b..74ed314 100644 --- a/docs/rules/0133/request-parent-behavior.md +++ b/docs/rules/0133/request-parent-behavior.md @@ -29,7 +29,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. // Incorrect. message CreateBooksRequest { // The `aep.api.field_behavior` annotation should also be included. - string parent = 1 [(google.api.resource_reference) = { + string parent = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Publisher" }]; Book book = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -43,7 +43,7 @@ message CreateBooksRequest { message CreateBooksRequest { string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Publisher" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher" ]; Book book = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; } @@ -58,7 +58,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message CreateBooksRequest { // (-- api-linter: core::0133::request-parent-behavior=disabled // aep.dev/not-precedent: We need to do this because reasons. --) - string parent = 1 [(google.api.resource_reference) = { + string parent = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Publisher" }]; Book book = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; diff --git a/docs/rules/0133/request-resource-behavior.md b/docs/rules/0133/request-resource-behavior.md index 6eb2481..f534691 100644 --- a/docs/rules/0133/request-resource-behavior.md +++ b/docs/rules/0133/request-resource-behavior.md @@ -30,7 +30,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. message CreateBooksRequest { string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Publisher" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher" ]; Book book = 2; // Should also have (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED. } @@ -43,7 +43,7 @@ message CreateBooksRequest { message CreateBooksRequest { string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Publisher" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher" ]; Book book = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; } @@ -58,7 +58,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message CreateBooksRequest { string parent = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Publisher" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher" ]; // (-- api-linter: core::0133::request-resource-behavior=disabled diff --git a/docs/rules/0133/resource-reference-type.md b/docs/rules/0133/resource-reference-type.md index 4fd510e..f41ec6a 100644 --- a/docs/rules/0133/resource-reference-type.md +++ b/docs/rules/0133/resource-reference-type.md @@ -11,14 +11,14 @@ redirect_from: # Create methods: Parent field resource reference This rule enforces that all `Create` standard methods with a `string parent` -field use a proper `google.api.resource_reference`, that being either a +field use a proper `(aep.api.field_info).resource_reference`, that being either a `child_type` referring to the created resource or a `type` referring directly to the parent resource, as mandated in [AEP-133][]. ## Details This rule looks at any message matching `Create*Request` and complains if the -`google.api.resource_reference` on the `parent` field refers to the wrong +`(aep.api.field_info).resource_reference` on the `parent` field refers to the wrong resource. ## Examples @@ -30,7 +30,7 @@ resource. message CreateBooksRequest { // `child_type` should be used instead of `type` when referring to the // created resource on a parent field. - string parent = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"]; + string parent = 1 [(aep.api.field_info).resource_reference.type = "library.googleapis.com/Book"]; Book book = 2; } ``` @@ -40,7 +40,7 @@ message CreateBooksRequest { ```proto // Correct. message CreateBooksRequest { - string parent = 1 [(google.api.resource_reference).child_type = "library.googleapis.com/Book"]; + string parent = 1 [(aep.api.field_info).resource_reference.child_type = "library.googleapis.com/Book"]; Book book = 2; } ``` @@ -54,7 +54,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message CreateBooksRequest { // (-- api-linter: core::0133::resource-reference-type=disabled // aep.dev/not-precedent: We need to do this because reasons. --) - string parent = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"]; + string parent = 1 [(aep.api.field_info).resource_reference.type = "library.googleapis.com/Book"]; Book book = 2; } ``` diff --git a/docs/rules/0135/force-field.md b/docs/rules/0135/force-field.md index d6987ac..2b20b51 100644 --- a/docs/rules/0135/force-field.md +++ b/docs/rules/0135/force-field.md @@ -29,7 +29,7 @@ missing. message DeletePublisherRequest { // Where Publisher parents the Book resource. string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Publisher"]; + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher"]; // Missing `bool force` field. } @@ -42,7 +42,7 @@ message DeletePublisherRequest { message DeletePublisherRequest { // Where Publisher parents the Book resource. string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Publisher"]; + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher"]; // If set to true, any books from this publisher will also be deleted. // (Otherwise, the request will only work if the publisher has no books.) @@ -62,7 +62,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message DeletePublisherRequest { // Where Publisher parents the Book resource. string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Publisher"]; + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher"]; } ``` diff --git a/docs/rules/0135/request-force-field.md b/docs/rules/0135/request-force-field.md index bd8c457..70f30b5 100644 --- a/docs/rules/0135/request-force-field.md +++ b/docs/rules/0135/request-force-field.md @@ -25,7 +25,7 @@ field and complains if the field is not a singular `bool`. ```proto message DeletePublisherRequest { string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Publisher", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher", (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED ]; @@ -38,7 +38,7 @@ message DeletePublisherRequest { ```proto message DeletePublisherRequest { string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Publisher", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher", (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED ]; @@ -54,7 +54,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. ```proto message DeletePublisherRequest { string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Publisher", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Publisher", (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED ]; diff --git a/docs/rules/0135/request-path-behavior.md b/docs/rules/0135/request-path-behavior.md index 00f6ca8..584eea9 100644 --- a/docs/rules/0135/request-path-behavior.md +++ b/docs/rules/0135/request-path-behavior.md @@ -29,7 +29,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. // Incorrect. message DeleteBookRequest { // The `aep.api.field_behavior` annotation should also be included. - string path = 1 [(google.api.resource_reference) = { + string path = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; } @@ -42,7 +42,7 @@ message DeleteBookRequest { message DeleteBookRequest { string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -56,7 +56,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message DeleteBookRequest { // (-- api-linter: core::0135::request-path-behavior=disabled // aep.dev/not-precedent: We need to do this because reasons. --) - string path = 1 [(google.api.resource_reference) = { + string path = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; } diff --git a/docs/rules/0135/request-path-reference.md b/docs/rules/0135/request-path-reference.md index 4987cb2..d5ae46d 100644 --- a/docs/rules/0135/request-path-reference.md +++ b/docs/rules/0135/request-path-reference.md @@ -3,7 +3,7 @@ rule: aep: 135 name: [core, '0135', request-path-reference] summary: | - Delete RPCs should annotate the `path` field with `google.api.resource_reference`. + Delete RPCs should annotate the `path` field with `(aep.api.field_info).resource_reference`. permalink: /135/request-path-reference redirect_from: - /0135/request-path-reference @@ -12,13 +12,13 @@ redirect_from: # Delete methods: Resource reference This rule enforces that all `Delete` standard methods have -`google.api.resource_reference` on their `string path` field, as mandated in +`(aep.api.field_info).resource_reference` on their `string path` field, as mandated in [AEP-135][]. ## Details This rule looks at the `path` field of any message matching `Delete*Request` -and complains if it does not have a `google.api.resource_reference` annotation. +and complains if it does not have a `(aep.api.field_info).resource_reference` annotation. ## Examples @@ -27,7 +27,7 @@ and complains if it does not have a `google.api.resource_reference` annotation. ```proto // Incorrect. message DeleteBookRequest { - // The `google.api.resource_reference` annotation should also be included. + // The `(aep.api.field_info).resource_reference` annotation should also be included. string path = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; } ``` @@ -39,7 +39,7 @@ message DeleteBookRequest { message DeleteBookRequest { string path = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0157/request-read-mask-field.md b/docs/rules/0157/request-read-mask-field.md index 2e0455a..b57aeb9 100644 --- a/docs/rules/0157/request-read-mask-field.md +++ b/docs/rules/0157/request-read-mask-field.md @@ -26,7 +26,7 @@ field, and complains if the field is not a singular `google.protobuf.FieldMask`. // Incorrect. message GetBookRequest { string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book", (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED ]; @@ -41,7 +41,7 @@ message GetBookRequest { // Correct. message GetBookRequest { string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book", (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED ]; @@ -57,7 +57,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. ```proto message GetBookRequest { string path = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book", (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED ]; diff --git a/docs/rules/0158/request-skip-field.md b/docs/rules/0158/request-skip-field.md index 8696faa..17d133e 100644 --- a/docs/rules/0158/request-skip-field.md +++ b/docs/rules/0158/request-skip-field.md @@ -25,7 +25,7 @@ contains a `skip` field, and complains if the field is not a singular `int32`. ```proto message ListBooksRequest { string parent = 1 [ - (google.api.resource_reference).child_type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.child_type = "library.googleapis.com/Book", (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED ]; @@ -42,7 +42,7 @@ message ListBooksRequest { ```proto message ListBooksRequest { string parent = 1 [ - (google.api.resource_reference).child_type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.child_type = "library.googleapis.com/Book", (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED ]; @@ -62,7 +62,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. ```proto message ListBooksRequest { string parent = 1 [ - (google.api.resource_reference).child_type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.child_type = "library.googleapis.com/Book", (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED ]; diff --git a/docs/rules/0162/commit-request-name-behavior.md b/docs/rules/0162/commit-request-name-behavior.md index 3d39831..aef80e7 100644 --- a/docs/rules/0162/commit-request-name-behavior.md +++ b/docs/rules/0162/commit-request-name-behavior.md @@ -30,7 +30,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. message CommitBookRequest { // The `aep.api.field_behavior` annotation should also be included. string name = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -42,7 +42,7 @@ message CommitBookRequest { message CommitBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -57,7 +57,7 @@ message CommitBookRequest { // (-- api-linter: core::0162::commit-request-name-behavior=disabled // aep.dev/not-precedent: We need to do this because reasons. --) string name = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0162/commit-request-name-field.md b/docs/rules/0162/commit-request-name-field.md index 26d5690..dc518dd 100644 --- a/docs/rules/0162/commit-request-name-field.md +++ b/docs/rules/0162/commit-request-name-field.md @@ -35,7 +35,7 @@ message CommitBookRequest { // Field type should be `string`. bytes name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -47,7 +47,7 @@ message CommitBookRequest { message CommitBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -64,7 +64,7 @@ message CommitBookRequest { // aep.dev/not-precedent: We need to do this because reasons. --) bytes name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0162/commit-request-name-reference.md b/docs/rules/0162/commit-request-name-reference.md index 1678914..4ecc0c1 100644 --- a/docs/rules/0162/commit-request-name-reference.md +++ b/docs/rules/0162/commit-request-name-reference.md @@ -3,7 +3,7 @@ rule: aep: 162 name: [core, '0162', commit-request-name-reference] summary: | - Commit requests should annotate the `name` field with `google.api.resource_reference`. + Commit requests should annotate the `name` field with `(aep.api.field_info).resource_reference`. permalink: /162/commit-request-name-reference redirect_from: - /0162/commit-request-name-reference @@ -12,13 +12,13 @@ redirect_from: # Commit requests: Name resource reference This rule enforces that all `Commit` requests have -`google.api.resource_reference` on their `string name` field, as mandated in +`(aep.api.field_info).resource_reference` on their `string name` field, as mandated in [AEP-162][]. ## Details This rule looks at the `name` field of any message matching `Commit*Request` -and complains if it does not have a `google.api.resource_reference` annotation. +and complains if it does not have a `(aep.api.field_info).resource_reference` annotation. ## Examples @@ -27,7 +27,7 @@ and complains if it does not have a `google.api.resource_reference` annotation. ```proto // Incorrect. message CommitBookRequest { - // The `google.api.resource_reference` annotation should also be included. + // The `(aep.api.field_info).resource_reference` annotation should also be included. string name = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; } ``` @@ -39,7 +39,7 @@ message CommitBookRequest { message CommitBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0162/delete-revision-request-name-behavior.md b/docs/rules/0162/delete-revision-request-name-behavior.md index 9f52e12..5079ff9 100644 --- a/docs/rules/0162/delete-revision-request-name-behavior.md +++ b/docs/rules/0162/delete-revision-request-name-behavior.md @@ -30,7 +30,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. message DeleteBookRevisionRequest { // The `aep.api.field_behavior` annotation should also be included. string name = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -42,7 +42,7 @@ message DeleteBookRevisionRequest { message DeleteBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -57,7 +57,7 @@ message DeleteBookRevisionRequest { // (-- api-linter: core::0162::delete-revision-request-name-behavior=disabled // aep.dev/not-precedent: We need to do this because reasons. --) string name = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0162/delete-revision-request-name-field.md b/docs/rules/0162/delete-revision-request-name-field.md index 1bc1b70..dd3fa50 100644 --- a/docs/rules/0162/delete-revision-request-name-field.md +++ b/docs/rules/0162/delete-revision-request-name-field.md @@ -34,7 +34,7 @@ message DeleteBookRevisionRequest { // Field type should be `string`. bytes name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -46,7 +46,7 @@ message DeleteBookRevisionRequest { message DeleteBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -63,7 +63,7 @@ message DeleteBookRevisionRequest { // aep.dev/not-precedent: We need to do this because reasons. --) bytes name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0162/delete-revision-request-name-reference.md b/docs/rules/0162/delete-revision-request-name-reference.md index f241cbb..7c83256 100644 --- a/docs/rules/0162/delete-revision-request-name-reference.md +++ b/docs/rules/0162/delete-revision-request-name-reference.md @@ -3,7 +3,7 @@ rule: aep: 162 name: [core, '0162', delete-revision-request-name-reference] summary: | - Delete Revision requests should annotate the `name` field with `google.api.resource_reference`. + Delete Revision requests should annotate the `name` field with `(aep.api.field_info).resource_reference`. permalink: /162/delete-revision-request-name-reference redirect_from: - /0162/delete-revision-request-name-reference @@ -12,13 +12,13 @@ redirect_from: # Delete Revision requests: Name resource reference This rule enforces that all Delete Revision requests have -`google.api.resource_reference` on their `string name` field, as mandated in +`(aep.api.field_info).resource_reference` on their `string name` field, as mandated in [AEP-162][]. ## Details This rule looks at the `name` field of any message matching `Delete*RevisionRequest` -and complains if it does not have a `google.api.resource_reference` annotation. +and complains if it does not have a `(aep.api.field_info).resource_reference` annotation. ## Examples @@ -27,7 +27,7 @@ and complains if it does not have a `google.api.resource_reference` annotation. ```proto // Incorrect. message DeleteBookRevisionRequest { - // The `google.api.resource_reference` annotation should also be included. + // The `(aep.api.field_info).resource_reference` annotation should also be included. string name = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; } ``` @@ -39,7 +39,7 @@ message DeleteBookRevisionRequest { message DeleteBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0162/rollback-request-name-behavior.md b/docs/rules/0162/rollback-request-name-behavior.md index fb8d96e..c3ada6b 100644 --- a/docs/rules/0162/rollback-request-name-behavior.md +++ b/docs/rules/0162/rollback-request-name-behavior.md @@ -30,7 +30,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. message RollbackBookRequest { // The `aep.api.field_behavior` annotation should also be included. string name = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -44,7 +44,7 @@ message RollbackBookRequest { message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -61,7 +61,7 @@ message RollbackBookRequest { // (-- api-linter: core::0162::rollback-request-name-behavior=disabled // aep.dev/not-precedent: We need to do this because reasons. --) string name = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; diff --git a/docs/rules/0162/rollback-request-name-field.md b/docs/rules/0162/rollback-request-name-field.md index 1637559..3dc034d 100644 --- a/docs/rules/0162/rollback-request-name-field.md +++ b/docs/rules/0162/rollback-request-name-field.md @@ -36,7 +36,7 @@ message RollbackBookRequest { // Field type should be `string`. bytes name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -50,7 +50,7 @@ message RollbackBookRequest { message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -69,7 +69,7 @@ message RollbackBookRequest { // aep.dev/not-precedent: We need to do this because reasons. --) bytes name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; diff --git a/docs/rules/0162/rollback-request-name-reference.md b/docs/rules/0162/rollback-request-name-reference.md index 9155ee7..5e97585 100644 --- a/docs/rules/0162/rollback-request-name-reference.md +++ b/docs/rules/0162/rollback-request-name-reference.md @@ -3,7 +3,7 @@ rule: aep: 162 name: [core, '0162', rollback-request-name-reference] summary: | - Rollback requests should annotate the `name` field with `google.api.resource_reference`. + Rollback requests should annotate the `name` field with `(aep.api.field_info).resource_reference`. permalink: /162/rollback-request-name-reference redirect_from: - /0162/rollback-request-name-reference @@ -12,13 +12,13 @@ redirect_from: # Rollback requests: Name resource reference This rule enforces that all `Rollback` requests have -`google.api.resource_reference` on their `string name` field, as mandated in +`(aep.api.field_info).resource_reference` on their `string name` field, as mandated in [AEP-162][]. ## Details This rule looks at the `name` field of any message matching `Rollback*Request` -and complains if it does not have a `google.api.resource_reference` annotation. +and complains if it does not have a `(aep.api.field_info).resource_reference` annotation. ## Examples @@ -27,7 +27,7 @@ and complains if it does not have a `google.api.resource_reference` annotation. ```proto // Incorrect. message RollbackBookRequest { - // The `google.api.resource_reference` annotation should also be included. + // The `(aep.api.field_info).resource_reference` annotation should also be included. string name = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -41,7 +41,7 @@ message RollbackBookRequest { message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; diff --git a/docs/rules/0162/rollback-request-revision-id-behavior.md b/docs/rules/0162/rollback-request-revision-id-behavior.md index b1810e8..bef8ed9 100644 --- a/docs/rules/0162/rollback-request-revision-id-behavior.md +++ b/docs/rules/0162/rollback-request-revision-id-behavior.md @@ -30,7 +30,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; // The `aep.api.field_behavior` annotation should be included. @@ -45,7 +45,7 @@ message RollbackBookRequest { message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -61,7 +61,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; // (-- api-linter: core::0162::rollback-request-revision-id-behavior=disabled diff --git a/docs/rules/0162/rollback-request-revision-id-field.md b/docs/rules/0162/rollback-request-revision-id-field.md index 7e6c01a..40b66ed 100644 --- a/docs/rules/0162/rollback-request-revision-id-field.md +++ b/docs/rules/0162/rollback-request-revision-id-field.md @@ -28,7 +28,7 @@ either the `revision_id` field is missing or it has any type other than `string` message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -38,7 +38,7 @@ message RollbackBookRequest { message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; // Field type should be `string`. @@ -53,7 +53,7 @@ message RollbackBookRequest { message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string revision_id = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -70,7 +70,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message RollbackBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; // (-- api-linter: core::0162::rollback-request-revision-id-field=disabled diff --git a/docs/rules/0162/tag-revision-request-name-behavior.md b/docs/rules/0162/tag-revision-request-name-behavior.md index 57a8ee7..6e8f672 100644 --- a/docs/rules/0162/tag-revision-request-name-behavior.md +++ b/docs/rules/0162/tag-revision-request-name-behavior.md @@ -30,7 +30,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. message TagBookRevisionRequest { // The `aep.api.field_behavior` annotation should also be included. string name = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -44,7 +44,7 @@ message TagBookRevisionRequest { message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -61,7 +61,7 @@ message TagBookRevisionRequest { // (-- api-linter: core::0162::tag-revision-request-name-behavior=disabled // aep.dev/not-precedent: We need to do this because reasons. --) string name = 1 [ - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; diff --git a/docs/rules/0162/tag-revision-request-name-field.md b/docs/rules/0162/tag-revision-request-name-field.md index 2e10882..594bbb7 100644 --- a/docs/rules/0162/tag-revision-request-name-field.md +++ b/docs/rules/0162/tag-revision-request-name-field.md @@ -36,7 +36,7 @@ message TagBookRevisionRequest { // Field type should be `string`. bytes name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -50,7 +50,7 @@ message TagBookRevisionRequest { message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -69,7 +69,7 @@ message TagBookRevisionRequest { // aep.dev/not-precedent: We need to do this because reasons. --) bytes name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; diff --git a/docs/rules/0162/tag-revision-request-name-reference.md b/docs/rules/0162/tag-revision-request-name-reference.md index f6665c1..f88d8bd 100644 --- a/docs/rules/0162/tag-revision-request-name-reference.md +++ b/docs/rules/0162/tag-revision-request-name-reference.md @@ -3,7 +3,7 @@ rule: aep: 162 name: [core, '0162', tag-revision-request-name-reference] summary: | - Tag Revision requests should annotate the `name` field with `google.api.resource_reference`. + Tag Revision requests should annotate the `name` field with `(aep.api.field_info).resource_reference`. permalink: /162/tag-revision-request-name-reference redirect_from: - /0162/tag-revision-request-name-reference @@ -12,13 +12,13 @@ redirect_from: # Tag Revision requests: Name resource reference This rule enforces that all Tag Revision requests have -`google.api.resource_reference` on their `string name` field, as mandated in +`(aep.api.field_info).resource_reference` on their `string name` field, as mandated in [AEP-162][]. ## Details This rule looks at the `name` field of any message matching `Tag*RevisionRequest` -and complains if it does not have a `google.api.resource_reference` annotation. +and complains if it does not have a `(aep.api.field_info).resource_reference` annotation. ## Examples @@ -27,7 +27,7 @@ and complains if it does not have a `google.api.resource_reference` annotation. ```proto // Incorrect. message TagBookRevisionRequest { - // The `google.api.resource_reference` annotation should also be included. + // The `(aep.api.field_info).resource_reference` annotation should also be included. string name = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -41,7 +41,7 @@ message TagBookRevisionRequest { message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; diff --git a/docs/rules/0162/tag-revision-request-tag-behavior.md b/docs/rules/0162/tag-revision-request-tag-behavior.md index b1b7ab1..0074f2b 100644 --- a/docs/rules/0162/tag-revision-request-tag-behavior.md +++ b/docs/rules/0162/tag-revision-request-tag-behavior.md @@ -30,7 +30,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; // The `aep.api.field_behavior` annotation should be included. @@ -45,7 +45,7 @@ message TagBookRevisionRequest { message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -61,7 +61,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; // (-- api-linter: core::0162::tag-revision-request-tag-behavior=disabled diff --git a/docs/rules/0162/tag-revision-request-tag-field.md b/docs/rules/0162/tag-revision-request-tag-field.md index 94deb8b..9a838c4 100644 --- a/docs/rules/0162/tag-revision-request-tag-field.md +++ b/docs/rules/0162/tag-revision-request-tag-field.md @@ -28,7 +28,7 @@ either the `tag` field is missing or it has any type other than `string`. message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -38,7 +38,7 @@ message TagBookRevisionRequest { message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; // Field type should be `string`. @@ -53,7 +53,7 @@ message TagBookRevisionRequest { message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; string tag = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; @@ -70,7 +70,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message TagBookRevisionRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; // (-- api-linter: core::0162::tag-revision-request-tag-field=disabled diff --git a/docs/rules/0164/request-name-behavior.md b/docs/rules/0164/request-name-behavior.md index 511148b..42293f3 100644 --- a/docs/rules/0164/request-name-behavior.md +++ b/docs/rules/0164/request-name-behavior.md @@ -29,7 +29,7 @@ value of `FIELD_BEHAVIOR_REQUIRED`. // Incorrect. message UndeleteBookRequest { // The `aep.api.field_behavior` annotation should also be included. - string name = 1 [(google.api.resource_reference) = { + string name = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; } @@ -42,7 +42,7 @@ message UndeleteBookRequest { message UndeleteBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` @@ -56,7 +56,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message UndeleteBookRequest { // (-- api-linter: core::0164::request-name-behavior=disabled // aep.dev/not-precedent: We need to do this because reasons. --) - string name = 1 [(google.api.resource_reference) = { + string name = 1 [(aep.api.field_info).resource_reference = { type: "library.googleapis.com/Book" }]; } diff --git a/docs/rules/0164/request-name-field.md b/docs/rules/0164/request-name-field.md index 4e86f82..5f2a1d5 100644 --- a/docs/rules/0164/request-name-field.md +++ b/docs/rules/0164/request-name-field.md @@ -43,7 +43,7 @@ message UndeleteBookRequest { message UndeleteBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0164/request-name-reference.md b/docs/rules/0164/request-name-reference.md index 557f6ed..af06b8e 100644 --- a/docs/rules/0164/request-name-reference.md +++ b/docs/rules/0164/request-name-reference.md @@ -3,7 +3,7 @@ rule: aep: 164 name: [core, '0164', request-name-reference] summary: | - Undelete RPCs should annotate the `name` field with `google.api.resource_reference`. + Undelete RPCs should annotate the `name` field with `(aep.api.field_info).resource_reference`. permalink: /164/request-name-reference redirect_from: - /0164/request-name-reference @@ -12,13 +12,13 @@ redirect_from: # Undelete methods: Resource reference This rule enforces that all `Undelete` methods have -`google.api.resource_reference` on their `string name` field, as mandated in +`(aep.api.field_info).resource_reference` on their `string name` field, as mandated in [AEP-164][]. ## Details This rule looks at the `name` field of any message matching `Undelete*Request` -and complains if it does not have a `google.api.resource_reference` annotation. +and complains if it does not have a `(aep.api.field_info).resource_reference` annotation. ## Examples @@ -27,7 +27,7 @@ and complains if it does not have a `google.api.resource_reference` annotation. ```proto // Incorrect. message UndeleteBookRequest { - // The `google.api.resource_reference` annotation should also be included. + // The `(aep.api.field_info).resource_reference` annotation should also be included. string name = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]; } ``` @@ -39,7 +39,7 @@ message UndeleteBookRequest { message UndeleteBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book" + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book" ]; } ``` diff --git a/docs/rules/0164/request-unknown-fields.md b/docs/rules/0164/request-unknown-fields.md index a5460a9..694e71a 100644 --- a/docs/rules/0164/request-unknown-fields.md +++ b/docs/rules/0164/request-unknown-fields.md @@ -32,7 +32,7 @@ comes across any fields other than: message UndeleteBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book", ]; string library_id = 2; // Non-standard field. } @@ -45,7 +45,7 @@ message UndeleteBookRequest { message UndeleteBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book", ]; } ``` @@ -59,7 +59,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why. message UndeleteBookRequest { string name = 1 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference).type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference.type = "library.googleapis.com/Book", ]; // (-- api-linter: core::0164::request-unknown-fields=disabled diff --git a/example/proto/example/bookstore/v1/bookstore.proto b/example/proto/example/bookstore/v1/bookstore.proto index a803775..4de728a 100644 --- a/example/proto/example/bookstore/v1/bookstore.proto +++ b/example/proto/example/bookstore/v1/bookstore.proto @@ -262,7 +262,7 @@ message CreateBookRequest { // A field for the parent of book string parent = 10013 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { } + (aep.api.field_info).resource_reference = "" ]; // An id that uniquely identifies the resource within the collection @@ -277,7 +277,7 @@ message GetBookRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/book" } + (aep.api.field_info).resource_reference = "bookstore.example.com/book" ]; } @@ -286,7 +286,7 @@ message UpdateBookRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/book" } + (aep.api.field_info).resource_reference = "bookstore.example.com/book" ]; // The resource to perform the operation on. @@ -301,7 +301,7 @@ message DeleteBookRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/book" } + (aep.api.field_info).resource_reference = "bookstore.example.com/book" ]; // If true, the resource will be deleted, even if children still exist. @@ -313,7 +313,7 @@ message ListBooksRequest { // A field for the parent of book string parent = 10013 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { } + (aep.api.field_info).resource_reference = "" ]; // The page token indicating the starting point of the page @@ -340,7 +340,7 @@ message ApplyBookRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/book" } + (aep.api.field_info).resource_reference = "bookstore.example.com/book" ]; // The resource to perform the operation on. @@ -352,7 +352,7 @@ message ArchiveBookRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/book" } + (aep.api.field_info).resource_reference = "bookstore.example.com/book" ]; } @@ -367,7 +367,7 @@ message CreateBookEditionRequest { // A field for the parent of book-edition string parent = 10013 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { } + (aep.api.field_info).resource_reference = "" ]; // An id that uniquely identifies the resource within the collection @@ -382,7 +382,7 @@ message GetBookEditionRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/book-edition" } + (aep.api.field_info).resource_reference = "bookstore.example.com/book-edition" ]; } @@ -391,7 +391,7 @@ message DeleteBookEditionRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/book-edition" } + (aep.api.field_info).resource_reference = "bookstore.example.com/book-edition" ]; } @@ -400,7 +400,7 @@ message ListBookEditionsRequest { // A field for the parent of book-edition string parent = 10013 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { } + (aep.api.field_info).resource_reference = "" ]; // The page token indicating the starting point of the page @@ -424,7 +424,7 @@ message CreateIsbnRequest { // A field for the parent of isbn string parent = 10013 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { } + (aep.api.field_info).resource_reference = "" ]; // An id that uniquely identifies the resource within the collection @@ -439,7 +439,7 @@ message GetIsbnRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/isbn" } + (aep.api.field_info).resource_reference = "bookstore.example.com/isbn" ]; } @@ -448,7 +448,7 @@ message ListIsbnsRequest { // A field for the parent of isbn string parent = 10013 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { } + (aep.api.field_info).resource_reference = "" ]; // The page token indicating the starting point of the page @@ -472,7 +472,7 @@ message CreatePublisherRequest { // A field for the parent of publisher string parent = 10013 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { } + (aep.api.field_info).resource_reference = "" ]; // An id that uniquely identifies the resource within the collection @@ -487,7 +487,7 @@ message GetPublisherRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/publisher" } + (aep.api.field_info).resource_reference = "bookstore.example.com/publisher" ]; } @@ -496,7 +496,7 @@ message UpdatePublisherRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/publisher" } + (aep.api.field_info).resource_reference = "bookstore.example.com/publisher" ]; // The resource to perform the operation on. @@ -511,7 +511,7 @@ message DeletePublisherRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/publisher" } + (aep.api.field_info).resource_reference = "bookstore.example.com/publisher" ]; // If true, the resource will be deleted, even if children still exist. @@ -523,7 +523,7 @@ message ListPublishersRequest { // A field for the parent of publisher string parent = 10013 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { } + (aep.api.field_info).resource_reference = "" ]; // The page token indicating the starting point of the page @@ -547,7 +547,7 @@ message ApplyPublisherRequest { // The globally unique identifier for the resource string path = 10018 [ (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/publisher" } + (aep.api.field_info).resource_reference = "bookstore.example.com/publisher" ]; // The resource to perform the operation on. diff --git a/locations/field_locations.go b/locations/field_locations.go index 586f948..95481f4 100644 --- a/locations/field_locations.go +++ b/locations/field_locations.go @@ -15,8 +15,8 @@ package locations import ( + aepapi "buf.build/gen/go/aep/api/protocolbuffers/go/aep/api" "github.com/jhump/protoreflect/desc" - apb "google.golang.org/genproto/googleapis/api/annotations" "google.golang.org/protobuf/reflect/protoreflect" dpb "google.golang.org/protobuf/types/descriptorpb" ) @@ -30,9 +30,10 @@ func FieldOption(f *desc.FieldDescriptor, e protoreflect.ExtensionType) *dpb.Sou } // FieldResourceReference returns the precise location for a field's -// resource reference annotation. +// resource reference annotation within the aep.api.field_info extension. func FieldResourceReference(f *desc.FieldDescriptor) *dpb.SourceCodeInfo_Location { - return pathLocation(f, 8, int(apb.E_ResourceReference.TypeDescriptor().Number())) // FieldDescriptor.options == 8 + // Path: FieldDescriptor.options (8) -> field_info extension number (10520) -> resource_reference field (2) -> array index (0) + return pathLocation(f, 8, int(aepapi.E_FieldInfo.TypeDescriptor().Number()), 2, 0) } // FieldType returns the precise location for a field's type. diff --git a/locations/field_locations_test.go b/locations/field_locations_test.go index c97af12..e564f98 100644 --- a/locations/field_locations_test.go +++ b/locations/field_locations_test.go @@ -19,7 +19,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/jhump/protoreflect/desc" - apb "google.golang.org/genproto/googleapis/api/annotations" ) func TestFieldLocations(t *testing.T) { @@ -75,30 +74,15 @@ func TestFieldLabel(t *testing.T) { func TestFieldResourceReference(t *testing.T) { f := parse(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message GetBookRequest { - string name = 1 [(google.api.resource_reference) = { - type: "library.googleapis.com/Book" - }]; + string name = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; } `) loc := FieldResourceReference(f.GetMessageTypes()[0].GetFields()[0]) - // resource_reference annotation location is roughly line 4, column 19. - if diff := cmp.Diff(loc.GetSpan(), []int32{4, 19, 6, 3}); diff != "" { + // resource_reference annotation location is roughly line 5, column 19-90. + if diff := cmp.Diff(loc.GetSpan(), []int32{5, 19, 90}); diff != "" { t.Error(diff) } } -func TestFieldOption(t *testing.T) { - f := parse(t, ` - import "google/api/resource.proto"; - message GetBookRequest { - string name = 1 [(google.api.resource_reference) = { - type: "library.googleapis.com/Book" - }]; - } - `) - loc := FieldOption(f.GetMessageTypes()[0].GetFields()[0], apb.E_ResourceReference) - if diff := cmp.Diff(loc.GetSpan(), []int32{4, 19, 6, 3}); diff != "" { - t.Error(diff) - } -} diff --git a/locations/locations_test.go b/locations/locations_test.go index 2ada999..91982eb 100644 --- a/locations/locations_test.go +++ b/locations/locations_test.go @@ -25,6 +25,7 @@ import ( // These imports cause the common protos to be registered with // the protocol buffer registry, and therefore make the call to // `proto.FileDescriptor` work for the imported files. + _ "buf.build/gen/go/aep/api/protocolbuffers/go/aep/api" _ "cloud.google.com/go/longrunning/autogen/longrunningpb" _ "google.golang.org/genproto/googleapis/api/annotations" ) diff --git a/rules/aep0004/resource_reference_type_test.go b/rules/aep0004/resource_reference_type_test.go index aad7feb..9529873 100644 --- a/rules/aep0004/resource_reference_type_test.go +++ b/rules/aep0004/resource_reference_type_test.go @@ -21,9 +21,7 @@ import ( ) func TestResourceReferenceType(t *testing.T) { - annotation := ` [(google.api.resource_reference) = { - type: "library.googleapis.com/Author" - }]` + annotation := ` [(aep.api.field_info).resource_reference = "library.googleapis.com/Author"]` for _, test := range []struct { name string Type string @@ -38,6 +36,7 @@ func TestResourceReferenceType(t *testing.T) { t.Run(test.name, func(t *testing.T) { file := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message Book { {{.Type}} author = 1{{.Annotation}}; } diff --git a/rules/aep0121/no_mutable_cycles_test.go b/rules/aep0121/no_mutable_cycles_test.go index a0fd92f..ca185d5 100644 --- a/rules/aep0121/no_mutable_cycles_test.go +++ b/rules/aep0121/no_mutable_cycles_test.go @@ -29,16 +29,16 @@ func TestNoMutableCycles(t *testing.T) { }{ { "ValidNoCycle", - `[(google.api.resource_reference).type = "library.googleapis.com/Library"]`, - `[(google.api.resource_reference).type = "library.googleapis.com/Library"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Library"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Library"]`, "", "", nil, }, { "InvalidCycle", - `[(google.api.resource_reference).type = "library.googleapis.com/Publisher"]`, - `[(google.api.resource_reference).type = "library.googleapis.com/Book"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Publisher"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]`, "", "", testutils.Problems{{ @@ -48,7 +48,7 @@ func TestNoMutableCycles(t *testing.T) { { "InvalidSelfReferenceCycle", "", - `[(google.api.resource_reference).type = "library.googleapis.com/Publisher"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Publisher"]`, "", "", testutils.Problems{{ @@ -57,9 +57,9 @@ func TestNoMutableCycles(t *testing.T) { }, { "InvalidDeepCycle", - `[(google.api.resource_reference).type = "library.googleapis.com/Publisher"]`, - `[(google.api.resource_reference).type = "library.googleapis.com/Library"]`, - `[(google.api.resource_reference).type = "library.googleapis.com/Book"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Publisher"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Library"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]`, "", testutils.Problems{{ Message: "cycle", @@ -67,10 +67,10 @@ func TestNoMutableCycles(t *testing.T) { }, { "InvalidDeepAndShallowCycles", - `[(google.api.resource_reference).type = "library.googleapis.com/Publisher"]`, - `[(google.api.resource_reference).type = "library.googleapis.com/Library"]`, - `[(google.api.resource_reference).type = "library.googleapis.com/Book"]`, - `[(google.api.resource_reference).type = "library.googleapis.com/Book"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Publisher"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Library"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]`, testutils.Problems{ { Message: "cycle", @@ -82,9 +82,9 @@ func TestNoMutableCycles(t *testing.T) { }, { "ValidOutputOnlyCyclicReference", - `[(google.api.resource_reference).type = "library.googleapis.com/Publisher"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Publisher"]`, `[ - (google.api.resource_reference).type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference = "library.googleapis.com/Book", (aep.api.field_info).field_behavior = FIELD_BEHAVIOR_OUTPUT_ONLY ]`, "", @@ -93,10 +93,10 @@ func TestNoMutableCycles(t *testing.T) { }, { "ValidOutputOnlyDeepCyclicReference", - `[(google.api.resource_reference).type = "library.googleapis.com/Publisher"]`, - `[(google.api.resource_reference).type = "library.googleapis.com/Library"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Publisher"]`, + `[(aep.api.field_info).resource_reference = "library.googleapis.com/Library"]`, `[ - (google.api.resource_reference).type = "library.googleapis.com/Book", + (aep.api.field_info).resource_reference = "library.googleapis.com/Book", (aep.api.field_info).field_behavior = FIELD_BEHAVIOR_OUTPUT_ONLY ]`, "", diff --git a/rules/aep0122/resource_reference_type_test.go b/rules/aep0122/resource_reference_type_test.go index e75b81f..30eda40 100644 --- a/rules/aep0122/resource_reference_type_test.go +++ b/rules/aep0122/resource_reference_type_test.go @@ -21,9 +21,7 @@ import ( ) func TestResourceReferenceType(t *testing.T) { - ann := ` [(google.api.resource_reference) = { - type: "library.googleapis.com/Author" - }]` + ann := ` [(aep.api.field_info).resource_reference = "library.googleapis.com/Author"]` for _, test := range []struct { name string Type string @@ -37,6 +35,7 @@ func TestResourceReferenceType(t *testing.T) { t.Run(test.name, func(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message Book { {{.Type}} author = 1{{.Annotation}}; diff --git a/rules/aep0127/http_template_pattern.go b/rules/aep0127/http_template_pattern.go index dad4101..b71b876 100644 --- a/rules/aep0127/http_template_pattern.go +++ b/rules/aep0127/http_template_pattern.go @@ -32,7 +32,7 @@ var ( ) type resourceReference struct { - // The path of the field with the `google.api.resource_reference`. This is + // The path of the field with the `(aep.api.field_info).resource_reference`. This is // provided as a variable in the HTTPRule. fieldPath string // A template that the resource's pattern string must adhere to. This is diff --git a/rules/aep0127/http_template_pattern_test.go b/rules/aep0127/http_template_pattern_test.go index 0fe0099..e096f71 100644 --- a/rules/aep0127/http_template_pattern_test.go +++ b/rules/aep0127/http_template_pattern_test.go @@ -58,6 +58,7 @@ func TestHttpTemplatePattern_PatternMatching(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/annotations.proto"; import "google/api/resource.proto"; + import "aep/api/field_info.proto"; service Library { rpc GetBook(GetBookRequest) returns (Book) { option (google.api.http) = { @@ -67,7 +68,7 @@ func TestHttpTemplatePattern_PatternMatching(t *testing.T) { } message GetBookRequest { // Format: shelves/{shelf}/books/{book} - string path = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"]; + string path = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; } message Book { option (google.api.resource) = { @@ -102,6 +103,7 @@ func TestHttpTemplatePattern_MultiplePatterns(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/annotations.proto"; import "google/api/resource.proto"; + import "aep/api/field_info.proto"; service Library { rpc GetBook(GetBookRequest) returns (Book) { option (google.api.http) = { @@ -110,7 +112,7 @@ func TestHttpTemplatePattern_MultiplePatterns(t *testing.T) { } } message GetBookRequest { - string path = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"]; + string path = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; } message Book { option (google.api.resource) = { @@ -133,11 +135,12 @@ func TestHttpTemplatePattern_SkipCheckIfNoHTTPRules(t *testing.T) { f := testutils.ParseProto3String(t, ` import "google/api/annotations.proto"; import "google/api/resource.proto"; + import "aep/api/field_info.proto"; service Library { rpc GetBook(GetBookRequest) returns (Book) {} } message GetBookRequest { - string path = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"]; + string path = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; } message Book { option (google.api.resource) = { @@ -155,6 +158,7 @@ func TestHttpTemplatePattern_SkipCheckIfHTTPRuleHasNoVariables(t *testing.T) { f := testutils.ParseProto3String(t, ` import "google/api/annotations.proto"; import "google/api/resource.proto"; + import "aep/api/field_info.proto"; service Library { rpc GetBook(GetBookRequest) returns (Book) { option (google.api.http) = { @@ -163,7 +167,7 @@ func TestHttpTemplatePattern_SkipCheckIfHTTPRuleHasNoVariables(t *testing.T) { } } message GetBookRequest { - string path = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"]; + string path = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; } message Book { option (google.api.resource) = { @@ -181,6 +185,7 @@ func TestHttpTemplatePattern_SkipCheckIfFieldPathMissingResourceAnnotation(t *te f := testutils.ParseProto3String(t, ` import "google/api/annotations.proto"; import "google/api/resource.proto"; + import "aep/api/field_info.proto"; service Library { rpc GetBook(GetBookRequest) returns (Book) { option (google.api.http) = { diff --git a/rules/aep0131/request_path_reference_test.go b/rules/aep0131/request_path_reference_test.go index 443324f..80df374 100644 --- a/rules/aep0131/request_path_reference_test.go +++ b/rules/aep0131/request_path_reference_test.go @@ -24,10 +24,9 @@ func TestRequestNameReference(t *testing.T) { t.Run("Present", func(t *testing.T) { f := testutils.ParseProto3String(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message GetBookRequest { - string path = 1 [(google.api.resource_reference) = { - type: "library.googleapis.com/Book" - }]; + string path = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; } `) if diff := (testutils.Problems{}).Diff(requestPathReference.Lint(f)); diff != "" { @@ -40,12 +39,13 @@ func TestRequestNameReference(t *testing.T) { FieldName string problems testutils.Problems }{ - {"Error", "path", testutils.Problems{{Message: "google.api.resource_reference"}}}, + {"Error", "path", testutils.Problems{{Message: "(aep.api.field_info).resource_reference"}}}, {"Irrelevant", "something_else", testutils.Problems{}}, } { t.Run(test.name, func(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message GetBookRequest { string {{.FieldName}} = 1; } diff --git a/rules/aep0131/request_path_reference_type.go b/rules/aep0131/request_path_reference_type.go index 9f70cd0..2d6fad7 100644 --- a/rules/aep0131/request_path_reference_type.go +++ b/rules/aep0131/request_path_reference_type.go @@ -30,7 +30,7 @@ var requestPathReferenceType = &lint.FieldRule{ LintField: func(f *desc.FieldDescriptor) []lint.Problem { if ref := utils.GetResourceReference(f); ref.GetType() == "" { return []lint.Problem{{ - Message: fmt.Sprintf("The `%s` field `google.api.resource_reference` annotation should be a direct `type` reference.", f.GetName()), + Message: fmt.Sprintf("The `%s` field `(aep.api.field_info).resource_reference` annotation should be a direct `type` reference.", f.GetName()), Descriptor: f, }} } diff --git a/rules/aep0131/request_path_reference_type_test.go b/rules/aep0131/request_path_reference_type_test.go index 632c400..deb979a 100644 --- a/rules/aep0131/request_path_reference_type_test.go +++ b/rules/aep0131/request_path_reference_type_test.go @@ -22,18 +22,19 @@ import ( func TestRequestNameReferenceType(t *testing.T) { for _, test := range []struct { - testName string - Reference string - problems testutils.Problems + testName string + Annotation string + problems testutils.Problems }{ - {"Valid", "type", nil}, - {"Invalid", "child_type", testutils.Problems{{Message: "should be a direct"}}}, + {"Valid", `[(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]`, nil}, + {"Invalid", `[(aep.api.field_info).resource_reference = ""]`, testutils.Problems{{Message: "should be a direct"}}}, } { t.Run(test.testName, func(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message GetBookRequest { - string path = 1 [(google.api.resource_reference).{{.Reference}} = "library.googleapis.com/Book"]; + string path = 1 {{.Annotation}}; } `, test) field := f.GetMessageTypes()[0].GetFields()[0] diff --git a/rules/aep0131/request_required_fields_test.go b/rules/aep0131/request_required_fields_test.go index 44950e7..60490f6 100644 --- a/rules/aep0131/request_required_fields_test.go +++ b/rules/aep0131/request_required_fields_test.go @@ -77,9 +77,7 @@ func TestRequiredFieldTests(t *testing.T) { // Format: publishers/{publisher}/books/{book} string path = 1 [ (aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { - type: "library.googleapis.com/Book" - } + (aep.api.field_info).resource_reference = "library.googleapis.com/Book" ]; {{.Fields}} } diff --git a/rules/aep0132/request_parent_reference_test.go b/rules/aep0132/request_parent_reference_test.go index ae796e0..90d204f 100644 --- a/rules/aep0132/request_parent_reference_test.go +++ b/rules/aep0132/request_parent_reference_test.go @@ -24,10 +24,9 @@ func TestRequestParentReference(t *testing.T) { t.Run("Present", func(t *testing.T) { f := testutils.ParseProto3String(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message ListBooksRequest { - string parent = 1 [(google.api.resource_reference) = { - type: "library.googleapis.com/Publisher" - }]; + string parent = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Publisher"]; } `) if diff := (testutils.Problems{}).Diff(requestParentReference.Lint(f)); diff != "" { @@ -40,12 +39,13 @@ func TestRequestParentReference(t *testing.T) { FieldName string problems testutils.Problems }{ - {"Error", "parent", testutils.Problems{{Message: "google.api.resource_reference"}}}, + {"Error", "parent", testutils.Problems{{Message: "(aep.api.field_info).resource_reference"}}}, {"Irrelevant", "something_else", testutils.Problems{}}, } { t.Run(test.name, func(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message ListBooksRequest { string {{.FieldName}} = 1; } diff --git a/rules/aep0132/request_parent_valid_reference.go b/rules/aep0132/request_parent_valid_reference.go index 263eca1..497a1f7 100644 --- a/rules/aep0132/request_parent_valid_reference.go +++ b/rules/aep0132/request_parent_valid_reference.go @@ -49,7 +49,7 @@ var requestParentValidReference = &lint.FieldRule{ if r := utils.GetResource(typ); r != nil && r.GetType() == res { return []lint.Problem{{ - Message: fmt.Sprintf("The `google.api.resource_reference` on `%s` field should reference the parent(s) of `%s`.", f.GetName(), res), + Message: fmt.Sprintf("The `(aep.api.field_info).resource_reference` on `%s` field should reference the parent(s) of `%s`.", f.GetName(), res), Descriptor: f, Location: locations.FieldResourceReference(f), }} diff --git a/rules/aep0132/request_parent_valid_reference_test.go b/rules/aep0132/request_parent_valid_reference_test.go index 515219d..7eb5e51 100644 --- a/rules/aep0132/request_parent_valid_reference_test.go +++ b/rules/aep0132/request_parent_valid_reference_test.go @@ -26,16 +26,14 @@ func TestRequestParentValidReference(t *testing.T) { ReferenceType string problems testutils.Problems }{ - {"Valid", "type: \"library.googleapis.com/Publisher\"", testutils.Problems{}}, - {"Invalid", "type: \"library.googleapis.com/Book\"", testutils.Problems{{Message: "reference the parent(s)"}}}, - {"IgnoreChildType", "child_type: \"library.googleapis.com/Book\"", testutils.Problems{}}, + {"Valid", "library.googleapis.com/Publisher", testutils.Problems{}}, + {"Invalid", "library.googleapis.com/Book", testutils.Problems{{Message: "reference the parent(s)"}}}, } { f := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message ListBooksRequest { - string parent = 1 [(google.api.resource_reference) = { - {{.ReferenceType}} - }]; + string parent = 1 [(aep.api.field_info).resource_reference = "{{.ReferenceType}}"]; } message ListBooksResponse { diff --git a/rules/aep0132/request_required_fields_test.go b/rules/aep0132/request_required_fields_test.go index cab1f13..fdd4f1b 100644 --- a/rules/aep0132/request_required_fields_test.go +++ b/rules/aep0132/request_required_fields_test.go @@ -76,9 +76,7 @@ func TestRequiredFieldTests(t *testing.T) { // Format: publishers/{publisher} string parent = 1 [ (aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED, - (google.api.resource_reference) = { - child_type: "library.googleapis.com/Book" - }]; + (aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; {{.Fields}} } diff --git a/rules/aep0132/resource_reference_type.go b/rules/aep0132/resource_reference_type.go index 0a65f71..57c98bd 100644 --- a/rules/aep0132/resource_reference_type.go +++ b/rules/aep0132/resource_reference_type.go @@ -45,19 +45,30 @@ var resourceReferenceType = &lint.MethodRule{ parent := m.GetInputType().FindFieldByName("parent") ref := utils.GetResourceReference(parent) - if resource.GetType() == ref.GetType() { - return []lint.Problem{{ - Message: "List should use a `child_type` reference to the paginated resource, not a `type` reference.", - Descriptor: parent, - Location: locations.FieldResourceReference(parent), - }} - } - if ref.GetChildType() != "" && resource.GetType() != ref.GetChildType() { - return []lint.Problem{{ - Message: "List should use a `child_type` reference to the paginated resource.", - Descriptor: parent, - Location: locations.FieldResourceReference(parent), - }} + // In AEP format, resource_reference is just a string. When used in List methods, + // it should match the child resource type. The old Google API format distinguishes + // between `type` and `child_type`, but AEP format just uses the string value. + // If child_type is set (Google API format), check it. Otherwise, check the type field + // and treat it as an implicit child_type reference. + if ref.GetChildType() != "" { + // Google API format with explicit child_type + if resource.GetType() != ref.GetChildType() { + return []lint.Problem{{ + Message: "List should use a `child_type` reference to the paginated resource.", + Descriptor: parent, + Location: locations.FieldResourceReference(parent), + }} + } + } else if ref.GetType() != "" { + // AEP format or Google API format with only type set + // In AEP format, this should match the child resource type + if resource.GetType() != ref.GetType() { + return []lint.Problem{{ + Message: "List should use a `child_type` reference to the paginated resource.", + Descriptor: parent, + Location: locations.FieldResourceReference(parent), + }} + } } return nil diff --git a/rules/aep0132/resource_reference_type_test.go b/rules/aep0132/resource_reference_type_test.go index 8a7eb8e..293c563 100644 --- a/rules/aep0132/resource_reference_type_test.go +++ b/rules/aep0132/resource_reference_type_test.go @@ -30,17 +30,14 @@ option (google.api.resource) = { // Set up testing permutations. tests := []struct { - testName string - TypeName string - RefType string + testName string + TypeName string ResourceAnnotation string problems testutils.Problems }{ - {"ValidChildType", "library.googleapis.com/Book", "child_type", bookResource, nil}, - {"ValidType", "library.googleapis.com/Shelf", "type", bookResource, nil}, - {"InvalidType", "library.googleapis.com/Book", "type", bookResource, testutils.Problems{{Message: "not a `type`"}}}, - {"InvalidChildType", "library.googleapis.com/Shelf", "child_type", bookResource, testutils.Problems{{Message: "`child_type`"}}}, - {"SkipNonResource", "library.googleapis.com/Book", "child_type", "", nil}, + {"ValidMatch", "library.googleapis.com/Book", bookResource, nil}, + {"InvalidMismatch", "library.googleapis.com/Shelf", bookResource, testutils.Problems{{Message: "`child_type`"}}}, + {"SkipNoResource", "library.googleapis.com/Book", "", nil}, } // Run each test. @@ -48,11 +45,12 @@ option (google.api.resource) = { t.Run(test.testName, func(t *testing.T) { file := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; service Library { rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {} } message ListBooksRequest { - string parent = 1 [(google.api.resource_reference).{{ .RefType }} = "{{ .TypeName }}"]; + string parent = 1 [(aep.api.field_info).resource_reference = "{{ .TypeName }}"]; } message ListBooksResponse { repeated string unreachable = 2; diff --git a/rules/aep0133/resource_reference_type.go b/rules/aep0133/resource_reference_type.go index 79a8dbc..bbe188d 100644 --- a/rules/aep0133/resource_reference_type.go +++ b/rules/aep0133/resource_reference_type.go @@ -40,19 +40,30 @@ var resourceReferenceType = &lint.MethodRule{ parent := m.GetInputType().FindFieldByName("parent") ref := utils.GetResourceReference(parent) - if resource.GetType() == ref.GetType() { - return []lint.Problem{{ - Message: "Create should use a `child_type` reference to the created resource, not a `type` reference.", - Descriptor: parent, - Location: locations.FieldResourceReference(parent), - }} - } - if ref.GetChildType() != "" && resource.GetType() != ref.GetChildType() { - return []lint.Problem{{ - Message: "Create should use a `child_type` reference to the created resource.", - Descriptor: parent, - Location: locations.FieldResourceReference(parent), - }} + // In AEP format, resource_reference is just a string. When used in Create methods, + // it should match the created resource type. The old Google API format distinguishes + // between `type` and `child_type`, but AEP format just uses the string value. + // If child_type is set (Google API format), check it. Otherwise, check the type field + // and treat it as an implicit child_type reference. + if ref.GetChildType() != "" { + // Google API format with explicit child_type + if resource.GetType() != ref.GetChildType() { + return []lint.Problem{{ + Message: "Create should use a `child_type` reference to the created resource.", + Descriptor: parent, + Location: locations.FieldResourceReference(parent), + }} + } + } else if ref.GetType() != "" { + // AEP format or Google API format with only type set + // In AEP format, this should match the created resource type + if resource.GetType() != ref.GetType() { + return []lint.Problem{{ + Message: "Create should use a `child_type` reference to the created resource.", + Descriptor: parent, + Location: locations.FieldResourceReference(parent), + }} + } } return nil diff --git a/rules/aep0133/resource_reference_type_test.go b/rules/aep0133/resource_reference_type_test.go index 8ced36e..c1dcdff 100644 --- a/rules/aep0133/resource_reference_type_test.go +++ b/rules/aep0133/resource_reference_type_test.go @@ -25,13 +25,10 @@ func TestResourceReferenceType(t *testing.T) { tests := []struct { testName string TypeName string - RefType string problems testutils.Problems }{ - {"ValidChildType", "library.googleapis.com/Book", "child_type", nil}, - {"ValidType", "library.googleapis.com/Shelf", "type", nil}, - {"InvalidType", "library.googleapis.com/Book", "type", testutils.Problems{{Message: "not a `type`"}}}, - {"InvalidChildType", "library.googleapis.com/Shelf", "child_type", testutils.Problems{{Message: "`child_type`"}}}, + {"ValidMatch", "library.googleapis.com/Book", nil}, + {"InvalidMismatch", "library.googleapis.com/Shelf", testutils.Problems{{Message: "`child_type`"}}}, } // Run each test. @@ -39,12 +36,13 @@ func TestResourceReferenceType(t *testing.T) { t.Run(test.testName, func(t *testing.T) { file := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; import "google/longrunning/operations.proto"; service Library { rpc CreateBook(CreateBookRequest) returns (Book) {} } message CreateBookRequest { - string parent = 1 [(google.api.resource_reference).{{ .RefType }} = "{{ .TypeName }}"]; + string parent = 1 [(aep.api.field_info).resource_reference = "{{ .TypeName }}"]; } message Book { option (google.api.resource) = { @@ -68,16 +66,12 @@ func TestResourceReferenceTypeLRO(t *testing.T) { tests := []struct { testName string TypeName string - RefType string ResponseType string problems testutils.Problems }{ - {"ValidChildType", "library.googleapis.com/Book", "child_type", "Book", nil}, - {"ValidChildTypeLRO", "library.googleapis.com/Book", "child_type", "Book", nil}, - {"ValidType", "library.googleapis.com/Shelf", "type", "Book", nil}, - {"InvalidType", "library.googleapis.com/Book", "type", "Book", testutils.Problems{{Message: "not a `type`"}}}, - {"InvalidChildType", "library.googleapis.com/Shelf", "child_type", "Book", testutils.Problems{{Message: "`child_type`"}}}, - {"SkipInvalidUnresolvableResponseType", "library.googleapis.com/Shelf", "child_type", "Foo", nil}, + {"ValidMatch", "library.googleapis.com/Book", "Book", nil}, + {"InvalidMismatch", "library.googleapis.com/Shelf", "Book", testutils.Problems{{Message: "`child_type`"}}}, + {"SkipUnresolvableResponse", "library.googleapis.com/Shelf", "Foo", nil}, } // Run each test. @@ -85,6 +79,7 @@ func TestResourceReferenceTypeLRO(t *testing.T) { t.Run(test.testName, func(t *testing.T) { file := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; import "google/longrunning/operations.proto"; service Library { rpc CreateBook(CreateBookRequest) returns (google.longrunning.Operation) { @@ -95,7 +90,7 @@ func TestResourceReferenceTypeLRO(t *testing.T) { } } message CreateBookRequest { - string parent = 1 [(google.api.resource_reference).{{ .RefType }} = "{{ .TypeName }}"]; + string parent = 1 [(aep.api.field_info).resource_reference = "{{ .TypeName }}"]; } message Book { option (google.api.resource) = { diff --git a/rules/aep0135/force_field_test.go b/rules/aep0135/force_field_test.go index 9d9275e..604a5ad 100644 --- a/rules/aep0135/force_field_test.go +++ b/rules/aep0135/force_field_test.go @@ -27,16 +27,16 @@ func TestForceField(t *testing.T) { BoolField string problems testutils.Problems }{ - {"ValidWithChildren", `.type = "library.googleapis.com/Publisher"`, "force", nil}, - {"ValidWithoutChildren", `.type = "library.googleapis.com/Book"`, "other", nil}, - {"SkipIncorrectChildTypeReference", `.child_type = "library.googleapis.com/Publisher"`, "other", nil}, - {"InvalidMissingForce", `.type = "library.googleapis.com/Publisher"`, "other", testutils.Problems{{Message: "bool force"}}}, + {"ValidWithChildren", "library.googleapis.com/Publisher", "force", nil}, + {"ValidWithoutChildren", "library.googleapis.com/Book", "other", nil}, + {"InvalidMissingForce", "library.googleapis.com/Publisher", "other", testutils.Problems{{Message: "bool force"}}}, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message Book { option (google.api.resource) = { @@ -57,7 +57,7 @@ func TestForceField(t *testing.T) { } message DeleteResourceRequest { - string path = 1 [(google.api.resource_reference){{.Reference}}]; + string path = 1 [(aep.api.field_info).resource_reference = "{{.Reference}}"]; bool {{.BoolField}} = 2; } diff --git a/rules/aep0135/request_path_reference_test.go b/rules/aep0135/request_path_reference_test.go index 98bd6a5..91425ed 100644 --- a/rules/aep0135/request_path_reference_test.go +++ b/rules/aep0135/request_path_reference_test.go @@ -24,10 +24,9 @@ func TestRequestNameReference(t *testing.T) { t.Run("Present", func(t *testing.T) { f := testutils.ParseProto3String(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message DeleteBookRequest { - string path = 1 [(google.api.resource_reference) = { - type: "library.googleapis.com/Book" - }]; + string path = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; } `) if diff := (testutils.Problems{}).Diff(requestPathReference.Lint(f)); diff != "" { @@ -40,12 +39,13 @@ func TestRequestNameReference(t *testing.T) { FieldName string problems testutils.Problems }{ - {"Error", "path", testutils.Problems{{Message: "google.api.resource_reference"}}}, + {"Error", "path", testutils.Problems{{Message: "(aep.api.field_info).resource_reference"}}}, {"Irrelevant", "something_else", testutils.Problems{}}, } { t.Run(test.name, func(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message DeleteBookRequest { string {{.FieldName}} = 1; } diff --git a/rules/aep0164/request_name_reference_test.go b/rules/aep0164/request_name_reference_test.go index d99c793..d6e7e33 100644 --- a/rules/aep0164/request_name_reference_test.go +++ b/rules/aep0164/request_name_reference_test.go @@ -24,10 +24,9 @@ func TestRequestNameReference(t *testing.T) { t.Run("Present", func(t *testing.T) { f := testutils.ParseProto3String(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message UndeleteBookRequest { - string name = 1 [(google.api.resource_reference) = { - type: "library.googleapis.com/Book" - }]; + string name = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; } `) if diff := (testutils.Problems{}).Diff(requestNameReference.Lint(f)); diff != "" { @@ -40,12 +39,13 @@ func TestRequestNameReference(t *testing.T) { FieldName string problems testutils.Problems }{ - {"Error", "name", testutils.Problems{{Message: "google.api.resource_reference"}}}, + {"Error", "name", testutils.Problems{{Message: "(aep.api.field_info).resource_reference"}}}, {"Irrelevant", "something_else", testutils.Problems{}}, } { t.Run(test.name, func(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message UndeleteBookRequest { string {{.FieldName}} = 1; } diff --git a/rules/internal/utils/common_lints.go b/rules/internal/utils/common_lints.go index c28b4b5..fd85fd5 100644 --- a/rules/internal/utils/common_lints.go +++ b/rules/internal/utils/common_lints.go @@ -118,7 +118,7 @@ func LintOutputOnlyField(f *desc.FieldDescriptor) []lint.Problem { func LintFieldResourceReference(f *desc.FieldDescriptor) []lint.Problem { if ref := GetResourceReference(f); ref == nil { return []lint.Problem{{ - Message: fmt.Sprintf("The `%s` field should include a `google.api.resource_reference` annotation.", f.GetName()), + Message: fmt.Sprintf("The `%s` field should include a `(aep.api.field_info).resource_reference` annotation.", f.GetName()), Descriptor: f, }} } diff --git a/rules/internal/utils/common_lints_test.go b/rules/internal/utils/common_lints_test.go index 6204375..c17cdd4 100644 --- a/rules/internal/utils/common_lints_test.go +++ b/rules/internal/utils/common_lints_test.go @@ -63,12 +63,13 @@ func TestLintFieldResourceReference(t *testing.T) { Annotation string problems testutils.Problems }{ - {"Valid", `[(google.api.resource_reference).type = "bar"]`, nil}, + {"Valid", `[(aep.api.field_info).resource_reference = "bar"]`, nil}, {"Invalid", ``, testutils.Problems{{Message: "resource_reference"}}}, } { t.Run(test.testName, func(t *testing.T) { f := testutils.ParseProto3Tmpl(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message Message { string foo = 1 {{.Annotation}}; } diff --git a/rules/internal/utils/extension.go b/rules/internal/utils/extension.go index 6a0b5b9..c3663c7 100644 --- a/rules/internal/utils/extension.go +++ b/rules/internal/utils/extension.go @@ -194,16 +194,11 @@ func GetResourceDefinitions(f *desc.FileDescriptor) []*apb.ResourceDescriptor { return nil } -// HasResourceReference returns if the field has a google.api.resource_reference or -// aep.api.field_info.resource_reference annotation. +// HasResourceReference returns if the field has a aep.api.field_info.resource_reference annotation. func HasResourceReference(f *desc.FieldDescriptor) bool { if f == nil { return false } - // Check google.api.resource_reference - if proto.HasExtension(f.GetFieldOptions(), apb.E_ResourceReference) { - return true - } // Check aep.api.field_info.resource_reference if x := proto.GetExtension(f.GetFieldOptions(), aepapi.E_FieldInfo); x != nil { fieldInfo := x.(*aepapi.FieldInfo) @@ -212,28 +207,21 @@ func HasResourceReference(f *desc.FieldDescriptor) bool { return false } -// GetResourceReference returns the google.api.resource_reference annotation. -// If the google.api annotation is not present, it checks for aep.api.field_info.resource_reference -// and converts it to the google.api format. +// GetResourceReference returns the aep.api.field_info.resource_reference annotation. func GetResourceReference(f *desc.FieldDescriptor) *apb.ResourceReference { if f == nil { return nil } opts := f.GetFieldOptions() - // Check google.api.resource_reference first - if x := proto.GetExtension(opts, apb.E_ResourceReference); x != nil { - return x.(*apb.ResourceReference) - } - // Check aep.api.field_info.resource_reference if x := proto.GetExtension(opts, aepapi.E_FieldInfo); x != nil { fieldInfo := x.(*aepapi.FieldInfo) resourceRefs := fieldInfo.GetResourceReference() if len(resourceRefs) > 0 { - // Convert aep.api.FieldInfo.resource_reference to google.api.ResourceReference - // Note: aep.api supports multiple resource references, but google.api only supports one - // For compatibility, we'll use the first one and set child_type for additional ones + // Convert aep.api.FieldInfo.resource_reference to google.api.ResourceReference for internal use + // Note: aep.api supports multiple resource references, but we only support one + // For compatibility, we'll use the first one ref := &apb.ResourceReference{} if resourceRefs[0] == "*" { ref.Type = "*" @@ -250,7 +238,7 @@ func GetResourceReference(f *desc.FieldDescriptor) *apb.ResourceReference { // FindResource returns first resource of type matching the reference param. // resource Type name being referenced. It looks within a given file and its // depenedencies, it cannot search within the entire protobuf package. -// This is especially useful for resolving google.api.resource_reference +// This is especially useful for resolving aep.api.field_info.resource_reference // annotations. func FindResource(reference string, file *desc.FileDescriptor) *apb.ResourceDescriptor { m := FindResourceMessage(reference, file) @@ -261,7 +249,7 @@ func FindResource(reference string, file *desc.FileDescriptor) *apb.ResourceDesc // matching the resource Type name being referenced. It looks within a given // file and its depenedencies, it cannot search within the entire protobuf // package. This is especially useful for resolving -// google.api.resource_reference annotations to the message that owns a +// aep.api.field_info.resource_reference annotations to the message that owns a // resource. func FindResourceMessage(reference string, file *desc.FileDescriptor) *desc.MessageDescriptor { files := append(file.GetDependencies(), file) diff --git a/rules/internal/utils/extension_test.go b/rules/internal/utils/extension_test.go index 3ed901e..aaa01b3 100644 --- a/rules/internal/utils/extension_test.go +++ b/rules/internal/utils/extension_test.go @@ -296,10 +296,9 @@ func TestGetResourceReference(t *testing.T) { t.Run("Present", func(t *testing.T) { f := testutils.ParseProto3String(t, ` import "google/api/resource.proto"; + import "aep/api/field_info.proto"; message GetBookRequest { - string name = 1 [(google.api.resource_reference) = { - type: "library.googleapis.com/Book" - }]; + string name = 1 [(aep.api.field_info).resource_reference = "library.googleapis.com/Book"]; } `) ref := GetResourceReference(f.GetMessageTypes()[0].GetFields()[0])