Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 8 additions & 8 deletions docs/rules/0004/duplicate-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ redirect_from:
# Resource annotation presence

This rule enforces that the same resource type doesn't appear in more than one
`google.api.resource` annotation, as described in [AEP-004][].
`aep.api.resource` annotation, as described in [AEP-004][].

## Details

This rule complains about messages that have the same `type` for the
`google.api.resource` annotation, which frequently occur due to copy-paste
`aep.api.resource` annotation, which frequently occur due to copy-paste
errors and messages spread across multiple files and/or packages. Duplicate
resource definitions can cause compilation problems in generated client code.

Expand All @@ -26,7 +26,7 @@ resource definitions can cause compilation problems in generated client code.

```proto
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -35,7 +35,7 @@ message Book {
}

message Author {
option (google.api.resource) = {
option (aep.api.resource) = {
// Incorrect: should be "library.googleapis.com/Author".
type: "library.googleapis.com/Book"
pattern: "authors/{author}"
Expand All @@ -50,7 +50,7 @@ message Author {
```proto
// Correct.
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -59,7 +59,7 @@ message Book {
}

message Author {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Author"
pattern: "authors/{author}"
};
Expand All @@ -79,7 +79,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why.
syntax = "proto3";

message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -88,7 +88,7 @@ message Book {
}

message Author {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "authors/{author}"
};
Expand Down
8 changes: 4 additions & 4 deletions docs/rules/0004/path-never-optional.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ proto3_optional.

## Details

This rule scans for messages with a `google.api.resource` annotation and ensures
This rule scans for messages with a `aep.api.resource` annotation and ensures
that the configured path field (either `path` or whichever field specified via
`path_field`) is not labeled as `optional`.

Expand All @@ -26,7 +26,7 @@ that the configured path field (either `path` or whichever field specified via
```proto
// Incorrect.
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -41,7 +41,7 @@ message Book {
```proto
// Correct.
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -58,7 +58,7 @@ If you need to violate this rule, use a leading comment above the message.
// (-- api-linter: core::04::path-never-optional=disabled
// aep.dev/not-precedent: We need to do this because reasons. --)
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand Down
10 changes: 5 additions & 5 deletions docs/rules/0004/resource-annotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
rule:
aep: 4
name: [core, '4', resource-annotation]
summary: Resource messages should be annotated with `google.api.resource`.
summary: Resource messages should be annotated with `aep.api.resource`.
permalink: /4/resource-annotation
redirect_from:
- /4/resource-annotation
Expand All @@ -11,13 +11,13 @@ redirect_from:
# Resource annotation presence

This rule enforces that top-level messages that appear to represent resources
have a `google.api.resource` annotation, as described in [AEP-4][].
have a `aep.api.resource` annotation, as described in [AEP-4][].

## Details

This rule scans all top-level messages, and assumes that messages with a
`string path` field are resources unless the message name ends with `Request`.
For messages that are resources, it complains if the `google.api.resource`
For messages that are resources, it complains if the `aep.api.resource`
annotation is missing.

## Examples
Expand All @@ -27,7 +27,7 @@ annotation is missing.
```proto
// Incorrect.
message Book {
// A `google.api.resource` annotation should be here.
// A `aep.api.resource` annotation should be here.
string path = 1;
}
```
Expand All @@ -37,7 +37,7 @@ message Book {
```proto
// Correct.
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand Down
14 changes: 7 additions & 7 deletions docs/rules/0004/resource-definition-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ redirect_from:
# Resource patterns

This rule enforces that files that define a resource with the
`google.api.resource_definition` annotation have a `pattern` defined, as
`aep.api.resource_definition` annotation have a `pattern` defined, as
described in [AEP-123][].

## Details

This rule scans all `google.api.resource_definition` annotations in all files,
This rule scans all `aep.api.resource_definition` annotations in all files,
and complains if `pattern` is not provided at least once. It also complains if
the segments outside of variable names contain underscores.

Expand All @@ -28,7 +28,7 @@ the segments outside of variable names contain underscores.
import "google/api/resources.proto";

// Incorrect.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/Book"
// pattern should be here
};
Expand All @@ -38,7 +38,7 @@ option (google.api.resource_definition) = {
import "google/api/resources.proto";

// Incorrect.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/ElectronicBook"
// Should be: publishers/{publisher}/electronicBooks/{electronic_book}
pattern: "publishers/{publisher}/electronic_books/{electronic_book}"
Expand All @@ -51,7 +51,7 @@ option (google.api.resource_definition) = {
import "google/api/resources.proto";

// Correct.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -61,7 +61,7 @@ option (google.api.resource_definition) = {
import "google/api/resource.proto";

// Correct.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/ElectronicBook"
pattern: "publishers/{publisher}/electronicBooks/{electronic_book}"
};
Expand All @@ -76,7 +76,7 @@ import "google/api/resource.proto";

// (-- api-linter: core::0123::resource-definition-pattern=disabled
// aep.dev/not-precedent: We need to do this because reasons. --)
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/Book"
};
```
Expand Down
10 changes: 5 additions & 5 deletions docs/rules/0004/resource-definition-type-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ redirect_from:
# Resource type name

This rule enforces that files that define a resource with the
`google.api.resource_definition` annotation have a properly formatted `type`, as
`aep.api.resource_definition` annotation have a properly formatted `type`, as
described in [AEP-123][].

## Details

This rule scans files with `google.api.resource_definition` annotations, and
This rule scans files with `aep.api.resource_definition` annotations, and
validates the format of the `type` field conforms to `{Service Name}/{Type}`.

## Examples
Expand All @@ -27,7 +27,7 @@ validates the format of the `type` field conforms to `{Service Name}/{Type}`.
import "google/api/resource.proto";

// Incorrect.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
// Should not have more than one separating '/'.
type: "library.googleapis.com/Genre/Mystery/Book"
pattern: "publishers/{publisher}/books/{book}"
Expand All @@ -40,7 +40,7 @@ option (google.api.resource_definition) = {
import "google/api/resource.proto";

// Correct.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -55,7 +55,7 @@ import "google/api/resource.proto";

// (-- api-linter: core::0123::resource-definition-type-name=disabled
// aep.dev/not-precedent: We need to do this because reasons. --)
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/Genre/Mystery/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand Down
12 changes: 6 additions & 6 deletions docs/rules/0004/resource-definition-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ conventions, as described in [AEP-4][].

## Details

This rule scans all files with `google.api.resource_definition` annotations, and
This rule scans all files with `aep.api.resource_definition` annotations, and
complains if variables in a `pattern` use camel case, or end in `_id`.

## Examples
Expand All @@ -26,7 +26,7 @@ complains if variables in a `pattern` use camel case, or end in `_id`.
import "google/api/resource.proto";

// Incorrect.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/Book"
// Should be: publishers/{publisher}/books/{book}
pattern: "publishers/{publisher_id}/books/{book_id}"
Expand All @@ -37,7 +37,7 @@ option (google.api.resource_definition) = {
import "google/api/resource.proto";

// Incorrect.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/ElectronicBook"
// Should be: publishers/{publisher}/electronicBooks/{electronic_book}
pattern: "publishers/{publisher}/electronicBooks/{electronicBook}"
Expand All @@ -50,7 +50,7 @@ option (google.api.resource_definition) = {
import "google/api/resource.proto";

// Correct.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -60,7 +60,7 @@ option (google.api.resource_definition) = {
import "google/api/resource.proto";

// Correct.
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/ElectronicBook"
pattern: "publishers/{publisher}/electronicBooks/{electronic_book}"
};
Expand All @@ -75,7 +75,7 @@ import "google/api/resource.proto";

// (-- api-linter: core::4::resource-definition-variables=disabled
// aep.dev/not-precedent: We need to do this because reasons. --)
option (google.api.resource_definition) = {
option (aep.api.resource_definition) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher_id}/books/{book_id}"
};
Expand Down
10 changes: 5 additions & 5 deletions docs/rules/0004/resource-name-components-alternate.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ redirect_from:

# Resource name components alternate

This rule enforces that messages that have a `google.api.resource` annotation
This rule enforces that messages that have a `aep.api.resource` annotation
have `pattern` annotations that alternate between collection and identifier, as
described in [AEP-4][].

## Details

This rule scans messages with a `google.api.resource` annotation, and validates
This rule scans messages with a `aep.api.resource` annotation, and validates
that each `pattern` alternated between collection and identifiers.

## Examples
Expand All @@ -28,7 +28,7 @@ that each `pattern` alternated between collection and identifiers.
```proto
// Incorrect.
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
// two collections next to each other.
pattern: "publishers/books/{book}"
Expand All @@ -42,7 +42,7 @@ message Book {
```proto
// Correct.
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -58,7 +58,7 @@ If you need to violate this rule, use a leading comment above the message.
// (-- api-linter: core::4::resource-name-components-alternate=disabled
// aep.dev/not-precedent: We need to do this because reasons. --)
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/books/{book}"
};
Expand Down
10 changes: 5 additions & 5 deletions docs/rules/0004/resource-path-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This rule enforces that messages that appear to represent resources have a

## Details

This rule scans all messages that have a `google.api.resource` annotation, and
This rule scans all messages that have a `aep.api.resource` annotation, and
complains if the `path` field is missing or if it is any type other than
singular `string`.

Expand All @@ -26,7 +26,7 @@ singular `string`.
```proto
// Incorrect: missing `string path` field.
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -36,7 +36,7 @@ message Book {
```proto
// Incorrect.
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -51,7 +51,7 @@ message Book {
```proto
// Correct.
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand All @@ -69,7 +69,7 @@ above the field if it is the wrong type.
// (-- api-linter: core::4::resource-path-field=disabled
// aep.dev/not-precedent: We need to do this because reasons. --)
message Book {
option (google.api.resource) = {
option (aep.api.resource) = {
type: "library.googleapis.com/Book"
pattern: "publishers/{publisher}/books/{book}"
};
Expand Down
Loading
Loading