Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 2ba3577

Browse files
feat: add FieldInfo.referenced_types for generics (#247)
Source-Link: googleapis/synthtool@373d00f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:2dc6f67639bee669c33c6277a624ab9857d363e2fd33ac5b02d417b7d25f1ffc Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent f949829 commit 2ba3577

File tree

10 files changed

+96
-71
lines changed

10 files changed

+96
-71
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:52210e0e0559f5ea8c52be148b33504022e1faef4e95fbe4b32d68022af2fa7e
17-
# created: 2024-07-08T19:25:35.862283192Z
16+
digest: sha256:2dc6f67639bee669c33c6277a624ab9857d363e2fd33ac5b02d417b7d25f1ffc
17+
# created: 2024-08-15T17:41:26.438340772Z

.kokoro/docker/docs/Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,18 @@ RUN tar -xvf Python-3.10.14.tgz
7272
RUN ./Python-3.10.14/configure --enable-optimizations
7373
RUN make altinstall
7474

75-
RUN python3.10 -m venv /venv
76-
ENV PATH /venv/bin:$PATH
75+
ENV PATH /usr/local/bin/python3.10:$PATH
7776

7877
###################### Install pip
7978
RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
80-
&& python3 /tmp/get-pip.py \
79+
&& python3.10 /tmp/get-pip.py \
8180
&& rm /tmp/get-pip.py
8281

8382
# Test pip
84-
RUN python3 -m pip
83+
RUN python3.10 -m pip
8584

8685
# Install build requirements
8786
COPY requirements.txt /requirements.txt
88-
RUN python3 -m pip install --require-hashes -r requirements.txt
87+
RUN python3.10 -m pip install --require-hashes -r requirements.txt
8988

9089
CMD ["python3.10"]

google/api/client.proto

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ message MethodSettings {
349349

350350
// The fully qualified name of the method, for which the options below apply.
351351
// This is used to find the method to apply the options.
352+
//
353+
// Example:
354+
//
355+
// publishing:
356+
// method_settings:
357+
// - selector: google.storage.control.v2.StorageControl.CreateFolder
358+
// # method settings for CreateFolder...
352359
string selector = 1;
353360

354361
// Describes settings to use for long-running operations when generating
@@ -357,17 +364,14 @@ message MethodSettings {
357364
//
358365
// Example of a YAML configuration::
359366
//
360-
// publishing:
361-
// method_settings:
367+
// publishing:
368+
// method_settings:
362369
// - selector: google.cloud.speech.v2.Speech.BatchRecognize
363370
// long_running:
364-
// initial_poll_delay:
365-
// seconds: 60 # 1 minute
371+
// initial_poll_delay: 60s # 1 minute
366372
// poll_delay_multiplier: 1.5
367-
// max_poll_delay:
368-
// seconds: 360 # 6 minutes
369-
// total_poll_timeout:
370-
// seconds: 54000 # 90 minutes
373+
// max_poll_delay: 360s # 6 minutes
374+
// total_poll_timeout: 54000s # 90 minutes
371375
LongRunning long_running = 2;
372376

373377
// List of top-level fields of the request message, that should be
@@ -376,8 +380,8 @@ message MethodSettings {
376380
//
377381
// Example of a YAML configuration:
378382
//
379-
// publishing:
380-
// method_settings:
383+
// publishing:
384+
// method_settings:
381385
// - selector: google.example.v1.ExampleService.CreateExample
382386
// auto_populated_fields:
383387
// - request_id

google/api/context.proto

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ message ContextRule {
7474
// details.
7575
string selector = 1;
7676

77-
// A list of full type names of requested contexts.
77+
// A list of full type names of requested contexts, only the requested context
78+
// will be made available to the backend.
7879
repeated string requested = 2;
7980

80-
// A list of full type names of provided contexts.
81+
// A list of full type names of provided contexts. It is used to support
82+
// propagating HTTP headers and ETags from the response extension.
8183
repeated string provided = 3;
8284

8385
// A list of full type names or extension IDs of extensions allowed in grpc

google/api/endpoint.proto

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,10 @@ message Endpoint {
4747
// The canonical name of this endpoint.
4848
string name = 1;
4949

50-
// Unimplemented. Dot not use.
51-
//
52-
// DEPRECATED: This field is no longer supported. Instead of using aliases,
53-
// please specify multiple [google.api.Endpoint][google.api.Endpoint] for each
54-
// of the intended aliases.
55-
//
56-
// Additional names that this endpoint will be hosted on.
57-
repeated string aliases = 2 [deprecated = true];
50+
// Aliases for this endpoint, these will be served by the same UrlMap as the
51+
// parent endpoint, and will be provisioned in the GCP stack for the Regional
52+
// Endpoints.
53+
repeated string aliases = 2;
5854

5955
// The specification of an Internet routable address of API frontend that will
6056
// handle requests to this [API

google/api/endpoint_pb2.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
31-
b'\n\x19google/api/endpoint.proto\x12\ngoogle.api"Q\n\x08\x45ndpoint\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x07\x61liases\x18\x02 \x03(\tB\x02\x18\x01\x12\x0e\n\x06target\x18\x65 \x01(\t\x12\x12\n\nallow_cors\x18\x05 \x01(\x08\x42o\n\x0e\x63om.google.apiB\rEndpointProtoP\x01ZEgoogle.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig\xa2\x02\x04GAPIb\x06proto3'
31+
b'\n\x19google/api/endpoint.proto\x12\ngoogle.api"M\n\x08\x45ndpoint\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07\x61liases\x18\x02 \x03(\t\x12\x0e\n\x06target\x18\x65 \x01(\t\x12\x12\n\nallow_cors\x18\x05 \x01(\x08\x42o\n\x0e\x63om.google.apiB\rEndpointProtoP\x01ZEgoogle.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig\xa2\x02\x04GAPIb\x06proto3'
3232
)
3333

3434
_globals = globals()
@@ -37,8 +37,6 @@
3737
if _descriptor._USE_C_DESCRIPTORS == False:
3838
DESCRIPTOR._options = None
3939
DESCRIPTOR._serialized_options = b"\n\016com.google.apiB\rEndpointProtoP\001ZEgoogle.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig\242\002\004GAPI"
40-
_ENDPOINT.fields_by_name["aliases"]._options = None
41-
_ENDPOINT.fields_by_name["aliases"]._serialized_options = b"\030\001"
4240
_globals["_ENDPOINT"]._serialized_start = 41
43-
_globals["_ENDPOINT"]._serialized_end = 122
41+
_globals["_ENDPOINT"]._serialized_end = 118
4442
# @@protoc_insertion_point(module_scope)

google/api/field_info.proto

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,19 @@ extend google.protobuf.FieldOptions {
2929
//
3030
// Examples:
3131
//
32-
// string request_id = 1 [(google.api.field_info).format = UUID4];
33-
// string old_ip_address = 2 [(google.api.field_info).format = IPV4];
34-
// string new_ip_address = 3 [(google.api.field_info).format = IPV6];
35-
// string actual_ip_address = 4 [
36-
// (google.api.field_info).format = IPV4_OR_IPV6
37-
// ];
32+
// string request_id = 1 [(google.api.field_info).format = UUID4];
33+
// string old_ip_address = 2 [(google.api.field_info).format = IPV4];
34+
// string new_ip_address = 3 [(google.api.field_info).format = IPV6];
35+
// string actual_ip_address = 4 [
36+
// (google.api.field_info).format = IPV4_OR_IPV6
37+
// ];
38+
// google.protobuf.Any generic_field = 5 [
39+
// (google.api.field_info).referenced_types = {type_name: "ActualType"},
40+
// (google.api.field_info).referenced_types = {type_name: "OtherType"},
41+
// ];
42+
// google.protobuf.Any generic_user_input = 5 [
43+
// (google.api.field_info).referenced_types = {type_name: "*"},
44+
// ];
3845
google.api.FieldInfo field_info = 291403980;
3946
}
4047

@@ -76,4 +83,24 @@ message FieldInfo {
7683
// any API consumer, just documents the API's format for the field it is
7784
// applied to.
7885
Format format = 1;
86+
87+
// The type(s) that the annotated, generic field may represent.
88+
//
89+
// Currently, this must only be used on fields of type `google.protobuf.Any`.
90+
// Supporting other generic types may be considered in the future.
91+
repeated TypeReference referenced_types = 2;
92+
}
93+
94+
// A reference to a message type, for use in [FieldInfo][google.api.FieldInfo].
95+
message TypeReference {
96+
// The name of the type that the annotated, generic field may represent.
97+
// If the type is in the same protobuf package, the value can be the simple
98+
// message name e.g., `"MyMessage"`. Otherwise, the value must be the
99+
// fully-qualified message name e.g., `"google.library.v1.Book"`.
100+
//
101+
// If the type(s) are unknown to the service (e.g. the field accepts generic
102+
// user input), use the wildcard `"*"` to denote this behavior.
103+
//
104+
// See [AIP-202](https://google.aip.dev/202#type-references) for more details.
105+
string type_name = 1;
79106
}

google/api/field_info_pb2.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
34-
b'\n\x1bgoogle/api/field_info.proto\x12\ngoogle.api\x1a google/protobuf/descriptor.proto"\x8c\x01\n\tFieldInfo\x12,\n\x06\x66ormat\x18\x01 \x01(\x0e\x32\x1c.google.api.FieldInfo.Format"Q\n\x06\x46ormat\x12\x16\n\x12\x46ORMAT_UNSPECIFIED\x10\x00\x12\t\n\x05UUID4\x10\x01\x12\x08\n\x04IPV4\x10\x02\x12\x08\n\x04IPV6\x10\x03\x12\x10\n\x0cIPV4_OR_IPV6\x10\x04:L\n\nfield_info\x12\x1d.google.protobuf.FieldOptions\x18\xcc\xf1\xf9\x8a\x01 \x01(\x0b\x32\x15.google.api.FieldInfoBl\n\x0e\x63om.google.apiB\x0e\x46ieldInfoProtoP\x01ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\xa2\x02\x04GAPIb\x06proto3'
34+
b'\n\x1bgoogle/api/field_info.proto\x12\ngoogle.api\x1a google/protobuf/descriptor.proto"\xc1\x01\n\tFieldInfo\x12,\n\x06\x66ormat\x18\x01 \x01(\x0e\x32\x1c.google.api.FieldInfo.Format\x12\x33\n\x10referenced_types\x18\x02 \x03(\x0b\x32\x19.google.api.TypeReference"Q\n\x06\x46ormat\x12\x16\n\x12\x46ORMAT_UNSPECIFIED\x10\x00\x12\t\n\x05UUID4\x10\x01\x12\x08\n\x04IPV4\x10\x02\x12\x08\n\x04IPV6\x10\x03\x12\x10\n\x0cIPV4_OR_IPV6\x10\x04""\n\rTypeReference\x12\x11\n\ttype_name\x18\x01 \x01(\t:L\n\nfield_info\x12\x1d.google.protobuf.FieldOptions\x18\xcc\xf1\xf9\x8a\x01 \x01(\x0b\x32\x15.google.api.FieldInfoBl\n\x0e\x63om.google.apiB\x0e\x46ieldInfoProtoP\x01ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\xa2\x02\x04GAPIb\x06proto3'
3535
)
3636

3737
_globals = globals()
@@ -43,7 +43,9 @@
4343
DESCRIPTOR._options = None
4444
DESCRIPTOR._serialized_options = b"\n\016com.google.apiB\016FieldInfoProtoP\001ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\242\002\004GAPI"
4545
_globals["_FIELDINFO"]._serialized_start = 78
46-
_globals["_FIELDINFO"]._serialized_end = 218
47-
_globals["_FIELDINFO_FORMAT"]._serialized_start = 137
48-
_globals["_FIELDINFO_FORMAT"]._serialized_end = 218
46+
_globals["_FIELDINFO"]._serialized_end = 271
47+
_globals["_FIELDINFO_FORMAT"]._serialized_start = 190
48+
_globals["_FIELDINFO_FORMAT"]._serialized_end = 271
49+
_globals["_TYPEREFERENCE"]._serialized_start = 273
50+
_globals["_TYPEREFERENCE"]._serialized_end = 307
4951
# @@protoc_insertion_point(module_scope)

google/api/http.proto

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ message Http {
4141
bool fully_decode_reserved_expansion = 2;
4242
}
4343

44-
// # gRPC Transcoding
44+
// gRPC Transcoding
4545
//
4646
// gRPC Transcoding is a feature for mapping between a gRPC method and one or
4747
// more HTTP REST endpoints. It allows developers to build a single API service
@@ -82,9 +82,8 @@ message Http {
8282
//
8383
// This enables an HTTP REST to gRPC mapping as below:
8484
//
85-
// HTTP | gRPC
86-
// -----|-----
87-
// `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")`
85+
// - HTTP: `GET /v1/messages/123456`
86+
// - gRPC: `GetMessage(name: "messages/123456")`
8887
//
8988
// Any fields in the request message which are not bound by the path template
9089
// automatically become HTTP query parameters if there is no HTTP request body.
@@ -108,11 +107,9 @@ message Http {
108107
//
109108
// This enables a HTTP JSON to RPC mapping as below:
110109
//
111-
// HTTP | gRPC
112-
// -----|-----
113-
// `GET /v1/messages/123456?revision=2&sub.subfield=foo` |
114-
// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield:
115-
// "foo"))`
110+
// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo`
111+
// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub:
112+
// SubMessage(subfield: "foo"))`
116113
//
117114
// Note that fields which are mapped to URL query parameters must have a
118115
// primitive type or a repeated primitive type or a non-repeated message type.
@@ -142,10 +139,8 @@ message Http {
142139
// representation of the JSON in the request body is determined by
143140
// protos JSON encoding:
144141
//
145-
// HTTP | gRPC
146-
// -----|-----
147-
// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
148-
// "123456" message { text: "Hi!" })`
142+
// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }`
143+
// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
149144
//
150145
// The special name `*` can be used in the body mapping to define that
151146
// every field not bound by the path template should be mapped to the
@@ -168,10 +163,8 @@ message Http {
168163
//
169164
// The following HTTP JSON to RPC mapping is enabled:
170165
//
171-
// HTTP | gRPC
172-
// -----|-----
173-
// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
174-
// "123456" text: "Hi!")`
166+
// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }`
167+
// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")`
175168
//
176169
// Note that when using `*` in the body mapping, it is not possible to
177170
// have HTTP parameters, as all fields not bound by the path end in
@@ -199,13 +192,13 @@ message Http {
199192
//
200193
// This enables the following two alternative HTTP JSON to RPC mappings:
201194
//
202-
// HTTP | gRPC
203-
// -----|-----
204-
// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
205-
// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id:
206-
// "123456")`
195+
// - HTTP: `GET /v1/messages/123456`
196+
// - gRPC: `GetMessage(message_id: "123456")`
207197
//
208-
// ## Rules for HTTP mapping
198+
// - HTTP: `GET /v1/users/me/messages/123456`
199+
// - gRPC: `GetMessage(user_id: "me" message_id: "123456")`
200+
//
201+
// Rules for HTTP mapping
209202
//
210203
// 1. Leaf request fields (recursive expansion nested messages in the request
211204
// message) are classified into three categories:
@@ -224,7 +217,7 @@ message Http {
224217
// request body, all
225218
// fields are passed via URL path and URL query parameters.
226219
//
227-
// ### Path template syntax
220+
// Path template syntax
228221
//
229222
// Template = "/" Segments [ Verb ] ;
230223
// Segments = Segment { "/" Segment } ;
@@ -263,7 +256,7 @@ message Http {
263256
// Document](https://developers.google.com/discovery/v1/reference/apis) as
264257
// `{+var}`.
265258
//
266-
// ## Using gRPC API Service Configuration
259+
// Using gRPC API Service Configuration
267260
//
268261
// gRPC API Service Configuration (service config) is a configuration language
269262
// for configuring a gRPC service to become a user-facing product. The
@@ -278,15 +271,14 @@ message Http {
278271
// specified in the service config will override any matching transcoding
279272
// configuration in the proto.
280273
//
281-
// Example:
274+
// The following example selects a gRPC method and applies an `HttpRule` to it:
282275
//
283276
// http:
284277
// rules:
285-
// # Selects a gRPC method and applies HttpRule to it.
286278
// - selector: example.v1.Messaging.GetMessage
287279
// get: /v1/messages/{message_id}/{sub.subfield}
288280
//
289-
// ## Special notes
281+
// Special notes
290282
//
291283
// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the
292284
// proto to JSON conversion must follow the [proto3

google/api/resource.proto

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,13 @@ message ResourceDescriptor {
179179

180180
// The plural name used in the resource name and permission names, such as
181181
// 'projects' for the resource name of 'projects/{project}' and the permission
182-
// name of 'cloudresourcemanager.googleapis.com/projects.get'. It is the same
183-
// concept of the `plural` field in k8s CRD spec
182+
// name of 'cloudresourcemanager.googleapis.com/projects.get'. One exception
183+
// to this is for Nested Collections that have stuttering names, as defined
184+
// in [AIP-122](https://google.aip.dev/122#nested-collections), where the
185+
// collection ID in the resource name pattern does not necessarily directly
186+
// match the `plural` value.
187+
//
188+
// It is the same concept of the `plural` field in k8s CRD spec
184189
// https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
185190
//
186191
// Note: The plural form is required even for singleton resources. See

0 commit comments

Comments
 (0)