quota.proto 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // Copyright 2015 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 details.
  85. string selector = 1;
  86. // Metrics to update when the selected methods are called, and the associated
  87. // cost applied to each metric.
  88. //
  89. // The key of the map is the metric name, and the values are the amount
  90. // increased for the metric against which the quota limits are defined.
  91. // The value must not be negative.
  92. map<string, int64> metric_costs = 2;
  93. }
  94. // `QuotaLimit` defines a specific limit that applies over a specified duration
  95. // for a limit type. There can be at most one limit for a duration and limit
  96. // type combination defined within a `QuotaGroup`.
  97. message QuotaLimit {
  98. // Name of the quota limit.
  99. //
  100. // The name must be provided, and it must be unique within the service. The
  101. // name can only include alphanumeric characters as well as '-'.
  102. //
  103. // The maximum length of the limit name is 64 characters.
  104. string name = 6;
  105. // Optional. User-visible, extended description for this quota limit.
  106. // Should be used only when more context is needed to understand this limit
  107. // than provided by the limit's display name (see: `display_name`).
  108. string description = 2;
  109. // Default number of tokens that can be consumed during the specified
  110. // duration. This is the number of tokens assigned when a client
  111. // application developer activates the service for his/her project.
  112. //
  113. // Specifying a value of 0 will block all requests. This can be used if you
  114. // are provisioning quota to selected consumers and blocking others.
  115. // Similarly, a value of -1 will indicate an unlimited quota. No other
  116. // negative values are allowed.
  117. //
  118. // Used by group-based quotas only.
  119. int64 default_limit = 3;
  120. // Maximum number of tokens that can be consumed during the specified
  121. // duration. Client application developers can override the default limit up
  122. // to this maximum. If specified, this value cannot be set to a value less
  123. // than the default limit. If not specified, it is set to the default limit.
  124. //
  125. // To allow clients to apply overrides with no upper bound, set this to -1,
  126. // indicating unlimited maximum quota.
  127. //
  128. // Used by group-based quotas only.
  129. int64 max_limit = 4;
  130. // Free tier value displayed in the Developers Console for this limit.
  131. // The free tier is the number of tokens that will be subtracted from the
  132. // billed amount when billing is enabled.
  133. // This field can only be set on a limit with duration "1d", in a billable
  134. // group; it is invalid on any other limit. If this field is not set, it
  135. // defaults to 0, indicating that there is no free tier for this service.
  136. //
  137. // Used by group-based quotas only.
  138. int64 free_tier = 7;
  139. // Duration of this limit in textual notation. Must be "100s" or "1d".
  140. //
  141. // Used by group-based quotas only.
  142. string duration = 5;
  143. // The name of the metric this quota limit applies to. The quota limits with
  144. // the same metric will be checked together during runtime. The metric must be
  145. // defined within the service config.
  146. string metric = 8;
  147. // Specify the unit of the quota limit. It uses the same syntax as
  148. // [Metric.unit][]. The supported unit kinds are determined by the quota
  149. // backend system.
  150. //
  151. // Here are some examples:
  152. // * "1/min/{project}" for quota per minute per project.
  153. //
  154. // Note: the order of unit components is insignificant.
  155. // The "1" at the beginning is required to follow the metric unit syntax.
  156. string unit = 9;
  157. // Tiered limit values. You must specify this as a key:value pair, with an
  158. // integer value that is the maximum number of requests allowed for the
  159. // specified unit. Currently only STANDARD is supported.
  160. map<string, int64> values = 10;
  161. // User-visible display name for this limit.
  162. // Optional. If not set, the UI will provide a default display name based on
  163. // the quota configuration. This field can be used to override the default
  164. // display name generated from the configuration.
  165. string display_name = 12;
  166. }