google-cloud-cloud_quotas-v1 0.a → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +149 -0
  4. data/README.md +144 -8
  5. data/lib/google/api/cloudquotas/v1/cloudquotas_pb.rb +58 -0
  6. data/lib/google/api/cloudquotas/v1/cloudquotas_services_pb.rb +62 -0
  7. data/lib/google/api/cloudquotas/v1/resources_pb.rb +58 -0
  8. data/lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb +979 -0
  9. data/lib/google/cloud/cloud_quotas/v1/cloud_quotas/credentials.rb +47 -0
  10. data/lib/google/cloud/cloud_quotas/v1/cloud_quotas/paths.rb +265 -0
  11. data/lib/google/cloud/cloud_quotas/v1/cloud_quotas/rest/client.rb +907 -0
  12. data/lib/google/cloud/cloud_quotas/v1/cloud_quotas/rest/service_stub.rb +492 -0
  13. data/lib/google/cloud/cloud_quotas/v1/cloud_quotas/rest.rb +58 -0
  14. data/lib/google/cloud/cloud_quotas/v1/cloud_quotas.rb +61 -0
  15. data/lib/google/cloud/cloud_quotas/v1/rest.rb +37 -0
  16. data/lib/google/cloud/cloud_quotas/v1/version.rb +7 -2
  17. data/lib/google/cloud/cloud_quotas/v1.rb +45 -0
  18. data/lib/google-cloud-cloud_quotas-v1.rb +21 -0
  19. data/proto_docs/README.md +4 -0
  20. data/proto_docs/google/api/client.rb +394 -0
  21. data/proto_docs/google/api/cloudquotas/v1/cloudquotas.rb +196 -0
  22. data/proto_docs/google/api/cloudquotas/v1/resources.rb +332 -0
  23. data/proto_docs/google/api/field_behavior.rb +85 -0
  24. data/proto_docs/google/api/launch_stage.rb +71 -0
  25. data/proto_docs/google/api/resource.rb +222 -0
  26. data/proto_docs/google/protobuf/duration.rb +98 -0
  27. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  28. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  29. data/proto_docs/google/protobuf/wrappers.rb +121 -0
  30. metadata +184 -10
@@ -0,0 +1,907 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/api/cloudquotas/v1/cloudquotas_pb"
21
+ require "google/cloud/cloud_quotas/v1/cloud_quotas/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module CloudQuotas
26
+ module V1
27
+ module CloudQuotas
28
+ module Rest
29
+ ##
30
+ # REST client for the CloudQuotas service.
31
+ #
32
+ # The Cloud Quotas API is an infrastructure service for Google Cloud that lets
33
+ # service consumers list and manage their resource usage limits.
34
+ #
35
+ # - List/Get the metadata and current status of the quotas for a service.
36
+ # - Create/Update quota preferencess that declare the preferred quota values.
37
+ # - Check the status of a quota preference request.
38
+ # - List/Get pending and historical quota preference.
39
+ #
40
+ class Client
41
+ include Paths
42
+
43
+ # @private
44
+ attr_reader :cloud_quotas_stub
45
+
46
+ ##
47
+ # Configure the CloudQuotas Client class.
48
+ #
49
+ # See {::Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client::Configuration}
50
+ # for a description of the configuration fields.
51
+ #
52
+ # @example
53
+ #
54
+ # # Modify the configuration for all CloudQuotas clients
55
+ # ::Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.configure do |config|
56
+ # config.timeout = 10.0
57
+ # end
58
+ #
59
+ # @yield [config] Configure the Client client.
60
+ # @yieldparam config [Client::Configuration]
61
+ #
62
+ # @return [Client::Configuration]
63
+ #
64
+ def self.configure
65
+ @configure ||= begin
66
+ namespace = ["Google", "Cloud", "CloudQuotas", "V1"]
67
+ parent_config = while namespace.any?
68
+ parent_name = namespace.join "::"
69
+ parent_const = const_get parent_name
70
+ break parent_const.configure if parent_const.respond_to? :configure
71
+ namespace.pop
72
+ end
73
+ default_config = Client::Configuration.new parent_config
74
+
75
+ default_config.rpcs.list_quota_infos.timeout = 60.0
76
+ default_config.rpcs.list_quota_infos.retry_policy = {
77
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
78
+ }
79
+
80
+ default_config.rpcs.get_quota_info.timeout = 60.0
81
+ default_config.rpcs.get_quota_info.retry_policy = {
82
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
83
+ }
84
+
85
+ default_config.rpcs.list_quota_preferences.timeout = 60.0
86
+ default_config.rpcs.list_quota_preferences.retry_policy = {
87
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
88
+ }
89
+
90
+ default_config.rpcs.get_quota_preference.timeout = 60.0
91
+ default_config.rpcs.get_quota_preference.retry_policy = {
92
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
93
+ }
94
+
95
+ default_config.rpcs.create_quota_preference.timeout = 60.0
96
+ default_config.rpcs.create_quota_preference.retry_policy = {
97
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
98
+ }
99
+
100
+ default_config.rpcs.update_quota_preference.timeout = 60.0
101
+ default_config.rpcs.update_quota_preference.retry_policy = {
102
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
103
+ }
104
+
105
+ default_config
106
+ end
107
+ yield @configure if block_given?
108
+ @configure
109
+ end
110
+
111
+ ##
112
+ # Configure the CloudQuotas Client instance.
113
+ #
114
+ # The configuration is set to the derived mode, meaning that values can be changed,
115
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
116
+ # should be made on {Client.configure}.
117
+ #
118
+ # See {::Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client::Configuration}
119
+ # for a description of the configuration fields.
120
+ #
121
+ # @yield [config] Configure the Client client.
122
+ # @yieldparam config [Client::Configuration]
123
+ #
124
+ # @return [Client::Configuration]
125
+ #
126
+ def configure
127
+ yield @config if block_given?
128
+ @config
129
+ end
130
+
131
+ ##
132
+ # Create a new CloudQuotas REST client object.
133
+ #
134
+ # @example
135
+ #
136
+ # # Create a client using the default configuration
137
+ # client = ::Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.new
138
+ #
139
+ # # Create a client using a custom configuration
140
+ # client = ::Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.new do |config|
141
+ # config.timeout = 10.0
142
+ # end
143
+ #
144
+ # @yield [config] Configure the CloudQuotas client.
145
+ # @yieldparam config [Client::Configuration]
146
+ #
147
+ def initialize
148
+ # Create the configuration object
149
+ @config = Configuration.new Client.configure
150
+
151
+ # Yield the configuration if needed
152
+ yield @config if block_given?
153
+
154
+ # Create credentials
155
+ credentials = @config.credentials
156
+ # Use self-signed JWT if the endpoint is unchanged from default,
157
+ # but only if the default endpoint does not have a region prefix.
158
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
159
+ !@config.endpoint.split(".").first.include?("-")
160
+ credentials ||= Credentials.default scope: @config.scope,
161
+ enable_self_signed_jwt: enable_self_signed_jwt
162
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
163
+ credentials = Credentials.new credentials, scope: @config.scope
164
+ end
165
+
166
+ @quota_project_id = @config.quota_project
167
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
168
+
169
+ @cloud_quotas_stub = ::Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
170
+ end
171
+
172
+ # Service calls
173
+
174
+ ##
175
+ # Lists QuotaInfos of all quotas for a given project, folder or organization.
176
+ #
177
+ # @overload list_quota_infos(request, options = nil)
178
+ # Pass arguments to `list_quota_infos` via a request object, either of type
179
+ # {::Google::Cloud::CloudQuotas::V1::ListQuotaInfosRequest} or an equivalent Hash.
180
+ #
181
+ # @param request [::Google::Cloud::CloudQuotas::V1::ListQuotaInfosRequest, ::Hash]
182
+ # A request object representing the call parameters. Required. To specify no
183
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
184
+ # @param options [::Gapic::CallOptions, ::Hash]
185
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
186
+ #
187
+ # @overload list_quota_infos(parent: nil, page_size: nil, page_token: nil)
188
+ # Pass arguments to `list_quota_infos` via keyword arguments. Note that at
189
+ # least one keyword argument is required. To specify no parameters, or to keep all
190
+ # the default parameter values, pass an empty Hash as a request object (see above).
191
+ #
192
+ # @param parent [::String]
193
+ # Required. Parent value of QuotaInfo resources.
194
+ # Listing across different resource containers (such as 'projects/-') is not
195
+ # allowed.
196
+ #
197
+ # Example names:
198
+ # `projects/123/locations/global/services/compute.googleapis.com`
199
+ # `folders/234/locations/global/services/compute.googleapis.com`
200
+ # `organizations/345/locations/global/services/compute.googleapis.com`
201
+ # @param page_size [::Integer]
202
+ # Optional. Requested page size. Server may return fewer items than
203
+ # requested. If unspecified, server will pick an appropriate default.
204
+ # @param page_token [::String]
205
+ # Optional. A token identifying a page of results the server should return.
206
+ # @yield [result, operation] Access the result along with the TransportOperation object
207
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::CloudQuotas::V1::QuotaInfo>]
208
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
209
+ #
210
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::CloudQuotas::V1::QuotaInfo>]
211
+ #
212
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
213
+ #
214
+ # @example Basic example
215
+ # require "google/cloud/cloud_quotas/v1"
216
+ #
217
+ # # Create a client object. The client can be reused for multiple calls.
218
+ # client = Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.new
219
+ #
220
+ # # Create a request. To set request fields, pass in keyword arguments.
221
+ # request = Google::Cloud::CloudQuotas::V1::ListQuotaInfosRequest.new
222
+ #
223
+ # # Call the list_quota_infos method.
224
+ # result = client.list_quota_infos request
225
+ #
226
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
227
+ # # over elements, and API calls will be issued to fetch pages as needed.
228
+ # result.each do |item|
229
+ # # Each element is of type ::Google::Cloud::CloudQuotas::V1::QuotaInfo.
230
+ # p item
231
+ # end
232
+ #
233
+ def list_quota_infos request, options = nil
234
+ raise ::ArgumentError, "request must be provided" if request.nil?
235
+
236
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::ListQuotaInfosRequest
237
+
238
+ # Converts hash and nil to an options object
239
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
240
+
241
+ # Customize the options with defaults
242
+ call_metadata = @config.rpcs.list_quota_infos.metadata.to_h
243
+
244
+ # Set x-goog-api-client and x-goog-user-project headers
245
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
246
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
247
+ gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION,
248
+ transports_version_send: [:rest]
249
+
250
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
251
+
252
+ options.apply_defaults timeout: @config.rpcs.list_quota_infos.timeout,
253
+ metadata: call_metadata,
254
+ retry_policy: @config.rpcs.list_quota_infos.retry_policy
255
+
256
+ options.apply_defaults timeout: @config.timeout,
257
+ metadata: @config.metadata,
258
+ retry_policy: @config.retry_policy
259
+
260
+ @cloud_quotas_stub.list_quota_infos request, options do |result, operation|
261
+ result = ::Gapic::Rest::PagedEnumerable.new @cloud_quotas_stub, :list_quota_infos, "quota_infos", request, result, options
262
+ yield result, operation if block_given?
263
+ return result
264
+ end
265
+ rescue ::Gapic::Rest::Error => e
266
+ raise ::Google::Cloud::Error.from_error(e)
267
+ end
268
+
269
+ ##
270
+ # Retrieve the QuotaInfo of a quota for a project, folder or organization.
271
+ #
272
+ # @overload get_quota_info(request, options = nil)
273
+ # Pass arguments to `get_quota_info` via a request object, either of type
274
+ # {::Google::Cloud::CloudQuotas::V1::GetQuotaInfoRequest} or an equivalent Hash.
275
+ #
276
+ # @param request [::Google::Cloud::CloudQuotas::V1::GetQuotaInfoRequest, ::Hash]
277
+ # A request object representing the call parameters. Required. To specify no
278
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
279
+ # @param options [::Gapic::CallOptions, ::Hash]
280
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
281
+ #
282
+ # @overload get_quota_info(name: nil)
283
+ # Pass arguments to `get_quota_info` via keyword arguments. Note that at
284
+ # least one keyword argument is required. To specify no parameters, or to keep all
285
+ # the default parameter values, pass an empty Hash as a request object (see above).
286
+ #
287
+ # @param name [::String]
288
+ # Required. The resource name of the quota info.
289
+ #
290
+ # An example name:
291
+ # `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion`
292
+ # @yield [result, operation] Access the result along with the TransportOperation object
293
+ # @yieldparam result [::Google::Cloud::CloudQuotas::V1::QuotaInfo]
294
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
295
+ #
296
+ # @return [::Google::Cloud::CloudQuotas::V1::QuotaInfo]
297
+ #
298
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
299
+ #
300
+ # @example Basic example
301
+ # require "google/cloud/cloud_quotas/v1"
302
+ #
303
+ # # Create a client object. The client can be reused for multiple calls.
304
+ # client = Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.new
305
+ #
306
+ # # Create a request. To set request fields, pass in keyword arguments.
307
+ # request = Google::Cloud::CloudQuotas::V1::GetQuotaInfoRequest.new
308
+ #
309
+ # # Call the get_quota_info method.
310
+ # result = client.get_quota_info request
311
+ #
312
+ # # The returned object is of type Google::Cloud::CloudQuotas::V1::QuotaInfo.
313
+ # p result
314
+ #
315
+ def get_quota_info request, options = nil
316
+ raise ::ArgumentError, "request must be provided" if request.nil?
317
+
318
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::GetQuotaInfoRequest
319
+
320
+ # Converts hash and nil to an options object
321
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
322
+
323
+ # Customize the options with defaults
324
+ call_metadata = @config.rpcs.get_quota_info.metadata.to_h
325
+
326
+ # Set x-goog-api-client and x-goog-user-project headers
327
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
328
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
329
+ gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION,
330
+ transports_version_send: [:rest]
331
+
332
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
333
+
334
+ options.apply_defaults timeout: @config.rpcs.get_quota_info.timeout,
335
+ metadata: call_metadata,
336
+ retry_policy: @config.rpcs.get_quota_info.retry_policy
337
+
338
+ options.apply_defaults timeout: @config.timeout,
339
+ metadata: @config.metadata,
340
+ retry_policy: @config.retry_policy
341
+
342
+ @cloud_quotas_stub.get_quota_info request, options do |result, operation|
343
+ yield result, operation if block_given?
344
+ return result
345
+ end
346
+ rescue ::Gapic::Rest::Error => e
347
+ raise ::Google::Cloud::Error.from_error(e)
348
+ end
349
+
350
+ ##
351
+ # Lists QuotaPreferences in a given project, folder or organization.
352
+ #
353
+ # @overload list_quota_preferences(request, options = nil)
354
+ # Pass arguments to `list_quota_preferences` via a request object, either of type
355
+ # {::Google::Cloud::CloudQuotas::V1::ListQuotaPreferencesRequest} or an equivalent Hash.
356
+ #
357
+ # @param request [::Google::Cloud::CloudQuotas::V1::ListQuotaPreferencesRequest, ::Hash]
358
+ # A request object representing the call parameters. Required. To specify no
359
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
360
+ # @param options [::Gapic::CallOptions, ::Hash]
361
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
362
+ #
363
+ # @overload list_quota_preferences(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
364
+ # Pass arguments to `list_quota_preferences` via keyword arguments. Note that at
365
+ # least one keyword argument is required. To specify no parameters, or to keep all
366
+ # the default parameter values, pass an empty Hash as a request object (see above).
367
+ #
368
+ # @param parent [::String]
369
+ # Required. Parent value of QuotaPreference resources.
370
+ # Listing across different resource containers (such as 'projects/-') is not
371
+ # allowed.
372
+ #
373
+ # When the value starts with 'folders' or 'organizations', it lists the
374
+ # QuotaPreferences for org quotas in the container. It does not list the
375
+ # QuotaPreferences in the descendant projects of the container.
376
+ #
377
+ # Example parents:
378
+ # `projects/123/locations/global`
379
+ # @param page_size [::Integer]
380
+ # Optional. Requested page size. Server may return fewer items than
381
+ # requested. If unspecified, server will pick an appropriate default.
382
+ # @param page_token [::String]
383
+ # Optional. A token identifying a page of results the server should return.
384
+ # @param filter [::String]
385
+ # Optional. Filter result QuotaPreferences by their state, type,
386
+ # create/update time range.
387
+ #
388
+ # Example filters:
389
+ # `state=PENDING OR state=PENDING_PARTIALLY_GRANTED`
390
+ # `state=PENDING OR state=PENDING_PARTIALLY_GRANTED AND
391
+ # creation_time>2022-12-03T10:30:00`
392
+ #
393
+ # If no filter is provided, returns all pending quota preferences.
394
+ # @param order_by [::String]
395
+ # Optional. How to order of the results. By default, the results are ordered
396
+ # by create time.
397
+ #
398
+ # Example orders:
399
+ # `type`
400
+ # `state, create_time`
401
+ # @yield [result, operation] Access the result along with the TransportOperation object
402
+ # @yieldparam result [::Google::Cloud::CloudQuotas::V1::ListQuotaPreferencesResponse]
403
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
404
+ #
405
+ # @return [::Google::Cloud::CloudQuotas::V1::ListQuotaPreferencesResponse]
406
+ #
407
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
408
+ #
409
+ # @example Basic example
410
+ # require "google/cloud/cloud_quotas/v1"
411
+ #
412
+ # # Create a client object. The client can be reused for multiple calls.
413
+ # client = Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.new
414
+ #
415
+ # # Create a request. To set request fields, pass in keyword arguments.
416
+ # request = Google::Cloud::CloudQuotas::V1::ListQuotaPreferencesRequest.new
417
+ #
418
+ # # Call the list_quota_preferences method.
419
+ # result = client.list_quota_preferences request
420
+ #
421
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
422
+ # # over elements, and API calls will be issued to fetch pages as needed.
423
+ # result.each do |item|
424
+ # # Each element is of type ::Google::Cloud::CloudQuotas::V1::QuotaPreference.
425
+ # p item
426
+ # end
427
+ #
428
+ def list_quota_preferences request, options = nil
429
+ raise ::ArgumentError, "request must be provided" if request.nil?
430
+
431
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::ListQuotaPreferencesRequest
432
+
433
+ # Converts hash and nil to an options object
434
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
435
+
436
+ # Customize the options with defaults
437
+ call_metadata = @config.rpcs.list_quota_preferences.metadata.to_h
438
+
439
+ # Set x-goog-api-client and x-goog-user-project headers
440
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
441
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
442
+ gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION,
443
+ transports_version_send: [:rest]
444
+
445
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
446
+
447
+ options.apply_defaults timeout: @config.rpcs.list_quota_preferences.timeout,
448
+ metadata: call_metadata,
449
+ retry_policy: @config.rpcs.list_quota_preferences.retry_policy
450
+
451
+ options.apply_defaults timeout: @config.timeout,
452
+ metadata: @config.metadata,
453
+ retry_policy: @config.retry_policy
454
+
455
+ @cloud_quotas_stub.list_quota_preferences request, options do |result, operation|
456
+ yield result, operation if block_given?
457
+ return result
458
+ end
459
+ rescue ::Gapic::Rest::Error => e
460
+ raise ::Google::Cloud::Error.from_error(e)
461
+ end
462
+
463
+ ##
464
+ # Gets details of a single QuotaPreference.
465
+ #
466
+ # @overload get_quota_preference(request, options = nil)
467
+ # Pass arguments to `get_quota_preference` via a request object, either of type
468
+ # {::Google::Cloud::CloudQuotas::V1::GetQuotaPreferenceRequest} or an equivalent Hash.
469
+ #
470
+ # @param request [::Google::Cloud::CloudQuotas::V1::GetQuotaPreferenceRequest, ::Hash]
471
+ # A request object representing the call parameters. Required. To specify no
472
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
473
+ # @param options [::Gapic::CallOptions, ::Hash]
474
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
475
+ #
476
+ # @overload get_quota_preference(name: nil)
477
+ # Pass arguments to `get_quota_preference` via keyword arguments. Note that at
478
+ # least one keyword argument is required. To specify no parameters, or to keep all
479
+ # the default parameter values, pass an empty Hash as a request object (see above).
480
+ #
481
+ # @param name [::String]
482
+ # Required. Name of the resource
483
+ #
484
+ # Example name:
485
+ # `projects/123/locations/global/quota_preferences/my-config-for-us-east1`
486
+ # @yield [result, operation] Access the result along with the TransportOperation object
487
+ # @yieldparam result [::Google::Cloud::CloudQuotas::V1::QuotaPreference]
488
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
489
+ #
490
+ # @return [::Google::Cloud::CloudQuotas::V1::QuotaPreference]
491
+ #
492
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
493
+ #
494
+ # @example Basic example
495
+ # require "google/cloud/cloud_quotas/v1"
496
+ #
497
+ # # Create a client object. The client can be reused for multiple calls.
498
+ # client = Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.new
499
+ #
500
+ # # Create a request. To set request fields, pass in keyword arguments.
501
+ # request = Google::Cloud::CloudQuotas::V1::GetQuotaPreferenceRequest.new
502
+ #
503
+ # # Call the get_quota_preference method.
504
+ # result = client.get_quota_preference request
505
+ #
506
+ # # The returned object is of type Google::Cloud::CloudQuotas::V1::QuotaPreference.
507
+ # p result
508
+ #
509
+ def get_quota_preference request, options = nil
510
+ raise ::ArgumentError, "request must be provided" if request.nil?
511
+
512
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::GetQuotaPreferenceRequest
513
+
514
+ # Converts hash and nil to an options object
515
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
516
+
517
+ # Customize the options with defaults
518
+ call_metadata = @config.rpcs.get_quota_preference.metadata.to_h
519
+
520
+ # Set x-goog-api-client and x-goog-user-project headers
521
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
522
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
523
+ gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION,
524
+ transports_version_send: [:rest]
525
+
526
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
527
+
528
+ options.apply_defaults timeout: @config.rpcs.get_quota_preference.timeout,
529
+ metadata: call_metadata,
530
+ retry_policy: @config.rpcs.get_quota_preference.retry_policy
531
+
532
+ options.apply_defaults timeout: @config.timeout,
533
+ metadata: @config.metadata,
534
+ retry_policy: @config.retry_policy
535
+
536
+ @cloud_quotas_stub.get_quota_preference request, options do |result, operation|
537
+ yield result, operation if block_given?
538
+ return result
539
+ end
540
+ rescue ::Gapic::Rest::Error => e
541
+ raise ::Google::Cloud::Error.from_error(e)
542
+ end
543
+
544
+ ##
545
+ # Creates a new QuotaPreference that declares the desired value for a quota.
546
+ #
547
+ # @overload create_quota_preference(request, options = nil)
548
+ # Pass arguments to `create_quota_preference` via a request object, either of type
549
+ # {::Google::Cloud::CloudQuotas::V1::CreateQuotaPreferenceRequest} or an equivalent Hash.
550
+ #
551
+ # @param request [::Google::Cloud::CloudQuotas::V1::CreateQuotaPreferenceRequest, ::Hash]
552
+ # A request object representing the call parameters. Required. To specify no
553
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
554
+ # @param options [::Gapic::CallOptions, ::Hash]
555
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
556
+ #
557
+ # @overload create_quota_preference(parent: nil, quota_preference_id: nil, quota_preference: nil, ignore_safety_checks: nil)
558
+ # Pass arguments to `create_quota_preference` via keyword arguments. Note that at
559
+ # least one keyword argument is required. To specify no parameters, or to keep all
560
+ # the default parameter values, pass an empty Hash as a request object (see above).
561
+ #
562
+ # @param parent [::String]
563
+ # Required. Value for parent.
564
+ #
565
+ # Example:
566
+ # `projects/123/locations/global`
567
+ # @param quota_preference_id [::String]
568
+ # Optional. Id of the requesting object, must be unique under its parent.
569
+ # If client does not set this field, the service will generate one.
570
+ # @param quota_preference [::Google::Cloud::CloudQuotas::V1::QuotaPreference, ::Hash]
571
+ # Required. The resource being created
572
+ # @param ignore_safety_checks [::Array<::Google::Cloud::CloudQuotas::V1::QuotaSafetyCheck>]
573
+ # The list of quota safety checks to be ignored.
574
+ # @yield [result, operation] Access the result along with the TransportOperation object
575
+ # @yieldparam result [::Google::Cloud::CloudQuotas::V1::QuotaPreference]
576
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
577
+ #
578
+ # @return [::Google::Cloud::CloudQuotas::V1::QuotaPreference]
579
+ #
580
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
581
+ #
582
+ # @example Basic example
583
+ # require "google/cloud/cloud_quotas/v1"
584
+ #
585
+ # # Create a client object. The client can be reused for multiple calls.
586
+ # client = Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.new
587
+ #
588
+ # # Create a request. To set request fields, pass in keyword arguments.
589
+ # request = Google::Cloud::CloudQuotas::V1::CreateQuotaPreferenceRequest.new
590
+ #
591
+ # # Call the create_quota_preference method.
592
+ # result = client.create_quota_preference request
593
+ #
594
+ # # The returned object is of type Google::Cloud::CloudQuotas::V1::QuotaPreference.
595
+ # p result
596
+ #
597
+ def create_quota_preference request, options = nil
598
+ raise ::ArgumentError, "request must be provided" if request.nil?
599
+
600
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::CreateQuotaPreferenceRequest
601
+
602
+ # Converts hash and nil to an options object
603
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
604
+
605
+ # Customize the options with defaults
606
+ call_metadata = @config.rpcs.create_quota_preference.metadata.to_h
607
+
608
+ # Set x-goog-api-client and x-goog-user-project headers
609
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
610
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
611
+ gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION,
612
+ transports_version_send: [:rest]
613
+
614
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
615
+
616
+ options.apply_defaults timeout: @config.rpcs.create_quota_preference.timeout,
617
+ metadata: call_metadata,
618
+ retry_policy: @config.rpcs.create_quota_preference.retry_policy
619
+
620
+ options.apply_defaults timeout: @config.timeout,
621
+ metadata: @config.metadata,
622
+ retry_policy: @config.retry_policy
623
+
624
+ @cloud_quotas_stub.create_quota_preference request, options do |result, operation|
625
+ yield result, operation if block_given?
626
+ return result
627
+ end
628
+ rescue ::Gapic::Rest::Error => e
629
+ raise ::Google::Cloud::Error.from_error(e)
630
+ end
631
+
632
+ ##
633
+ # Updates the parameters of a single QuotaPreference. It can updates the
634
+ # config in any states, not just the ones pending approval.
635
+ #
636
+ # @overload update_quota_preference(request, options = nil)
637
+ # Pass arguments to `update_quota_preference` via a request object, either of type
638
+ # {::Google::Cloud::CloudQuotas::V1::UpdateQuotaPreferenceRequest} or an equivalent Hash.
639
+ #
640
+ # @param request [::Google::Cloud::CloudQuotas::V1::UpdateQuotaPreferenceRequest, ::Hash]
641
+ # A request object representing the call parameters. Required. To specify no
642
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
643
+ # @param options [::Gapic::CallOptions, ::Hash]
644
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
645
+ #
646
+ # @overload update_quota_preference(update_mask: nil, quota_preference: nil, allow_missing: nil, validate_only: nil, ignore_safety_checks: nil)
647
+ # Pass arguments to `update_quota_preference` via keyword arguments. Note that at
648
+ # least one keyword argument is required. To specify no parameters, or to keep all
649
+ # the default parameter values, pass an empty Hash as a request object (see above).
650
+ #
651
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
652
+ # Optional. Field mask is used to specify the fields to be overwritten in the
653
+ # QuotaPreference resource by the update.
654
+ # The fields specified in the update_mask are relative to the resource, not
655
+ # the full request. A field will be overwritten if it is in the mask. If the
656
+ # user does not provide a mask then all fields will be overwritten.
657
+ # @param quota_preference [::Google::Cloud::CloudQuotas::V1::QuotaPreference, ::Hash]
658
+ # Required. The resource being updated
659
+ # @param allow_missing [::Boolean]
660
+ # Optional. If set to true, and the quota preference is not found, a new one
661
+ # will be created. In this situation, `update_mask` is ignored.
662
+ # @param validate_only [::Boolean]
663
+ # Optional. If set to true, validate the request, but do not actually update.
664
+ # Note that a request being valid does not mean that the request is
665
+ # guaranteed to be fulfilled.
666
+ # @param ignore_safety_checks [::Array<::Google::Cloud::CloudQuotas::V1::QuotaSafetyCheck>]
667
+ # The list of quota safety checks to be ignored.
668
+ # @yield [result, operation] Access the result along with the TransportOperation object
669
+ # @yieldparam result [::Google::Cloud::CloudQuotas::V1::QuotaPreference]
670
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
671
+ #
672
+ # @return [::Google::Cloud::CloudQuotas::V1::QuotaPreference]
673
+ #
674
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
675
+ #
676
+ # @example Basic example
677
+ # require "google/cloud/cloud_quotas/v1"
678
+ #
679
+ # # Create a client object. The client can be reused for multiple calls.
680
+ # client = Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.new
681
+ #
682
+ # # Create a request. To set request fields, pass in keyword arguments.
683
+ # request = Google::Cloud::CloudQuotas::V1::UpdateQuotaPreferenceRequest.new
684
+ #
685
+ # # Call the update_quota_preference method.
686
+ # result = client.update_quota_preference request
687
+ #
688
+ # # The returned object is of type Google::Cloud::CloudQuotas::V1::QuotaPreference.
689
+ # p result
690
+ #
691
+ def update_quota_preference request, options = nil
692
+ raise ::ArgumentError, "request must be provided" if request.nil?
693
+
694
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::UpdateQuotaPreferenceRequest
695
+
696
+ # Converts hash and nil to an options object
697
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
698
+
699
+ # Customize the options with defaults
700
+ call_metadata = @config.rpcs.update_quota_preference.metadata.to_h
701
+
702
+ # Set x-goog-api-client and x-goog-user-project headers
703
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
704
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
705
+ gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION,
706
+ transports_version_send: [:rest]
707
+
708
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
709
+
710
+ options.apply_defaults timeout: @config.rpcs.update_quota_preference.timeout,
711
+ metadata: call_metadata,
712
+ retry_policy: @config.rpcs.update_quota_preference.retry_policy
713
+
714
+ options.apply_defaults timeout: @config.timeout,
715
+ metadata: @config.metadata,
716
+ retry_policy: @config.retry_policy
717
+
718
+ @cloud_quotas_stub.update_quota_preference request, options do |result, operation|
719
+ yield result, operation if block_given?
720
+ return result
721
+ end
722
+ rescue ::Gapic::Rest::Error => e
723
+ raise ::Google::Cloud::Error.from_error(e)
724
+ end
725
+
726
+ ##
727
+ # Configuration class for the CloudQuotas REST API.
728
+ #
729
+ # This class represents the configuration for CloudQuotas REST,
730
+ # providing control over timeouts, retry behavior, logging, transport
731
+ # parameters, and other low-level controls. Certain parameters can also be
732
+ # applied individually to specific RPCs. See
733
+ # {::Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client::Configuration::Rpcs}
734
+ # for a list of RPCs that can be configured independently.
735
+ #
736
+ # Configuration can be applied globally to all clients, or to a single client
737
+ # on construction.
738
+ #
739
+ # @example
740
+ #
741
+ # # Modify the global config, setting the timeout for
742
+ # # list_quota_infos to 20 seconds,
743
+ # # and all remaining timeouts to 10 seconds.
744
+ # ::Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.configure do |config|
745
+ # config.timeout = 10.0
746
+ # config.rpcs.list_quota_infos.timeout = 20.0
747
+ # end
748
+ #
749
+ # # Apply the above configuration only to a new client.
750
+ # client = ::Google::Cloud::CloudQuotas::V1::CloudQuotas::Rest::Client.new do |config|
751
+ # config.timeout = 10.0
752
+ # config.rpcs.list_quota_infos.timeout = 20.0
753
+ # end
754
+ #
755
+ # @!attribute [rw] endpoint
756
+ # The hostname or hostname:port of the service endpoint.
757
+ # Defaults to `"cloudquotas.googleapis.com"`.
758
+ # @return [::String]
759
+ # @!attribute [rw] credentials
760
+ # Credentials to send with calls. You may provide any of the following types:
761
+ # * (`String`) The path to a service account key file in JSON format
762
+ # * (`Hash`) A service account key as a Hash
763
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
764
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
765
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
766
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
767
+ # * (`nil`) indicating no credentials
768
+ # @return [::Object]
769
+ # @!attribute [rw] scope
770
+ # The OAuth scopes
771
+ # @return [::Array<::String>]
772
+ # @!attribute [rw] lib_name
773
+ # The library name as recorded in instrumentation and logging
774
+ # @return [::String]
775
+ # @!attribute [rw] lib_version
776
+ # The library version as recorded in instrumentation and logging
777
+ # @return [::String]
778
+ # @!attribute [rw] timeout
779
+ # The call timeout in seconds.
780
+ # @return [::Numeric]
781
+ # @!attribute [rw] metadata
782
+ # Additional headers to be sent with the call.
783
+ # @return [::Hash{::Symbol=>::String}]
784
+ # @!attribute [rw] retry_policy
785
+ # The retry policy. The value is a hash with the following keys:
786
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
787
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
788
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
789
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
790
+ # trigger a retry.
791
+ # @return [::Hash]
792
+ # @!attribute [rw] quota_project
793
+ # A separate project against which to charge quota.
794
+ # @return [::String]
795
+ #
796
+ class Configuration
797
+ extend ::Gapic::Config
798
+
799
+ DEFAULT_ENDPOINT = "cloudquotas.googleapis.com"
800
+
801
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
802
+ config_attr :credentials, nil do |value|
803
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
804
+ allowed.any? { |klass| klass === value }
805
+ end
806
+ config_attr :scope, nil, ::String, ::Array, nil
807
+ config_attr :lib_name, nil, ::String, nil
808
+ config_attr :lib_version, nil, ::String, nil
809
+ config_attr :timeout, nil, ::Numeric, nil
810
+ config_attr :metadata, nil, ::Hash, nil
811
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
812
+ config_attr :quota_project, nil, ::String, nil
813
+
814
+ # @private
815
+ def initialize parent_config = nil
816
+ @parent_config = parent_config unless parent_config.nil?
817
+
818
+ yield self if block_given?
819
+ end
820
+
821
+ ##
822
+ # Configurations for individual RPCs
823
+ # @return [Rpcs]
824
+ #
825
+ def rpcs
826
+ @rpcs ||= begin
827
+ parent_rpcs = nil
828
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
829
+ Rpcs.new parent_rpcs
830
+ end
831
+ end
832
+
833
+ ##
834
+ # Configuration RPC class for the CloudQuotas API.
835
+ #
836
+ # Includes fields providing the configuration for each RPC in this service.
837
+ # Each configuration object is of type `Gapic::Config::Method` and includes
838
+ # the following configuration fields:
839
+ #
840
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
841
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
842
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
843
+ # include the following keys:
844
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
845
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
846
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
847
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
848
+ # trigger a retry.
849
+ #
850
+ class Rpcs
851
+ ##
852
+ # RPC-specific configuration for `list_quota_infos`
853
+ # @return [::Gapic::Config::Method]
854
+ #
855
+ attr_reader :list_quota_infos
856
+ ##
857
+ # RPC-specific configuration for `get_quota_info`
858
+ # @return [::Gapic::Config::Method]
859
+ #
860
+ attr_reader :get_quota_info
861
+ ##
862
+ # RPC-specific configuration for `list_quota_preferences`
863
+ # @return [::Gapic::Config::Method]
864
+ #
865
+ attr_reader :list_quota_preferences
866
+ ##
867
+ # RPC-specific configuration for `get_quota_preference`
868
+ # @return [::Gapic::Config::Method]
869
+ #
870
+ attr_reader :get_quota_preference
871
+ ##
872
+ # RPC-specific configuration for `create_quota_preference`
873
+ # @return [::Gapic::Config::Method]
874
+ #
875
+ attr_reader :create_quota_preference
876
+ ##
877
+ # RPC-specific configuration for `update_quota_preference`
878
+ # @return [::Gapic::Config::Method]
879
+ #
880
+ attr_reader :update_quota_preference
881
+
882
+ # @private
883
+ def initialize parent_rpcs = nil
884
+ list_quota_infos_config = parent_rpcs.list_quota_infos if parent_rpcs.respond_to? :list_quota_infos
885
+ @list_quota_infos = ::Gapic::Config::Method.new list_quota_infos_config
886
+ get_quota_info_config = parent_rpcs.get_quota_info if parent_rpcs.respond_to? :get_quota_info
887
+ @get_quota_info = ::Gapic::Config::Method.new get_quota_info_config
888
+ list_quota_preferences_config = parent_rpcs.list_quota_preferences if parent_rpcs.respond_to? :list_quota_preferences
889
+ @list_quota_preferences = ::Gapic::Config::Method.new list_quota_preferences_config
890
+ get_quota_preference_config = parent_rpcs.get_quota_preference if parent_rpcs.respond_to? :get_quota_preference
891
+ @get_quota_preference = ::Gapic::Config::Method.new get_quota_preference_config
892
+ create_quota_preference_config = parent_rpcs.create_quota_preference if parent_rpcs.respond_to? :create_quota_preference
893
+ @create_quota_preference = ::Gapic::Config::Method.new create_quota_preference_config
894
+ update_quota_preference_config = parent_rpcs.update_quota_preference if parent_rpcs.respond_to? :update_quota_preference
895
+ @update_quota_preference = ::Gapic::Config::Method.new update_quota_preference_config
896
+
897
+ yield self if block_given?
898
+ end
899
+ end
900
+ end
901
+ end
902
+ end
903
+ end
904
+ end
905
+ end
906
+ end
907
+ end