policy.proto 3.2 KB

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