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

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