Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/rules/0004/resource-reference-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -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"
}];
}
Expand All @@ -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"
}];
}
Expand Down
12 changes: 6 additions & 6 deletions docs/rules/0121/no-mutable-cycles.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
}

Expand All @@ -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"
];
}
```
Expand All @@ -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"
];
}

Expand All @@ -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
];
}
Expand All @@ -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"
];
}

Expand All @@ -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"
];
}
```
Expand Down
10 changes: 5 additions & 5 deletions docs/rules/0122/resource-reference-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}];
}
Expand All @@ -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"
}];
}
Expand Down Expand Up @@ -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"
}];
}
Expand Down
8 changes: 4 additions & 4 deletions docs/rules/0124/reference-same-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
}];
}
Expand All @@ -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"
}];
}
Expand Down Expand Up @@ -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"
}];
}
Expand Down
4 changes: 2 additions & 2 deletions docs/rules/0127/http-template-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions docs/rules/0131/request-path-behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}];
}
Expand All @@ -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"
];
}
```
Expand All @@ -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"
}];
}
Expand Down
14 changes: 7 additions & 7 deletions docs/rules/0131/request-path-reference-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.

Expand All @@ -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"
];
}
```
Expand All @@ -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"
];
}
```
Expand All @@ -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"
];
}
```
Expand Down
10 changes: 5 additions & 5 deletions docs/rules/0131/request-path-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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];
}
```
Expand All @@ -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"
];
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/rules/0131/request-path-required.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
}
```
Expand All @@ -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"
];
}
```
Expand All @@ -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"
];
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/rules/0131/request-required-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}];

Expand All @@ -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"
}];

Expand All @@ -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"
}];

Expand Down
6 changes: 3 additions & 3 deletions docs/rules/0132/request-parent-behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Loading