policy.proto 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 2025 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/serviceconfig;serviceconfig";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "PolicyProto";
  20. option java_package = "com.google.api";
  21. option objc_class_prefix = "GAPI";
  22. extend google.protobuf.FieldOptions {
  23. // See [FieldPolicy][].
  24. google.api.FieldPolicy field_policy = 158361448;
  25. }
  26. extend google.protobuf.MethodOptions {
  27. // See [MethodPolicy][].
  28. google.api.MethodPolicy method_policy = 161893301;
  29. }
  30. // Google API Policy Annotation
  31. //
  32. // This message defines a simple API policy annotation that can be used to
  33. // annotate API request and response message fields with applicable policies.
  34. // One field may have multiple applicable policies that must all be satisfied
  35. // before a request can be processed. This policy annotation is used to
  36. // generate the overall policy that will be used for automatic runtime
  37. // policy enforcement and documentation generation.
  38. message FieldPolicy {
  39. // Selects one or more request or response message fields to apply this
  40. // `FieldPolicy`.
  41. //
  42. // When a `FieldPolicy` is used in proto annotation, the selector must
  43. // be left as empty. The service config generator will automatically fill
  44. // the correct value.
  45. //
  46. // When a `FieldPolicy` is used in service config, the selector must be a
  47. // comma-separated string with valid request or response field paths,
  48. // such as "foo.bar" or "foo.bar,foo.baz".
  49. string selector = 1;
  50. // Specifies the required permission(s) for the resource referred to by the
  51. // field. It requires the field contains a valid resource reference, and
  52. // the request must pass the permission checks to proceed. For example,
  53. // "resourcemanager.projects.get".
  54. string resource_permission = 2;
  55. // Specifies the resource type for the resource referred to by the field.
  56. string resource_type = 3;
  57. }
  58. // Defines policies applying to an RPC method.
  59. message MethodPolicy {
  60. // Selects a method to which these policies should be enforced, for example,
  61. // "google.pubsub.v1.Subscriber.CreateSubscription".
  62. //
  63. // Refer to [selector][google.api.DocumentationRule.selector] for syntax
  64. // details.
  65. //
  66. // NOTE: This field must not be set in the proto annotation. It will be
  67. // automatically filled by the service config compiler .
  68. string selector = 9;
  69. // Policies that are applicable to the request message.
  70. repeated FieldPolicy request_policies = 2;
  71. }