Skip to content

Commit 0bf652b

Browse files
committed
feat(field_info): use aep.api.field_info
With new aep.api.field_info annotations, we should use those rather than google.api.resource_reference and google.api.field_behavior.
1 parent edac165 commit 0bf652b

File tree

19 files changed

+204
-175
lines changed

19 files changed

+204
-175
lines changed

aep/general/0122/aep.md.j2

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,16 @@ When defining a method that retrieves or acts on an already-existing resource
214214
(such as `GetBook` or `ArchiveBook`), the first field of the request message
215215
**should** be the resource path, which **must** be of type `string` and
216216
**must** be called `path` for the resource path. The field **should** also be
217-
annotated with the `google.api.resource_reference` annotation, referencing the
218-
resource type (AEP-4).
217+
annotated with `api.api.field_info`, referencing the resource type (AEP-4).
219218

220219
```proto
221220
// Request message for ArchiveBook
222221
message ArchiveBookRequest {
223222
// The book to archive.
224223
// Format: publishers/{publisher_id}/books/{book_id}
225224
string path = 1 [
226-
(google.api.field_behavior) = REQUIRED,
227-
(google.api.resource_reference) = {
228-
type: "apis.example.com/library/Book"
229-
}];
225+
(aep.api.field_info) = { resource_reference: [ "apis.example.com/library/Book" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }
226+
];
230227

231228
// Other fields...
232229
}
@@ -242,25 +239,23 @@ When defining a method that retrieves resources from a collection or adds a new
242239
resource to a collection (such as `ListBooks` or `CreateBook`), the first field
243240
of the request message **should** be of type `string` and **should** be called
244241
`parent` for the resource path of the collection. The `parent` field **should**
245-
also be annotated with the `google.api.resource_reference` annotation,
246-
referencing the parent's resource type (AEP-4).
242+
also be annotated with `api.api.field_info`, referencing the parent's resource
243+
type (AEP-4).
247244

248245
```proto
249246
// Request message for ListBooks.
250247
message ListBooksRequest {
251248
// The publisher to list books from.
252249
// Format: publishers/{publisher_id}
253-
string parent = 1 [(google.api.resource_reference) = {
254-
type: "apis.example.com/library/Publisher"
255-
}];
250+
string parent = 1 [(aep.api.field_info) = { resource_reference: [ "apis.example.com/library/Publisher" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }];
256251

257252
// Other fields (e.g. max_page_size, page_token, filter, etc.)...
258253
}
259254
```
260255

261256
If there is more than one possible parent type, the `parent` field **should**
262-
be annotated with the `child_type` key on `google.api.resource_reference`
263-
instead:
257+
be annotated with multiple `resource_reference` types using
258+
`aep.api.field_info`:
264259

265260
```proto
266261
// Request message for ListBooks.
@@ -270,10 +265,8 @@ message ListBooksRequest {
270265
// - publishers/{publisher_id}
271266
// - authors/{author_id}
272267
string parent = 1 [
273-
(google.api.field_behavior) = REQUIRED,
274-
(google.api.resource_reference) = {
275-
child_type: "apis.example.com/library/Book"
276-
}];
268+
(aep.api.field_info) = { resource_reference: [ "apis.example.com/library/Book" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }
269+
];
277270

278271
// Other fields (e.g. max_page_size, page_token, filter, etc.)...
279272
}
@@ -298,8 +291,7 @@ When referencing a resource path for a different resource:
298291
- Field names **should not** use the `_path` suffix unless the field would be
299292
ambiguous without it (e.g., `crypto_key_path`)
300293
- In protobuf, fields representing another resource **should** provide the
301-
`google.api.resource_reference` annotation with the resource type being
302-
referenced.
294+
`aep.api.field_info` annotation with the resource type being referenced.
303295

304296
```proto
305297
// A representation of a book in a library.
@@ -315,9 +307,7 @@ string path = 1;
315307

316308
// The shelf where the book currently sits.
317309
// Format is `shelves/{shelf}`.
318-
string shelf = 2 [(google.api.resource_reference) = {
319-
type: "apis.example.com/library/Shelf"
320-
}];
310+
string shelf = 2 [(aep.api.field_info) = { resource_reference: [ "apis.example.com/library/Shelf" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }];
321311

322312
// Other fields...
323313
}

aep/general/0124/embedded_resource.proto

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
syntax = "proto3";
22

3+
import "aep/api/field_info.proto";
34
import "google/api/resource.proto";
45

56
message Book {
@@ -16,13 +17,11 @@ message Book {
1617
// The resource path of the book's author.
1718
//
1819
// By default, only the `path` field of the author is populated.
19-
// However, the full author can be retrieved by specifying the
20+
// However, the full author can be retrieved by specifying the
2021
// FULL_WITH_AUTHOR view. This **will not** dereference resource
2122
// references within the author, such as `Author.pen_names`; only
2223
// the `path` subfield of these fields will be populated.
23-
Author author = 2 [(google.api.resource_reference) = {
24-
type: "library.googleapis.com/Author"
25-
}];
24+
Author author = 2 [(aep.api.field_info) = { resource_reference: [ "library.googleapis.com/Author" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }];
2625

2726
// Different views of a book.
2827
enum View {

aep/general/0124/many_to_many_repeated.proto

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
syntax = "proto3";
22

3+
import "aep/api/field_info.proto";
34
import "google/api/field_behavior.proto";
45
import "google/api/resource.proto";
56

@@ -12,7 +13,5 @@ message Book {
1213
string path = 1 [(google.api.field_behavior) = IDENTIFIER];
1314

1415
// The resource paths for the book's authors.
15-
repeated string authors = 2 [(google.api.resource_reference) = {
16-
type: "library.googleapis.com/Author"
17-
}];
16+
repeated string authors = 2 [(aep.api.field_info) = { resource_reference: [ "library.googleapis.com/Author" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }];
1817
}

aep/general/0124/many_to_many_subresource.proto

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
syntax = "proto3";
22

3+
import "aep/api/field_info.proto";
34
import "google/api/field_behavior.proto";
45
import "google/api/resource.proto";
56

@@ -15,9 +16,7 @@ message BookAuthor {
1516
string path = 1 [(google.api.field_behavior) = IDENTIFIER];
1617

1718
// The resource path for the author.
18-
string author = 2 [(google.api.resource_reference) = {
19-
type: "library.googleapis.com/Author"
20-
}];
19+
string author = 2 [(aep.api.field_info) = { resource_reference: [ "library.googleapis.com/Author" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }];
2120

2221
// Other fields...
2322
}

aep/general/0124/multiple_many_to_one.proto

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
syntax = "proto3";
22

3+
import "aep/api/field_info.proto";
34
import "google/api/resource.proto";
45

56
message Book {
@@ -14,7 +15,5 @@ message Book {
1415
string path = 1 [(google.api.field_behavior) = IDENTIFIER];
1516

1617
// The resource name for the book's author.
17-
string author = 2 [(google.api.resource_reference) = {
18-
type: "library.googleapis.com/Author"
19-
}];
18+
string author = 2 [(aep.api.field_info) = { resource_reference: [ "library.googleapis.com/Author" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }];
2019
}

aep/general/0127/aep.md.j2

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ message CreateBookRequest {
3333
// When using HTTP/JSON, this field is automatically populated based
3434
// on the URI, because of the `{parent=publishers/*}` syntax.
3535
string parent = 1 [
36-
(google.api.field_behavior) = REQUIRED,
37-
(google.api.resource_reference) = {
38-
child_type: "library.example.com/Book"
39-
}];
36+
(aep.api.field_info) = { resource_reference: [ "library.example.com/Book" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }
37+
];
4038

4139
// The book to create.
4240
// When using HTTP/JSON, this field is populated based on the HTTP body,

aep/general/0132/aep.md.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ collection's URI:
7777
top-level resource. It **should** be called `parent`.
7878
- The field **must** be [annotated as required][aep-203].
7979
- The field **must** identify the [resource type][] of the resource being
80-
listed with a `google.api.resource_reference` annotation.
80+
listed with a `aepi.api.field_info.resource_reference` annotation.
8181
- The field **must** accept the parent [path, _not_ the id](./0122)
8282
- The `max_page_size` and `page_token` fields, which support pagination,
8383
**must** be specified on all list request messages. For more information, see

aep/general/0135/aep.md.j2

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,8 @@ message DeletePublisherRequest {
134134
// The path of the publisher to delete.
135135
// Format: publishers/{publisher_id}
136136
string path = 1 [
137-
(google.api.field_behavior) = REQUIRED,
138-
(google.api.resource_reference) = {
139-
type: "library.example.com/Publisher"
140-
}];
137+
(aep.api.field_info) = { resource_reference: [ "library.example.com/Publisher" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }
138+
];
141139

142140
// If set to true, any books from this publisher will also be deleted.
143141
// (Otherwise, the request will only work if the publisher has no books.)

aep/general/0136/library.proto

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
syntax = "proto3";
1616

17+
import "aep/api/field_info.proto";
1718
import "google/api/annotations.proto";
1819
import "google/api/field_behavior.proto";
1920
import "google/api/resource.proto";
@@ -41,10 +42,8 @@ service Library {
4142
message ArchiveBookRequest {
4243
// The path of the book to retrieve.
4344
string path = 1 [
44-
(google.api.field_behavior) = REQUIRED,
45-
(google.api.resource_reference) = {
46-
type: "library.googleapis.com/Book"
47-
}];
45+
(aep.api.field_info) = { resource_reference: [ "library.googleapis.com/Book" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }
46+
];
4847

4948
// The target format for the archived book.
5049
// Must be "application/pdf", "application/rtf", or "application/epub+zip"
@@ -61,10 +60,8 @@ message ArchiveBookResponse {
6160
message SortBooksRequest {
6261
// The path of the publisher to sort books for.
6362
string parent = 1 [
64-
(google.api.field_behavior) = REQUIRED,
65-
(google.api.resource_reference) = {
66-
type: "library.googleapis.com/Publisher"
67-
}];
63+
(aep.api.field_info) = { resource_reference: [ "library.googleapis.com/Publisher" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }
64+
];
6865

6966
// The property of the book to sort by.
7067
// If not provided, "title" is used.

aep/general/0144/add_remove.proto

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
syntax = "proto3";
22

3+
import "aep/api/field_info.proto";
34
import "google/api/annotations.proto";
45
import "google/api/field_behavior.proto";
56
import "google/api/resource.proto";
@@ -26,8 +27,7 @@ service Library {
2627
message AddAuthorRequest {
2728
// The name of the book to add an author to.
2829
string book = 1 [
29-
(google.api.field_behavior) = REQUIRED,
30-
(google.api.resource_reference).type = "library.googleapis.com/Book"
30+
(aep.api.field_info) = { resource_reference: [ "library.googleapis.com/Book" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }
3131
];
3232

3333
// The author to be added.
@@ -38,8 +38,7 @@ message AddAuthorRequest {
3838
message RemoveAuthorRequest {
3939
// The name of the book to remove an author from.
4040
string book = 1 [
41-
(google.api.field_behavior) = REQUIRED,
42-
(google.api.resource_reference).type = "library.googleapis.com/Book"
41+
(aep.api.field_info) = { resource_reference: [ "library.googleapis.com/Book" ], field_behavior: [ FIELD_BEHAVIOR_REQUIRED ] }
4342
];
4443

4544
// The author to be removed.

0 commit comments

Comments
 (0)