Skip to content

Commit

Permalink
feat: public google.api.FieldInfo type and extension
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 570083911
  • Loading branch information
Google APIs authored and Copybara-Service committed Oct 2, 2023
1 parent 615270f commit 2ca95f6
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
22 changes: 22 additions & 0 deletions google/api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ proto_library(
srcs = ["error_reason.proto"],
)

proto_library(
name = "field_info_proto",
srcs = ["field_info.proto"],
deps = [
"@com_google_protobuf//:descriptor_proto",
],
)

proto_library(
name = "field_behavior_proto",
srcs = ["field_behavior.proto"],
Expand Down Expand Up @@ -290,6 +298,7 @@ java_proto_library(
"endpoint_proto",
"error_reason_proto",
"field_behavior_proto",
"field_info_proto",
"http_proto",
"httpbody_proto",
"label_proto",
Expand Down Expand Up @@ -332,6 +341,7 @@ java_gapic_assembly_gradle_pkg(
"endpoint_proto",
"error_reason_proto",
"field_behavior_proto",
"field_info_proto",
"http_proto",
"httpbody_proto",
"label_proto",
Expand Down Expand Up @@ -366,6 +376,7 @@ go_proto_library(
":annotations_proto",
":client_proto",
":field_behavior_proto",
":field_info_proto",
":http_proto",
":resource_proto",
":routing_proto",
Expand Down Expand Up @@ -552,6 +563,11 @@ cc_proto_library(
deps = [":endpoint_proto"],
)

cc_proto_library(
name = "field_info_cc_proto",
deps = [":field_info_proto"],
)

cc_proto_library(
name = "field_behavior_cc_proto",
deps = [":field_behavior_proto"],
Expand Down Expand Up @@ -712,6 +728,11 @@ py_proto_library(
deps = [":endpoint_proto"],
)

py_proto_library(
name = "field_info_py_proto",
deps = [":field_info_proto"],
)

py_proto_library(
name = "field_behavior_py_proto",
deps = [":field_behavior_proto"],
Expand Down Expand Up @@ -832,6 +853,7 @@ php_proto_library(
"documentation_proto",
"endpoint_proto",
"error_reason_proto",
"field_info_proto",
"field_behavior_proto",
"http_proto",
"httpbody_proto",
Expand Down
79 changes: 79 additions & 0 deletions google/api/field_info.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.api;

import "google/protobuf/descriptor.proto";

option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "FieldInfoProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";

extend google.protobuf.FieldOptions {
// Rich semantic descriptor of an API field beyond the basic typing.
//
// Examples:
//
// string request_id = 1 [(google.api.field_info).format = UUID4];
// string old_ip_address = 2 [(google.api.field_info).format = IPV4];
// string new_ip_address = 3 [(google.api.field_info).format = IPV6];
// string actual_ip_address = 4 [
// (google.api.field_info).format = IPV4_OR_IPV6
// ];
google.api.FieldInfo field_info = 291403980;
}

// Rich semantic information of an API field beyond basic typing.
message FieldInfo {
// The standard format of a field value. The supported formats are all backed
// by either an RFC defined by the IETF or a Google-defined AIP.
enum Format {
// Default, unspecified value.
FORMAT_UNSPECIFIED = 0;

// Universally Unique Identifier, version 4, value as defined by
// https://datatracker.ietf.org/doc/html/rfc4122. The value may be
// normalized to entirely lowercase letters. For example, the value
// `F47AC10B-58CC-0372-8567-0E02B2C3D479` would be normalized to
// `f47ac10b-58cc-0372-8567-0e02b2c3d479`.
UUID4 = 1;

// Internet Protocol v4 value as defined by [RFC
// 791](https://datatracker.ietf.org/doc/html/rfc791). The value may be
// condensed, with leading zeros in each octet stripped. For example,
// `001.022.233.040` would be condensed to `1.22.233.40`.
IPV4 = 2;

// Internet Protocol v6 value as defined by [RFC
// 2460](https://datatracker.ietf.org/doc/html/rfc2460). The value may be
// normalized to entirely lowercase letters, and zero-padded partial and
// empty octets. For example, the value `2001:DB8::` would be normalized to
// `2001:0db8:0:0`.
IPV6 = 3;

// An IP address in either v4 or v6 format as described by the individual
// values defined herein. See the comments on the IPV4 and IPV6 types for
// allowed normalizations of each.
IPV4_OR_IPV6 = 4;
}

// The standard format of a field value. This does not explicitly configure
// any API consumer, just documents the API's format for the field it is
// applied to.
Format format = 1;
}
1 change: 1 addition & 0 deletions google/api/serviceconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ types:
- name: google.api.ConfigChange
- name: google.api.Distribution
- name: google.api.DocumentationRule
- name: google.api.FieldInfo
- name: google.api.HttpBody
- name: google.api.LabelDescriptor
- name: google.api.Metric
Expand Down

0 comments on commit 2ca95f6

Please sign in to comment.