google-shopping-merchant-quota-v1beta 0.a → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,441 @@
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/shopping/merchant/quota/v1beta/quota_pb"
21
+
22
+ module Google
23
+ module Shopping
24
+ module Merchant
25
+ module Quota
26
+ module V1beta
27
+ module QuotaService
28
+ ##
29
+ # Client for the QuotaService service.
30
+ #
31
+ # Service to get method call quota information per Merchant API method.
32
+ #
33
+ class Client
34
+ # @private
35
+ DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$"
36
+
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :quota_service_stub
41
+
42
+ ##
43
+ # Configure the QuotaService Client class.
44
+ #
45
+ # See {::Google::Shopping::Merchant::Quota::V1beta::QuotaService::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # @example
49
+ #
50
+ # # Modify the configuration for all QuotaService clients
51
+ # ::Google::Shopping::Merchant::Quota::V1beta::QuotaService::Client.configure do |config|
52
+ # config.timeout = 10.0
53
+ # end
54
+ #
55
+ # @yield [config] Configure the Client client.
56
+ # @yieldparam config [Client::Configuration]
57
+ #
58
+ # @return [Client::Configuration]
59
+ #
60
+ def self.configure
61
+ @configure ||= begin
62
+ namespace = ["Google", "Shopping", "Merchant", "Quota", "V1beta"]
63
+ parent_config = while namespace.any?
64
+ parent_name = namespace.join "::"
65
+ parent_const = const_get parent_name
66
+ break parent_const.configure if parent_const.respond_to? :configure
67
+ namespace.pop
68
+ end
69
+ default_config = Client::Configuration.new parent_config
70
+
71
+ default_config.timeout = 60.0
72
+ default_config.retry_policy = {
73
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
74
+ }
75
+
76
+ default_config
77
+ end
78
+ yield @configure if block_given?
79
+ @configure
80
+ end
81
+
82
+ ##
83
+ # Configure the QuotaService Client instance.
84
+ #
85
+ # The configuration is set to the derived mode, meaning that values can be changed,
86
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
87
+ # should be made on {Client.configure}.
88
+ #
89
+ # See {::Google::Shopping::Merchant::Quota::V1beta::QuotaService::Client::Configuration}
90
+ # for a description of the configuration fields.
91
+ #
92
+ # @yield [config] Configure the Client client.
93
+ # @yieldparam config [Client::Configuration]
94
+ #
95
+ # @return [Client::Configuration]
96
+ #
97
+ def configure
98
+ yield @config if block_given?
99
+ @config
100
+ end
101
+
102
+ ##
103
+ # The effective universe domain
104
+ #
105
+ # @return [String]
106
+ #
107
+ def universe_domain
108
+ @quota_service_stub.universe_domain
109
+ end
110
+
111
+ ##
112
+ # Create a new QuotaService client object.
113
+ #
114
+ # @example
115
+ #
116
+ # # Create a client using the default configuration
117
+ # client = ::Google::Shopping::Merchant::Quota::V1beta::QuotaService::Client.new
118
+ #
119
+ # # Create a client using a custom configuration
120
+ # client = ::Google::Shopping::Merchant::Quota::V1beta::QuotaService::Client.new do |config|
121
+ # config.timeout = 10.0
122
+ # end
123
+ #
124
+ # @yield [config] Configure the QuotaService client.
125
+ # @yieldparam config [Client::Configuration]
126
+ #
127
+ def initialize
128
+ # These require statements are intentionally placed here to initialize
129
+ # the gRPC module only when it's required.
130
+ # See https://github.com/googleapis/toolkit/issues/446
131
+ require "gapic/grpc"
132
+ require "google/shopping/merchant/quota/v1beta/quota_services_pb"
133
+
134
+ # Create the configuration object
135
+ @config = Configuration.new Client.configure
136
+
137
+ # Yield the configuration if needed
138
+ yield @config if block_given?
139
+
140
+ # Create credentials
141
+ credentials = @config.credentials
142
+ # Use self-signed JWT if the endpoint is unchanged from default,
143
+ # but only if the default endpoint does not have a region prefix.
144
+ enable_self_signed_jwt = @config.endpoint.nil? ||
145
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
146
+ !@config.endpoint.split(".").first.include?("-"))
147
+ credentials ||= Credentials.default scope: @config.scope,
148
+ enable_self_signed_jwt: enable_self_signed_jwt
149
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
150
+ credentials = Credentials.new credentials, scope: @config.scope
151
+ end
152
+ @quota_project_id = @config.quota_project
153
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
154
+
155
+ @quota_service_stub = ::Gapic::ServiceStub.new(
156
+ ::Google::Shopping::Merchant::Quota::V1beta::QuotaService::Stub,
157
+ credentials: credentials,
158
+ endpoint: @config.endpoint,
159
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
160
+ universe_domain: @config.universe_domain,
161
+ channel_args: @config.channel_args,
162
+ interceptors: @config.interceptors,
163
+ channel_pool_config: @config.channel_pool
164
+ )
165
+ end
166
+
167
+ # Service calls
168
+
169
+ ##
170
+ # Lists the daily call quota and usage per group for your Merchant
171
+ # Center account.
172
+ #
173
+ # @overload list_quota_groups(request, options = nil)
174
+ # Pass arguments to `list_quota_groups` via a request object, either of type
175
+ # {::Google::Shopping::Merchant::Quota::V1beta::ListQuotaGroupsRequest} or an equivalent Hash.
176
+ #
177
+ # @param request [::Google::Shopping::Merchant::Quota::V1beta::ListQuotaGroupsRequest, ::Hash]
178
+ # A request object representing the call parameters. Required. To specify no
179
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
180
+ # @param options [::Gapic::CallOptions, ::Hash]
181
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
182
+ #
183
+ # @overload list_quota_groups(parent: nil, page_size: nil, page_token: nil)
184
+ # Pass arguments to `list_quota_groups` via keyword arguments. Note that at
185
+ # least one keyword argument is required. To specify no parameters, or to keep all
186
+ # the default parameter values, pass an empty Hash as a request object (see above).
187
+ #
188
+ # @param parent [::String]
189
+ # Required. The merchant account who owns the collection of method quotas
190
+ # Format: accounts/\\{account}
191
+ # @param page_size [::Integer]
192
+ # Optional. The maximum number of quotas to return in the response, used
193
+ # for paging. Defaults to 500; values above 1000 will be coerced to 1000.
194
+ # @param page_token [::String]
195
+ # Optional. Token (if provided) to retrieve the subsequent page. All other
196
+ # parameters must match the original call that provided the page token.
197
+ #
198
+ # @yield [response, operation] Access the result along with the RPC operation
199
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Quota::V1beta::QuotaGroup>]
200
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
201
+ #
202
+ # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Quota::V1beta::QuotaGroup>]
203
+ #
204
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
205
+ #
206
+ # @example Basic example
207
+ # require "google/shopping/merchant/quota/v1beta"
208
+ #
209
+ # # Create a client object. The client can be reused for multiple calls.
210
+ # client = Google::Shopping::Merchant::Quota::V1beta::QuotaService::Client.new
211
+ #
212
+ # # Create a request. To set request fields, pass in keyword arguments.
213
+ # request = Google::Shopping::Merchant::Quota::V1beta::ListQuotaGroupsRequest.new
214
+ #
215
+ # # Call the list_quota_groups method.
216
+ # result = client.list_quota_groups request
217
+ #
218
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
219
+ # # over elements, and API calls will be issued to fetch pages as needed.
220
+ # result.each do |item|
221
+ # # Each element is of type ::Google::Shopping::Merchant::Quota::V1beta::QuotaGroup.
222
+ # p item
223
+ # end
224
+ #
225
+ def list_quota_groups request, options = nil
226
+ raise ::ArgumentError, "request must be provided" if request.nil?
227
+
228
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Quota::V1beta::ListQuotaGroupsRequest
229
+
230
+ # Converts hash and nil to an options object
231
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
232
+
233
+ # Customize the options with defaults
234
+ metadata = @config.rpcs.list_quota_groups.metadata.to_h
235
+
236
+ # Set x-goog-api-client and x-goog-user-project headers
237
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
238
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
239
+ gapic_version: ::Google::Shopping::Merchant::Quota::V1beta::VERSION
240
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
241
+
242
+ header_params = {}
243
+ if request.parent
244
+ header_params["parent"] = request.parent
245
+ end
246
+
247
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
248
+ metadata[:"x-goog-request-params"] ||= request_params_header
249
+
250
+ options.apply_defaults timeout: @config.rpcs.list_quota_groups.timeout,
251
+ metadata: metadata,
252
+ retry_policy: @config.rpcs.list_quota_groups.retry_policy
253
+
254
+ options.apply_defaults timeout: @config.timeout,
255
+ metadata: @config.metadata,
256
+ retry_policy: @config.retry_policy
257
+
258
+ @quota_service_stub.call_rpc :list_quota_groups, request, options: options do |response, operation|
259
+ response = ::Gapic::PagedEnumerable.new @quota_service_stub, :list_quota_groups, request, response, operation, options
260
+ yield response, operation if block_given?
261
+ return response
262
+ end
263
+ rescue ::GRPC::BadStatus => e
264
+ raise ::Google::Cloud::Error.from_error(e)
265
+ end
266
+
267
+ ##
268
+ # Configuration class for the QuotaService API.
269
+ #
270
+ # This class represents the configuration for QuotaService,
271
+ # providing control over timeouts, retry behavior, logging, transport
272
+ # parameters, and other low-level controls. Certain parameters can also be
273
+ # applied individually to specific RPCs. See
274
+ # {::Google::Shopping::Merchant::Quota::V1beta::QuotaService::Client::Configuration::Rpcs}
275
+ # for a list of RPCs that can be configured independently.
276
+ #
277
+ # Configuration can be applied globally to all clients, or to a single client
278
+ # on construction.
279
+ #
280
+ # @example
281
+ #
282
+ # # Modify the global config, setting the timeout for
283
+ # # list_quota_groups to 20 seconds,
284
+ # # and all remaining timeouts to 10 seconds.
285
+ # ::Google::Shopping::Merchant::Quota::V1beta::QuotaService::Client.configure do |config|
286
+ # config.timeout = 10.0
287
+ # config.rpcs.list_quota_groups.timeout = 20.0
288
+ # end
289
+ #
290
+ # # Apply the above configuration only to a new client.
291
+ # client = ::Google::Shopping::Merchant::Quota::V1beta::QuotaService::Client.new do |config|
292
+ # config.timeout = 10.0
293
+ # config.rpcs.list_quota_groups.timeout = 20.0
294
+ # end
295
+ #
296
+ # @!attribute [rw] endpoint
297
+ # A custom service endpoint, as a hostname or hostname:port. The default is
298
+ # nil, indicating to use the default endpoint in the current universe domain.
299
+ # @return [::String,nil]
300
+ # @!attribute [rw] credentials
301
+ # Credentials to send with calls. You may provide any of the following types:
302
+ # * (`String`) The path to a service account key file in JSON format
303
+ # * (`Hash`) A service account key as a Hash
304
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
305
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
306
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
307
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
308
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
309
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
310
+ # * (`nil`) indicating no credentials
311
+ # @return [::Object]
312
+ # @!attribute [rw] scope
313
+ # The OAuth scopes
314
+ # @return [::Array<::String>]
315
+ # @!attribute [rw] lib_name
316
+ # The library name as recorded in instrumentation and logging
317
+ # @return [::String]
318
+ # @!attribute [rw] lib_version
319
+ # The library version as recorded in instrumentation and logging
320
+ # @return [::String]
321
+ # @!attribute [rw] channel_args
322
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
323
+ # `GRPC::Core::Channel` object is provided as the credential.
324
+ # @return [::Hash]
325
+ # @!attribute [rw] interceptors
326
+ # An array of interceptors that are run before calls are executed.
327
+ # @return [::Array<::GRPC::ClientInterceptor>]
328
+ # @!attribute [rw] timeout
329
+ # The call timeout in seconds.
330
+ # @return [::Numeric]
331
+ # @!attribute [rw] metadata
332
+ # Additional gRPC headers to be sent with the call.
333
+ # @return [::Hash{::Symbol=>::String}]
334
+ # @!attribute [rw] retry_policy
335
+ # The retry policy. The value is a hash with the following keys:
336
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
337
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
338
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
339
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
340
+ # trigger a retry.
341
+ # @return [::Hash]
342
+ # @!attribute [rw] quota_project
343
+ # A separate project against which to charge quota.
344
+ # @return [::String]
345
+ # @!attribute [rw] universe_domain
346
+ # The universe domain within which to make requests. This determines the
347
+ # default endpoint URL. The default value of nil uses the environment
348
+ # universe (usually the default "googleapis.com" universe).
349
+ # @return [::String,nil]
350
+ #
351
+ class Configuration
352
+ extend ::Gapic::Config
353
+
354
+ # @private
355
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
356
+ DEFAULT_ENDPOINT = "merchantapi.googleapis.com"
357
+
358
+ config_attr :endpoint, nil, ::String, nil
359
+ config_attr :credentials, nil do |value|
360
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
361
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
362
+ allowed.any? { |klass| klass === value }
363
+ end
364
+ config_attr :scope, nil, ::String, ::Array, nil
365
+ config_attr :lib_name, nil, ::String, nil
366
+ config_attr :lib_version, nil, ::String, nil
367
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
368
+ config_attr :interceptors, nil, ::Array, nil
369
+ config_attr :timeout, nil, ::Numeric, nil
370
+ config_attr :metadata, nil, ::Hash, nil
371
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
372
+ config_attr :quota_project, nil, ::String, nil
373
+ config_attr :universe_domain, nil, ::String, nil
374
+
375
+ # @private
376
+ def initialize parent_config = nil
377
+ @parent_config = parent_config unless parent_config.nil?
378
+
379
+ yield self if block_given?
380
+ end
381
+
382
+ ##
383
+ # Configurations for individual RPCs
384
+ # @return [Rpcs]
385
+ #
386
+ def rpcs
387
+ @rpcs ||= begin
388
+ parent_rpcs = nil
389
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
390
+ Rpcs.new parent_rpcs
391
+ end
392
+ end
393
+
394
+ ##
395
+ # Configuration for the channel pool
396
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
397
+ #
398
+ def channel_pool
399
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
400
+ end
401
+
402
+ ##
403
+ # Configuration RPC class for the QuotaService API.
404
+ #
405
+ # Includes fields providing the configuration for each RPC in this service.
406
+ # Each configuration object is of type `Gapic::Config::Method` and includes
407
+ # the following configuration fields:
408
+ #
409
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
410
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
411
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
412
+ # include the following keys:
413
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
414
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
415
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
416
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
417
+ # trigger a retry.
418
+ #
419
+ class Rpcs
420
+ ##
421
+ # RPC-specific configuration for `list_quota_groups`
422
+ # @return [::Gapic::Config::Method]
423
+ #
424
+ attr_reader :list_quota_groups
425
+
426
+ # @private
427
+ def initialize parent_rpcs = nil
428
+ list_quota_groups_config = parent_rpcs.list_quota_groups if parent_rpcs.respond_to? :list_quota_groups
429
+ @list_quota_groups = ::Gapic::Config::Method.new list_quota_groups_config
430
+
431
+ yield self if block_given?
432
+ end
433
+ end
434
+ end
435
+ end
436
+ end
437
+ end
438
+ end
439
+ end
440
+ end
441
+ end
@@ -0,0 +1,49 @@
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 "googleauth"
20
+
21
+ module Google
22
+ module Shopping
23
+ module Merchant
24
+ module Quota
25
+ module V1beta
26
+ module QuotaService
27
+ # Credentials for the QuotaService API.
28
+ class Credentials < ::Google::Auth::Credentials
29
+ self.scope = [
30
+ "https://www.googleapis.com/auth/content"
31
+ ]
32
+ self.env_vars = [
33
+ "GOOGLE_CLOUD_CREDENTIALS",
34
+ "GOOGLE_CLOUD_KEYFILE",
35
+ "GCLOUD_KEYFILE",
36
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
37
+ "GOOGLE_CLOUD_KEYFILE_JSON",
38
+ "GCLOUD_KEYFILE_JSON"
39
+ ]
40
+ self.paths = [
41
+ "~/.config/google_cloud/application_default_credentials.json"
42
+ ]
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,49 @@
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
+
20
+ module Google
21
+ module Shopping
22
+ module Merchant
23
+ module Quota
24
+ module V1beta
25
+ module QuotaService
26
+ # Path helper methods for the QuotaService API.
27
+ module Paths
28
+ ##
29
+ # Create a fully-qualified Account resource string.
30
+ #
31
+ # The resource will be in the following format:
32
+ #
33
+ # `accounts/{account}`
34
+ #
35
+ # @param account [String]
36
+ #
37
+ # @return [::String]
38
+ def account_path account:
39
+ "accounts/#{account}"
40
+ end
41
+
42
+ extend self
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end