field_info.proto 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Copyright 2024 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.api;
  16. import "google/protobuf/descriptor.proto";
  17. option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "FieldInfoProto";
  20. option java_package = "com.google.api";
  21. option objc_class_prefix = "GAPI";
  22. extend google.protobuf.FieldOptions {
  23. // Rich semantic descriptor of an API field beyond the basic typing.
  24. //
  25. // Examples:
  26. //
  27. // string request_id = 1 [(google.api.field_info).format = UUID4];
  28. // string old_ip_address = 2 [(google.api.field_info).format = IPV4];
  29. // string new_ip_address = 3 [(google.api.field_info).format = IPV6];
  30. // string actual_ip_address = 4 [
  31. // (google.api.field_info).format = IPV4_OR_IPV6
  32. // ];
  33. // google.protobuf.Any generic_field = 5 [
  34. // (google.api.field_info).referenced_types = {type_name: "ActualType"},
  35. // (google.api.field_info).referenced_types = {type_name: "OtherType"},
  36. // ];
  37. // google.protobuf.Any generic_user_input = 5 [
  38. // (google.api.field_info).referenced_types = {type_name: "*"},
  39. // ];
  40. google.api.FieldInfo field_info = 291403980;
  41. }
  42. // Rich semantic information of an API field beyond basic typing.
  43. message FieldInfo {
  44. // The standard format of a field value. The supported formats are all backed
  45. // by either an RFC defined by the IETF or a Google-defined AIP.
  46. enum Format {
  47. // Default, unspecified value.
  48. FORMAT_UNSPECIFIED = 0;
  49. // Universally Unique Identifier, version 4, value as defined by
  50. // https://datatracker.ietf.org/doc/html/rfc4122. The value may be
  51. // normalized to entirely lowercase letters. For example, the value
  52. // `F47AC10B-58CC-0372-8567-0E02B2C3D479` would be normalized to
  53. // `f47ac10b-58cc-0372-8567-0e02b2c3d479`.
  54. UUID4 = 1;
  55. // Internet Protocol v4 value as defined by [RFC
  56. // 791](https://datatracker.ietf.org/doc/html/rfc791). The value may be
  57. // condensed, with leading zeros in each octet stripped. For example,
  58. // `001.022.233.040` would be condensed to `1.22.233.40`.
  59. IPV4 = 2;
  60. // Internet Protocol v6 value as defined by [RFC
  61. // 2460](https://datatracker.ietf.org/doc/html/rfc2460). The value may be
  62. // normalized to entirely lowercase letters with zeros compressed, following
  63. // [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952). For example,
  64. // the value `2001:0DB8:0::0` would be normalized to `2001:db8::`.
  65. IPV6 = 3;
  66. // An IP address in either v4 or v6 format as described by the individual
  67. // values defined herein. See the comments on the IPV4 and IPV6 types for
  68. // allowed normalizations of each.
  69. IPV4_OR_IPV6 = 4;
  70. }
  71. // The standard format of a field value. This does not explicitly configure
  72. // any API consumer, just documents the API's format for the field it is
  73. // applied to.
  74. Format format = 1;
  75. // The type(s) that the annotated, generic field may represent.
  76. //
  77. // Currently, this must only be used on fields of type `google.protobuf.Any`.
  78. // Supporting other generic types may be considered in the future.
  79. repeated TypeReference referenced_types = 2;
  80. }
  81. // A reference to a message type, for use in [FieldInfo][google.api.FieldInfo].
  82. message TypeReference {
  83. // The name of the type that the annotated, generic field may represent.
  84. // If the type is in the same protobuf package, the value can be the simple
  85. // message name e.g., `"MyMessage"`. Otherwise, the value must be the
  86. // fully-qualified message name e.g., `"google.library.v1.Book"`.
  87. //
  88. // If the type(s) are unknown to the service (e.g. the field accepts generic
  89. // user input), use the wildcard `"*"` to denote this behavior.
  90. //
  91. // See [AIP-202](https://google.aip.dev/202#type-references) for more details.
  92. string type_name = 1;
  93. }