policy.proto 3.1 KB

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