Reference documentation and code samples for the Service Usage V1 API class Google::Api::Quota.
Quota configuration helps to achieve fairness and budgeting in service
usage.
The metric based quota configuration works this way:
The service configuration defines a set of metrics.
For API calls, the quota.metric_rules maps methods to metrics with
corresponding costs.
The quota.limits defines limits on the metrics, which will be used for
quota checks at runtime.
An example quota configuration in yaml format:
quota:
limits:
- name: apiWriteQpsPerProject
metric: library.googleapis.com/write_calls
unit: "1/min/\\{project}" # rate limit for consumer projects
values:
STANDARD: 10000
(The metric rules bind all methods to the read_calls metric,
except for the UpdateBook and DeleteBook methods. These two methods
are mapped to the write_calls metric, with the UpdateBook method
consuming at twice rate as the DeleteBook method.)
metric_rules:
- selector: "*"
metric_costs:
library.googleapis.com/read_calls: 1
- selector: google.example.library.v1.LibraryService.UpdateBook
metric_costs:
library.googleapis.com/write_calls: 2
- selector: google.example.library.v1.LibraryService.DeleteBook
metric_costs:
library.googleapis.com/write_calls: 1
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Service Usage V1 API - Class Google::Api::Quota (v1.3.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.3.0 (latest)](/ruby/docs/reference/google-cloud-service_usage-v1/latest/Google-Api-Quota)\n- [1.2.1](/ruby/docs/reference/google-cloud-service_usage-v1/1.2.1/Google-Api-Quota)\n- [1.1.0](/ruby/docs/reference/google-cloud-service_usage-v1/1.1.0/Google-Api-Quota)\n- [1.0.1](/ruby/docs/reference/google-cloud-service_usage-v1/1.0.1/Google-Api-Quota)\n- [0.7.0](/ruby/docs/reference/google-cloud-service_usage-v1/0.7.0/Google-Api-Quota)\n- [0.6.2](/ruby/docs/reference/google-cloud-service_usage-v1/0.6.2/Google-Api-Quota)\n- [0.5.0](/ruby/docs/reference/google-cloud-service_usage-v1/0.5.0/Google-Api-Quota)\n- [0.4.0](/ruby/docs/reference/google-cloud-service_usage-v1/0.4.0/Google-Api-Quota)\n- [0.3.1](/ruby/docs/reference/google-cloud-service_usage-v1/0.3.1/Google-Api-Quota)\n- [0.2.1](/ruby/docs/reference/google-cloud-service_usage-v1/0.2.1/Google-Api-Quota)\n- [0.1.4](/ruby/docs/reference/google-cloud-service_usage-v1/0.1.4/Google-Api-Quota) \nReference documentation and code samples for the Service Usage V1 API class Google::Api::Quota.\n\nQuota configuration helps to achieve fairness and budgeting in service\nusage.\n\nThe metric based quota configuration works this way:\n\n- The service configuration defines a set of metrics.\n- For API calls, the quota.metric_rules maps methods to metrics with corresponding costs.\n- The quota.limits defines limits on the metrics, which will be used for quota checks at runtime.\n\nAn example quota configuration in yaml format:\n\nquota:\nlimits: \n\n - name: apiWriteQpsPerProject\n metric: library.googleapis.com/write_calls\n unit: \"1/min/\\\\{project}\" # rate limit for consumer projects\n values:\n STANDARD: 10000\n\n\n (The metric rules bind all methods to the read_calls metric,\n except for the UpdateBook and DeleteBook methods. These two methods\n are mapped to the write_calls metric, with the UpdateBook method\n consuming at twice rate as the DeleteBook method.)\n metric_rules:\n - selector: \"*\"\n metric_costs:\n library.googleapis.com/read_calls: 1\n - selector: google.example.library.v1.LibraryService.UpdateBook\n metric_costs:\n library.googleapis.com/write_calls: 2\n - selector: google.example.library.v1.LibraryService.DeleteBook\n metric_costs:\n library.googleapis.com/write_calls: 1\n\nCorresponding Metric definition: \n\n metrics:\n - name: library.googleapis.com/read_calls\n display_name: Read requests\n metric_kind: DELTA\n value_type: INT64\n\n - name: library.googleapis.com/write_calls\n display_name: Write requests\n metric_kind: DELTA\n value_type: INT64\n\nInherits\n--------\n\n- Object \n\nExtended By\n-----------\n\n- Google::Protobuf::MessageExts::ClassMethods \n\nIncludes\n--------\n\n- Google::Protobuf::MessageExts\n\nMethods\n-------\n\n### #limits\n\n def limits() -\u003e ::Array\u003c::Google::Api::QuotaLimit\u003e\n\n**Returns**\n\n- (::Array\\\u003c[::Google::Api::QuotaLimit](./Google-Api-QuotaLimit)\\\u003e) --- List of QuotaLimit definitions for the service.\n\n### #limits=\n\n def limits=(value) -\u003e ::Array\u003c::Google::Api::QuotaLimit\u003e\n\n**Parameter**\n\n- **value** (::Array\\\u003c[::Google::Api::QuotaLimit](./Google-Api-QuotaLimit)\\\u003e) --- List of QuotaLimit definitions for the service. \n**Returns**\n\n- (::Array\\\u003c[::Google::Api::QuotaLimit](./Google-Api-QuotaLimit)\\\u003e) --- List of QuotaLimit definitions for the service.\n\n### #metric_rules\n\n def metric_rules() -\u003e ::Array\u003c::Google::Api::MetricRule\u003e\n\n**Returns**\n\n- (::Array\\\u003c[::Google::Api::MetricRule](./Google-Api-MetricRule)\\\u003e) --- List of MetricRule definitions, each one mapping a selected method to one or more metrics.\n\n### #metric_rules=\n\n def metric_rules=(value) -\u003e ::Array\u003c::Google::Api::MetricRule\u003e\n\n**Parameter**\n\n- **value** (::Array\\\u003c[::Google::Api::MetricRule](./Google-Api-MetricRule)\\\u003e) --- List of MetricRule definitions, each one mapping a selected method to one or more metrics. \n**Returns**\n\n- (::Array\\\u003c[::Google::Api::MetricRule](./Google-Api-MetricRule)\\\u003e) --- List of MetricRule definitions, each one mapping a selected method to one or more metrics."]]