Skip to content

Commit cee645b

Browse files
authored
feat(AIP-203): introduce IDENTIFIER field behavior (#1201)
Identifier fields are often multi-modal: they are required or optional in various situations. Adding an explicit field behavior for these fields helps eliminate ambiguity for an author to fully annotate field behavior on all request fields, as well as clarify which fields to use in identifying the resource for clients.
1 parent 59e3dd4 commit cee645b

File tree

18 files changed

+105
-88
lines changed

18 files changed

+105
-88
lines changed

aip/client-libraries/4231.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ message Topic {
4343
pattern: "projects/{project}/topics/{topic}"
4444
};
4545
46-
// The resource's name.
47-
string name = 1;
48-
49-
// And so on...
46+
// name and so on...
5047
}
5148
```
5249

@@ -91,10 +88,7 @@ message LogEntry {
9188
pattern: "billingAccounts/{billing_account}/logs/{log}"
9289
};
9390
94-
// The resource's name.
95-
string name = 1;
96-
97-
// And so on...
91+
// name and so on...
9892
}
9993
```
10094

@@ -195,10 +189,7 @@ message FeedItemTarget {
195189
pattern: "customers/{customer}/feedItemTargets/{feed}~{feed_item}"
196190
};
197191
198-
// The resource name of this event.
199-
string name = 1;
200-
201-
// Other fields...
192+
// name and other fields...
202193
}
203194
```
204195

aip/cloud/2510.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ message Book {
8888
};
8989
9090
// The resource name of the Book.
91-
string name = 1;
91+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
9292
9393
// A reference to another resource, a Shelf.
9494
string shelf = 2 [(google.api.resource_reference) = {

aip/general/0122.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ message Book {
196196
197197
// The resource name of the book.
198198
// Format: publishers/{publisher}/books/{book}
199-
string name = 1;
199+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
200200
201201
// Other fields...
202202
}
@@ -282,7 +282,7 @@ When a field represents another resource, the field **should** be of type
282282
`string` and accept the resource name of the other resource. The field name
283283
**should** be equivalent to the corresponding message's name in snake case.
284284

285-
The field **should not** be of type `message` using the `message` that
285+
The field **should not** be of type `message` using the `message` that
286286
implements the resource, _unless_ the API is internal-only, has tight lifecycle
287287
relationships, and has a permission model that enables inherited access to
288288
embedded resources.
@@ -307,7 +307,7 @@ message Book {
307307
308308
// Name of the book.
309309
// Format is `publishers/{publisher}/books/{book}`
310-
string name = 1;
310+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
311311
312312
// The shelf where the book currently sits.
313313
// Format is `shelves/{shelf}`.

aip/general/0123.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ message Topic {
6767
plural: "topics"
6868
};
6969
70-
// The resource name of the topic.
71-
string name = 1;
72-
73-
// Other fields...
70+
// Name and other fields...
7471
}
7572
```
7673

aip/general/0124.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ message Book {
3636
};
3737
3838
// The resource name for the book.
39-
string name = 1;
39+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
4040
4141
// The resource name for the book's author.
4242
string author = 2 [(google.api.resource_reference) = {
@@ -71,7 +71,7 @@ message Book {
7171
pattern: "publishers/{publisher}/books/{book}"
7272
};
7373
74-
string name = 1;
74+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
7575
7676
// The resource names for the book's authors.
7777
repeated string authors = 2 [(google.api.resource_reference) = {
@@ -97,7 +97,7 @@ message BookAuthor {
9797
};
9898
9999
// The resource name for the book-author association.
100-
string name = 1;
100+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
101101
102102
// The resource name for the author.
103103
string author = 2 [(google.api.resource_reference) = {

aip/general/0128.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ message Book {
4444
style: DECLARATIVE_FRIENDLY
4545
};
4646
47-
string name = 1;
48-
// Other fields...
47+
// Name and other fields...
4948
}
5049
```
5150

aip/general/0134.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,14 @@ In this situation, the resource **should** contain a `string etag` field:
227227

228228
```proto
229229
message Book {
230+
option (google.api.resource) = {
231+
type: "library.googleapis.com/Book"
232+
pattern: "publishers/{publisher}/books/{book}"
233+
};
234+
230235
// The resource name of the book.
231236
// Format: publishers/{publisher}/books/{book}
232-
string name = 1;
237+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
233238
234239
// The title of the book.
235240
// Example: "Mary Poppins"

aip/general/0144.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ Resources **may** use repeated fields where appropriate.
2020

2121
```proto
2222
message Book {
23-
string name = 1;
23+
option (google.api.resource) = {
24+
type: "library.googleapis.com/Book"
25+
pattern: "publishers/{publisher}/books/{book}"
26+
};
27+
28+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
29+
2430
repeated string authors = 2;
2531
}
2632
```

aip/general/0147.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ resource implies storage of the sensitive data. For example:
2525

2626
```proto
2727
message SelfManagedKeypair {
28-
string name = 1;
28+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
2929
3030
// The public key data in PEM-encoded form.
3131
bytes public_key = 2;
@@ -42,7 +42,7 @@ indicate whether or not the sensitive information is present. For example:
4242

4343
```proto
4444
message Integration {
45-
string name = 1;
45+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
4646
string uri = 2;
4747
4848
// A secret to be passed in the `Authorization` header of the webhook.

aip/general/0149.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ its default value (`0`, `false`, or empty string) from not setting it at all:
2525
```proto
2626
// A representation of a book in a library.
2727
message Book {
28+
option (google.api.resource) = {
29+
type: "library.googleapis.com/Book"
30+
pattern: "publishers/{publisher}/books/{book}"
31+
};
32+
2833
// The name of the book.
29-
string name = 1;
34+
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
3035
3136
// The rating for the book, from 0 to 5.
3237
// 0 is distinct from no rating.

0 commit comments

Comments
 (0)