quota.proto 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
  17. option java_multiple_files = true;
  18. option java_outer_classname = "QuotaProto";
  19. option java_package = "com.google.api";
  20. option objc_class_prefix = "GAPI";
  21. // Quota configuration helps to achieve fairness and budgeting in service
  22. // usage.
  23. //
  24. // The metric based quota configuration works this way:
  25. // - The service configuration defines a set of metrics.
  26. // - For API calls, the quota.metric_rules maps methods to metrics with
  27. // corresponding costs.
  28. // - The quota.limits defines limits on the metrics, which will be used for
  29. // quota checks at runtime.
  30. //
  31. // An example quota configuration in yaml format:
  32. //
  33. // quota:
  34. // limits:
  35. //
  36. // - name: apiWriteQpsPerProject
  37. // metric: library.googleapis.com/write_calls
  38. // unit: "1/min/{project}" # rate limit for consumer projects
  39. // values:
  40. // STANDARD: 10000
  41. //
  42. //
  43. // (The metric rules bind all methods to the read_calls metric,
  44. // except for the UpdateBook and DeleteBook methods. These two methods
  45. // are mapped to the write_calls metric, with the UpdateBook method
  46. // consuming at twice rate as the DeleteBook method.)
  47. // metric_rules:
  48. // - selector: "*"
  49. // metric_costs:
  50. // library.googleapis.com/read_calls: 1
  51. // - selector: google.example.library.v1.LibraryService.UpdateBook
  52. // metric_costs:
  53. // library.googleapis.com/write_calls: 2
  54. // - selector: google.example.library.v1.LibraryService.DeleteBook
  55. // metric_costs:
  56. // library.googleapis.com/write_calls: 1
  57. //
  58. // Corresponding Metric definition:
  59. //
  60. // metrics:
  61. // - name: library.googleapis.com/read_calls
  62. // display_name: Read requests
  63. // metric_kind: DELTA
  64. // value_type: INT64
  65. //
  66. // - name: library.googleapis.com/write_calls
  67. // display_name: Write requests
  68. // metric_kind: DELTA
  69. // value_type: INT64
  70. //
  71. //
  72. message Quota {
  73. // List of QuotaLimit definitions for the service.
  74. repeated QuotaLimit limits = 3;
  75. // List of MetricRule definitions, each one mapping a selected method to one
  76. // or more metrics.
  77. repeated MetricRule metric_rules = 4;
  78. }
  79. // Bind API methods to metrics. Binding a method to a metric causes that
  80. // metric's configured quota behaviors to apply to the method call.
  81. message MetricRule {
  82. // Selects the methods to which this rule applies.
  83. //
  84. // Refer to [selector][google.api.DocumentationRule.selector] for syntax
  85. // details.
  86. string selector = 1;
  87. // Metrics to update when the selected methods are called, and the associated
  88. // cost applied to each metric.
  89. //
  90. // The key of the map is the metric name, and the values are the amount
  91. // increased for the metric against which the quota limits are defined.
  92. // The value must not be negative.
  93. map<string, int64> metric_costs = 2;
  94. }
  95. // `QuotaLimit` defines a specific limit that applies over a specified duration
  96. // for a limit type. There can be at most one limit for a duration and limit
  97. // type combination defined within a `QuotaGroup`.
  98. message QuotaLimit {
  99. // Name of the quota limit.
  100. //
  101. // The name must be provided, and it must be unique within the service. The
  102. // name can only include alphanumeric characters as well as '-'.
  103. //
  104. // The maximum length of the limit name is 64 characters.
  105. string name = 6;
  106. // Optional. User-visible, extended description for this quota limit.
  107. // Should be used only when more context is needed to understand this limit
  108. // than provided by the limit's display name (see: `display_name`).
  109. string description = 2;
  110. // Default number of tokens that can be consumed during the specified
  111. // duration. This is the number of tokens assigned when a client
  112. // application developer activates the service for his/her project.
  113. //
  114. // Specifying a value of 0 will block all requests. This can be used if you
  115. // are provisioning quota to selected consumers and blocking others.
  116. // Similarly, a value of -1 will indicate an unlimited quota. No other
  117. // negative values are allowed.
  118. //
  119. // Used by group-based quotas only.
  120. int64 default_limit = 3;
  121. // Maximum number of tokens that can be consumed during the specified
  122. // duration. Client application developers can override the default limit up
  123. // to this maximum. If specified, this value cannot be set to a value less
  124. // than the default limit. If not specified, it is set to the default limit.
  125. //
  126. // To allow clients to apply overrides with no upper bound, set this to -1,
  127. // indicating unlimited maximum quota.
  128. //
  129. // Used by group-based quotas only.
  130. int64 max_limit = 4;
  131. // Free tier value displayed in the Developers Console for this limit.
  132. // The free tier is the number of tokens that will be subtracted from the
  133. // billed amount when billing is enabled.
  134. // This field can only be set on a limit with duration "1d", in a billable
  135. // group; it is invalid on any other limit. If this field is not set, it
  136. // defaults to 0, indicating that there is no free tier for this service.
  137. //
  138. // Used by group-based quotas only.
  139. int64 free_tier = 7;
  140. // Duration of this limit in textual notation. Must be "100s" or "1d".
  141. //
  142. // Used by group-based quotas only.
  143. string duration = 5;
  144. // The name of the metric this quota limit applies to. The quota limits with
  145. // the same metric will be checked together during runtime. The metric must be
  146. // defined within the service config.
  147. string metric = 8;
  148. // Specify the unit of the quota limit. It uses the same syntax as
  149. // [Metric.unit][]. The supported unit kinds are determined by the quota
  150. // backend system.
  151. //
  152. // Here are some examples:
  153. // * "1/min/{project}" for quota per minute per project.
  154. //
  155. // Note: the order of unit components is insignificant.
  156. // The "1" at the beginning is required to follow the metric unit syntax.
  157. string unit = 9;
  158. // Tiered limit values. You must specify this as a key:value pair, with an
  159. // integer value that is the maximum number of requests allowed for the
  160. // specified unit. Currently only STANDARD is supported.
  161. map<string, int64> values = 10;
  162. // User-visible display name for this limit.
  163. // Optional. If not set, the UI will provide a default display name based on
  164. // the quota configuration. This field can be used to override the default
  165. // display name generated from the configuration.
  166. string display_name = 12;
  167. }