google-cloud-service_control-v1 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,487 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/servicecontrol/v1/service_controller_pb"
21
+ require "google/cloud/service_control/v1/service_controller/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module ServiceControl
26
+ module V1
27
+ module ServiceController
28
+ module Rest
29
+ ##
30
+ # REST client for the ServiceController service.
31
+ #
32
+ # [Google Service Control API](/service-control/overview)
33
+ #
34
+ # Lets clients check and report operations against a [managed
35
+ # service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService).
36
+ #
37
+ class Client
38
+ # @private
39
+ attr_reader :service_controller_stub
40
+
41
+ ##
42
+ # Configure the ServiceController Client class.
43
+ #
44
+ # See {::Google::Cloud::ServiceControl::V1::ServiceController::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all ServiceController clients
50
+ # ::Google::Cloud::ServiceControl::V1::ServiceController::Rest::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "ServiceControl", "V1"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.rpcs.check.timeout = 5.0
71
+ default_config.rpcs.check.retry_policy = {
72
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
73
+ }
74
+
75
+ default_config.rpcs.report.timeout = 16.0
76
+
77
+ default_config
78
+ end
79
+ yield @configure if block_given?
80
+ @configure
81
+ end
82
+
83
+ ##
84
+ # Configure the ServiceController Client instance.
85
+ #
86
+ # The configuration is set to the derived mode, meaning that values can be changed,
87
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
88
+ # should be made on {Client.configure}.
89
+ #
90
+ # See {::Google::Cloud::ServiceControl::V1::ServiceController::Rest::Client::Configuration}
91
+ # for a description of the configuration fields.
92
+ #
93
+ # @yield [config] Configure the Client client.
94
+ # @yieldparam config [Client::Configuration]
95
+ #
96
+ # @return [Client::Configuration]
97
+ #
98
+ def configure
99
+ yield @config if block_given?
100
+ @config
101
+ end
102
+
103
+ ##
104
+ # Create a new ServiceController REST client object.
105
+ #
106
+ # @example
107
+ #
108
+ # # Create a client using the default configuration
109
+ # client = ::Google::Cloud::ServiceControl::V1::ServiceController::Rest::Client.new
110
+ #
111
+ # # Create a client using a custom configuration
112
+ # client = ::Google::Cloud::ServiceControl::V1::ServiceController::Rest::Client.new do |config|
113
+ # config.timeout = 10.0
114
+ # end
115
+ #
116
+ # @yield [config] Configure the ServiceController client.
117
+ # @yieldparam config [Client::Configuration]
118
+ #
119
+ def initialize
120
+ # Create the configuration object
121
+ @config = Configuration.new Client.configure
122
+
123
+ # Yield the configuration if needed
124
+ yield @config if block_given?
125
+
126
+ # Create credentials
127
+ credentials = @config.credentials
128
+ # Use self-signed JWT if the endpoint is unchanged from default,
129
+ # but only if the default endpoint does not have a region prefix.
130
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
131
+ !@config.endpoint.split(".").first.include?("-")
132
+ credentials ||= Credentials.default scope: @config.scope,
133
+ enable_self_signed_jwt: enable_self_signed_jwt
134
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
135
+ credentials = Credentials.new credentials, scope: @config.scope
136
+ end
137
+
138
+ @quota_project_id = @config.quota_project
139
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
140
+
141
+ @service_controller_stub = ::Google::Cloud::ServiceControl::V1::ServiceController::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
142
+ end
143
+
144
+ # Service calls
145
+
146
+ ##
147
+ # Checks whether an operation on a service should be allowed to proceed
148
+ # based on the configuration of the service and related policies. It must be
149
+ # called before the operation is executed.
150
+ #
151
+ # If feasible, the client should cache the check results and reuse them for
152
+ # 60 seconds. In case of any server errors, the client should rely on the
153
+ # cached results for much longer time to avoid outage.
154
+ # WARNING: There is general 60s delay for the configuration and policy
155
+ # propagation, therefore callers MUST NOT depend on the `Check` method having
156
+ # the latest policy information.
157
+ #
158
+ # NOTE: the {::Google::Cloud::ServiceControl::V1::CheckRequest CheckRequest} has
159
+ # the size limit (wire-format byte size) of 1MB.
160
+ #
161
+ # This method requires the `servicemanagement.services.check` permission
162
+ # on the specified service. For more information, see
163
+ # [Cloud IAM](https://cloud.google.com/iam).
164
+ #
165
+ # @overload check(request, options = nil)
166
+ # Pass arguments to `check` via a request object, either of type
167
+ # {::Google::Cloud::ServiceControl::V1::CheckRequest} or an equivalent Hash.
168
+ #
169
+ # @param request [::Google::Cloud::ServiceControl::V1::CheckRequest, ::Hash]
170
+ # A request object representing the call parameters. Required. To specify no
171
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
172
+ # @param options [::Gapic::CallOptions, ::Hash]
173
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
174
+ #
175
+ # @overload check(service_name: nil, operation: nil, service_config_id: nil)
176
+ # Pass arguments to `check` via keyword arguments. Note that at
177
+ # least one keyword argument is required. To specify no parameters, or to keep all
178
+ # the default parameter values, pass an empty Hash as a request object (see above).
179
+ #
180
+ # @param service_name [::String]
181
+ # The service name as specified in its service configuration. For example,
182
+ # `"pubsub.googleapis.com"`.
183
+ #
184
+ # See
185
+ # [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
186
+ # for the definition of a service name.
187
+ # @param operation [::Google::Cloud::ServiceControl::V1::Operation, ::Hash]
188
+ # The operation to be checked.
189
+ # @param service_config_id [::String]
190
+ # Specifies which version of service configuration should be used to process
191
+ # the request.
192
+ #
193
+ # If unspecified or no matching version can be found, the
194
+ # latest one will be used.
195
+ # @yield [result, operation] Access the result along with the TransportOperation object
196
+ # @yieldparam result [::Google::Cloud::ServiceControl::V1::CheckResponse]
197
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
198
+ #
199
+ # @return [::Google::Cloud::ServiceControl::V1::CheckResponse]
200
+ #
201
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
202
+ def check request, options = nil
203
+ raise ::ArgumentError, "request must be provided" if request.nil?
204
+
205
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceControl::V1::CheckRequest
206
+
207
+ # Converts hash and nil to an options object
208
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
209
+
210
+ # Customize the options with defaults
211
+ call_metadata = @config.rpcs.check.metadata.to_h
212
+
213
+ # Set x-goog-api-client and x-goog-user-project headers
214
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
215
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
216
+ gapic_version: ::Google::Cloud::ServiceControl::V1::VERSION,
217
+ transports_version_send: [:rest]
218
+
219
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
220
+
221
+ options.apply_defaults timeout: @config.rpcs.check.timeout,
222
+ metadata: call_metadata,
223
+ retry_policy: @config.rpcs.check.retry_policy
224
+
225
+ options.apply_defaults timeout: @config.timeout,
226
+ metadata: @config.metadata,
227
+ retry_policy: @config.retry_policy
228
+
229
+ @service_controller_stub.check request, options do |result, operation|
230
+ yield result, operation if block_given?
231
+ return result
232
+ end
233
+ rescue ::Gapic::Rest::Error => e
234
+ raise ::Google::Cloud::Error.from_error(e)
235
+ end
236
+
237
+ ##
238
+ # Reports operation results to Google Service Control, such as logs and
239
+ # metrics. It should be called after an operation is completed.
240
+ #
241
+ # If feasible, the client should aggregate reporting data for up to 5
242
+ # seconds to reduce API traffic. Limiting aggregation to 5 seconds is to
243
+ # reduce data loss during client crashes. Clients should carefully choose
244
+ # the aggregation time window to avoid data loss risk more than 0.01%
245
+ # for business and compliance reasons.
246
+ #
247
+ # NOTE: the {::Google::Cloud::ServiceControl::V1::ReportRequest ReportRequest} has
248
+ # the size limit (wire-format byte size) of 1MB.
249
+ #
250
+ # This method requires the `servicemanagement.services.report` permission
251
+ # on the specified service. For more information, see
252
+ # [Google Cloud IAM](https://cloud.google.com/iam).
253
+ #
254
+ # @overload report(request, options = nil)
255
+ # Pass arguments to `report` via a request object, either of type
256
+ # {::Google::Cloud::ServiceControl::V1::ReportRequest} or an equivalent Hash.
257
+ #
258
+ # @param request [::Google::Cloud::ServiceControl::V1::ReportRequest, ::Hash]
259
+ # A request object representing the call parameters. Required. To specify no
260
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
261
+ # @param options [::Gapic::CallOptions, ::Hash]
262
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
263
+ #
264
+ # @overload report(service_name: nil, operations: nil, service_config_id: nil)
265
+ # Pass arguments to `report` via keyword arguments. Note that at
266
+ # least one keyword argument is required. To specify no parameters, or to keep all
267
+ # the default parameter values, pass an empty Hash as a request object (see above).
268
+ #
269
+ # @param service_name [::String]
270
+ # The service name as specified in its service configuration. For example,
271
+ # `"pubsub.googleapis.com"`.
272
+ #
273
+ # See
274
+ # [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
275
+ # for the definition of a service name.
276
+ # @param operations [::Array<::Google::Cloud::ServiceControl::V1::Operation, ::Hash>]
277
+ # Operations to be reported.
278
+ #
279
+ # Typically the service should report one operation per request.
280
+ # Putting multiple operations into a single request is allowed, but should
281
+ # be used only when multiple operations are natually available at the time
282
+ # of the report.
283
+ #
284
+ # There is no limit on the number of operations in the same ReportRequest,
285
+ # however the ReportRequest size should be no larger than 1MB. See
286
+ # {::Google::Cloud::ServiceControl::V1::ReportResponse#report_errors ReportResponse.report_errors}
287
+ # for partial failure behavior.
288
+ # @param service_config_id [::String]
289
+ # Specifies which version of service config should be used to process the
290
+ # request.
291
+ #
292
+ # If unspecified or no matching version can be found, the
293
+ # latest one will be used.
294
+ # @yield [result, operation] Access the result along with the TransportOperation object
295
+ # @yieldparam result [::Google::Cloud::ServiceControl::V1::ReportResponse]
296
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
297
+ #
298
+ # @return [::Google::Cloud::ServiceControl::V1::ReportResponse]
299
+ #
300
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
301
+ def report request, options = nil
302
+ raise ::ArgumentError, "request must be provided" if request.nil?
303
+
304
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceControl::V1::ReportRequest
305
+
306
+ # Converts hash and nil to an options object
307
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
308
+
309
+ # Customize the options with defaults
310
+ call_metadata = @config.rpcs.report.metadata.to_h
311
+
312
+ # Set x-goog-api-client and x-goog-user-project headers
313
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
314
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
315
+ gapic_version: ::Google::Cloud::ServiceControl::V1::VERSION,
316
+ transports_version_send: [:rest]
317
+
318
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
319
+
320
+ options.apply_defaults timeout: @config.rpcs.report.timeout,
321
+ metadata: call_metadata,
322
+ retry_policy: @config.rpcs.report.retry_policy
323
+
324
+ options.apply_defaults timeout: @config.timeout,
325
+ metadata: @config.metadata,
326
+ retry_policy: @config.retry_policy
327
+
328
+ @service_controller_stub.report request, options do |result, operation|
329
+ yield result, operation if block_given?
330
+ return result
331
+ end
332
+ rescue ::Gapic::Rest::Error => e
333
+ raise ::Google::Cloud::Error.from_error(e)
334
+ end
335
+
336
+ ##
337
+ # Configuration class for the ServiceController REST API.
338
+ #
339
+ # This class represents the configuration for ServiceController REST,
340
+ # providing control over timeouts, retry behavior, logging, transport
341
+ # parameters, and other low-level controls. Certain parameters can also be
342
+ # applied individually to specific RPCs. See
343
+ # {::Google::Cloud::ServiceControl::V1::ServiceController::Rest::Client::Configuration::Rpcs}
344
+ # for a list of RPCs that can be configured independently.
345
+ #
346
+ # Configuration can be applied globally to all clients, or to a single client
347
+ # on construction.
348
+ #
349
+ # @example
350
+ #
351
+ # # Modify the global config, setting the timeout for
352
+ # # check to 20 seconds,
353
+ # # and all remaining timeouts to 10 seconds.
354
+ # ::Google::Cloud::ServiceControl::V1::ServiceController::Rest::Client.configure do |config|
355
+ # config.timeout = 10.0
356
+ # config.rpcs.check.timeout = 20.0
357
+ # end
358
+ #
359
+ # # Apply the above configuration only to a new client.
360
+ # client = ::Google::Cloud::ServiceControl::V1::ServiceController::Rest::Client.new do |config|
361
+ # config.timeout = 10.0
362
+ # config.rpcs.check.timeout = 20.0
363
+ # end
364
+ #
365
+ # @!attribute [rw] endpoint
366
+ # The hostname or hostname:port of the service endpoint.
367
+ # Defaults to `"servicecontrol.googleapis.com"`.
368
+ # @return [::String]
369
+ # @!attribute [rw] credentials
370
+ # Credentials to send with calls. You may provide any of the following types:
371
+ # * (`String`) The path to a service account key file in JSON format
372
+ # * (`Hash`) A service account key as a Hash
373
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
374
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
375
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
376
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
377
+ # * (`nil`) indicating no credentials
378
+ # @return [::Object]
379
+ # @!attribute [rw] scope
380
+ # The OAuth scopes
381
+ # @return [::Array<::String>]
382
+ # @!attribute [rw] lib_name
383
+ # The library name as recorded in instrumentation and logging
384
+ # @return [::String]
385
+ # @!attribute [rw] lib_version
386
+ # The library version as recorded in instrumentation and logging
387
+ # @return [::String]
388
+ # @!attribute [rw] timeout
389
+ # The call timeout in seconds.
390
+ # @return [::Numeric]
391
+ # @!attribute [rw] metadata
392
+ # Additional headers to be sent with the call.
393
+ # @return [::Hash{::Symbol=>::String}]
394
+ # @!attribute [rw] retry_policy
395
+ # The retry policy. The value is a hash with the following keys:
396
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
397
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
398
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
399
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
400
+ # trigger a retry.
401
+ # @return [::Hash]
402
+ # @!attribute [rw] quota_project
403
+ # A separate project against which to charge quota.
404
+ # @return [::String]
405
+ #
406
+ class Configuration
407
+ extend ::Gapic::Config
408
+
409
+ config_attr :endpoint, "servicecontrol.googleapis.com", ::String
410
+ config_attr :credentials, nil do |value|
411
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
412
+ allowed.any? { |klass| klass === value }
413
+ end
414
+ config_attr :scope, nil, ::String, ::Array, nil
415
+ config_attr :lib_name, nil, ::String, nil
416
+ config_attr :lib_version, nil, ::String, nil
417
+ config_attr :timeout, nil, ::Numeric, nil
418
+ config_attr :metadata, nil, ::Hash, nil
419
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
420
+ config_attr :quota_project, nil, ::String, nil
421
+
422
+ # @private
423
+ def initialize parent_config = nil
424
+ @parent_config = parent_config unless parent_config.nil?
425
+
426
+ yield self if block_given?
427
+ end
428
+
429
+ ##
430
+ # Configurations for individual RPCs
431
+ # @return [Rpcs]
432
+ #
433
+ def rpcs
434
+ @rpcs ||= begin
435
+ parent_rpcs = nil
436
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
437
+ Rpcs.new parent_rpcs
438
+ end
439
+ end
440
+
441
+ ##
442
+ # Configuration RPC class for the ServiceController API.
443
+ #
444
+ # Includes fields providing the configuration for each RPC in this service.
445
+ # Each configuration object is of type `Gapic::Config::Method` and includes
446
+ # the following configuration fields:
447
+ #
448
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
449
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
450
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
451
+ # include the following keys:
452
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
453
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
454
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
455
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
456
+ # trigger a retry.
457
+ #
458
+ class Rpcs
459
+ ##
460
+ # RPC-specific configuration for `check`
461
+ # @return [::Gapic::Config::Method]
462
+ #
463
+ attr_reader :check
464
+ ##
465
+ # RPC-specific configuration for `report`
466
+ # @return [::Gapic::Config::Method]
467
+ #
468
+ attr_reader :report
469
+
470
+ # @private
471
+ def initialize parent_rpcs = nil
472
+ check_config = parent_rpcs.check if parent_rpcs.respond_to? :check
473
+ @check = ::Gapic::Config::Method.new check_config
474
+ report_config = parent_rpcs.report if parent_rpcs.respond_to? :report
475
+ @report = ::Gapic::Config::Method.new report_config
476
+
477
+ yield self if block_given?
478
+ end
479
+ end
480
+ end
481
+ end
482
+ end
483
+ end
484
+ end
485
+ end
486
+ end
487
+ end
@@ -0,0 +1,168 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/api/servicecontrol/v1/service_controller_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module ServiceControl
24
+ module V1
25
+ module ServiceController
26
+ module Rest
27
+ ##
28
+ # REST service stub for the ServiceController service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
39
+ numeric_enums: true,
40
+ raise_faraday_errors: false
41
+ end
42
+
43
+ ##
44
+ # Baseline implementation for the check REST call
45
+ #
46
+ # @param request_pb [::Google::Cloud::ServiceControl::V1::CheckRequest]
47
+ # A request object representing the call parameters. Required.
48
+ # @param options [::Gapic::CallOptions]
49
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
50
+ #
51
+ # @yield [result, operation] Access the result along with the TransportOperation object
52
+ # @yieldparam result [::Google::Cloud::ServiceControl::V1::CheckResponse]
53
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
54
+ #
55
+ # @return [::Google::Cloud::ServiceControl::V1::CheckResponse]
56
+ # A result object deserialized from the server's reply
57
+ def check request_pb, options = nil
58
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
59
+
60
+ verb, uri, query_string_params, body = ServiceStub.transcode_check_request request_pb
61
+ query_string_params = if query_string_params.any?
62
+ query_string_params.to_h { |p| p.split("=", 2) }
63
+ else
64
+ {}
65
+ end
66
+
67
+ response = @client_stub.make_http_request(
68
+ verb,
69
+ uri: uri,
70
+ body: body || "",
71
+ params: query_string_params,
72
+ options: options
73
+ )
74
+ operation = ::Gapic::Rest::TransportOperation.new response
75
+ result = ::Google::Cloud::ServiceControl::V1::CheckResponse.decode_json response.body, ignore_unknown_fields: true
76
+
77
+ yield result, operation if block_given?
78
+ result
79
+ end
80
+
81
+ ##
82
+ # Baseline implementation for the report REST call
83
+ #
84
+ # @param request_pb [::Google::Cloud::ServiceControl::V1::ReportRequest]
85
+ # A request object representing the call parameters. Required.
86
+ # @param options [::Gapic::CallOptions]
87
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
88
+ #
89
+ # @yield [result, operation] Access the result along with the TransportOperation object
90
+ # @yieldparam result [::Google::Cloud::ServiceControl::V1::ReportResponse]
91
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
92
+ #
93
+ # @return [::Google::Cloud::ServiceControl::V1::ReportResponse]
94
+ # A result object deserialized from the server's reply
95
+ def report request_pb, options = nil
96
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
97
+
98
+ verb, uri, query_string_params, body = ServiceStub.transcode_report_request request_pb
99
+ query_string_params = if query_string_params.any?
100
+ query_string_params.to_h { |p| p.split("=", 2) }
101
+ else
102
+ {}
103
+ end
104
+
105
+ response = @client_stub.make_http_request(
106
+ verb,
107
+ uri: uri,
108
+ body: body || "",
109
+ params: query_string_params,
110
+ options: options
111
+ )
112
+ operation = ::Gapic::Rest::TransportOperation.new response
113
+ result = ::Google::Cloud::ServiceControl::V1::ReportResponse.decode_json response.body, ignore_unknown_fields: true
114
+
115
+ yield result, operation if block_given?
116
+ result
117
+ end
118
+
119
+ ##
120
+ # @private
121
+ #
122
+ # GRPC transcoding helper method for the check REST call
123
+ #
124
+ # @param request_pb [::Google::Cloud::ServiceControl::V1::CheckRequest]
125
+ # A request object representing the call parameters. Required.
126
+ # @return [Array(String, [String, nil], Hash{String => String})]
127
+ # Uri, Body, Query string parameters
128
+ def self.transcode_check_request request_pb
129
+ transcoder = Gapic::Rest::GrpcTranscoder.new
130
+ .with_bindings(
131
+ uri_method: :post,
132
+ uri_template: "/v1/services/{service_name}:check",
133
+ body: "*",
134
+ matches: [
135
+ ["service_name", %r{^[^/]+/?$}, false]
136
+ ]
137
+ )
138
+ transcoder.transcode request_pb
139
+ end
140
+
141
+ ##
142
+ # @private
143
+ #
144
+ # GRPC transcoding helper method for the report REST call
145
+ #
146
+ # @param request_pb [::Google::Cloud::ServiceControl::V1::ReportRequest]
147
+ # A request object representing the call parameters. Required.
148
+ # @return [Array(String, [String, nil], Hash{String => String})]
149
+ # Uri, Body, Query string parameters
150
+ def self.transcode_report_request request_pb
151
+ transcoder = Gapic::Rest::GrpcTranscoder.new
152
+ .with_bindings(
153
+ uri_method: :post,
154
+ uri_template: "/v1/services/{service_name}:report",
155
+ body: "*",
156
+ matches: [
157
+ ["service_name", %r{^[^/]+/?$}, false]
158
+ ]
159
+ )
160
+ transcoder.transcode request_pb
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end