field_behavior.proto 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright 2023 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 = "FieldBehaviorProto";
  20. option java_package = "com.google.api";
  21. option objc_class_prefix = "GAPI";
  22. extend google.protobuf.FieldOptions {
  23. // A designation of a specific field behavior (required, output only, etc.)
  24. // in protobuf messages.
  25. //
  26. // Examples:
  27. //
  28. // string name = 1 [(google.api.field_behavior) = REQUIRED];
  29. // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  30. // google.protobuf.Duration ttl = 1
  31. // [(google.api.field_behavior) = INPUT_ONLY];
  32. // google.protobuf.Timestamp expire_time = 1
  33. // [(google.api.field_behavior) = OUTPUT_ONLY,
  34. // (google.api.field_behavior) = IMMUTABLE];
  35. repeated google.api.FieldBehavior field_behavior = 1052 [packed = false];
  36. }
  37. // An indicator of the behavior of a given field (for example, that a field
  38. // is required in requests, or given as output but ignored as input).
  39. // This **does not** change the behavior in protocol buffers itself; it only
  40. // denotes the behavior and may affect how API tooling handles the field.
  41. //
  42. // Note: This enum **may** receive new values in the future.
  43. enum FieldBehavior {
  44. // Conventional default for enums. Do not use this.
  45. FIELD_BEHAVIOR_UNSPECIFIED = 0;
  46. // Specifically denotes a field as optional.
  47. // While all fields in protocol buffers are optional, this may be specified
  48. // for emphasis if appropriate.
  49. OPTIONAL = 1;
  50. // Denotes a field as required.
  51. // This indicates that the field **must** be provided as part of the request,
  52. // and failure to do so will cause an error (usually `INVALID_ARGUMENT`).
  53. REQUIRED = 2;
  54. // Denotes a field as output only.
  55. // This indicates that the field is provided in responses, but including the
  56. // field in a request does nothing (the server *must* ignore it and
  57. // *must not* throw an error as a result of the field's presence).
  58. OUTPUT_ONLY = 3;
  59. // Denotes a field as input only.
  60. // This indicates that the field is provided in requests, and the
  61. // corresponding field is not included in output.
  62. INPUT_ONLY = 4;
  63. // Denotes a field as immutable.
  64. // This indicates that the field may be set once in a request to create a
  65. // resource, but may not be changed thereafter.
  66. IMMUTABLE = 5;
  67. // Denotes that a (repeated) field is an unordered list.
  68. // This indicates that the service may provide the elements of the list
  69. // in any arbitrary order, rather than the order the user originally
  70. // provided. Additionally, the list's order may or may not be stable.
  71. UNORDERED_LIST = 6;
  72. // Denotes that this field returns a non-empty default value if not set.
  73. // This indicates that if the user provides the empty value in a request,
  74. // a non-empty value will be returned. The user will not be aware of what
  75. // non-empty value to expect.
  76. NON_EMPTY_DEFAULT = 7;
  77. // Denotes that the field in a resource (a message annotated with
  78. // google.api.resource) is used in the resource name to uniquely identify the
  79. // resource. For AIP-compliant APIs, this should only be applied to the
  80. // `name` field on the resource.
  81. //
  82. // This behavior should not be applied to references to other resources within
  83. // the message.
  84. //
  85. // The identifier field of resources often have different field behavior
  86. // depending on the request it is embedded in (e.g. for Create methods name
  87. // is optional and unused, while for Update methods it is required). Instead
  88. // of method-specific annotations, only `IDENTIFIER` is required.
  89. IDENTIFIER = 8;
  90. }