google-cloud-network_connectivity-v1 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,786 @@
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/cloud/networkconnectivity/v1/policy_based_routing_pb"
21
+ require "google/cloud/location"
22
+ require "google/iam/v1"
23
+
24
+ module Google
25
+ module Cloud
26
+ module NetworkConnectivity
27
+ module V1
28
+ module PolicyBasedRoutingService
29
+ ##
30
+ # Client for the PolicyBasedRoutingService service.
31
+ #
32
+ # Policy-Based Routing allows GCP customers to specify flexibile routing
33
+ # policies for Layer 4 traffic traversing through the connected service.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :policy_based_routing_service_stub
40
+
41
+ ##
42
+ # Configure the PolicyBasedRoutingService Client class.
43
+ #
44
+ # See {::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all PolicyBasedRoutingService clients
50
+ # ::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::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", "NetworkConnectivity", "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.timeout = 60.0
71
+ default_config.retry_policy = {
72
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
73
+ }
74
+
75
+ default_config.rpcs.create_policy_based_route.timeout = 60.0
76
+
77
+ default_config.rpcs.delete_policy_based_route.timeout = 60.0
78
+
79
+ default_config
80
+ end
81
+ yield @configure if block_given?
82
+ @configure
83
+ end
84
+
85
+ ##
86
+ # Configure the PolicyBasedRoutingService Client instance.
87
+ #
88
+ # The configuration is set to the derived mode, meaning that values can be changed,
89
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
90
+ # should be made on {Client.configure}.
91
+ #
92
+ # See {::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client::Configuration}
93
+ # for a description of the configuration fields.
94
+ #
95
+ # @yield [config] Configure the Client client.
96
+ # @yieldparam config [Client::Configuration]
97
+ #
98
+ # @return [Client::Configuration]
99
+ #
100
+ def configure
101
+ yield @config if block_given?
102
+ @config
103
+ end
104
+
105
+ ##
106
+ # Create a new PolicyBasedRoutingService client object.
107
+ #
108
+ # @example
109
+ #
110
+ # # Create a client using the default configuration
111
+ # client = ::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client.new
112
+ #
113
+ # # Create a client using a custom configuration
114
+ # client = ::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client.new do |config|
115
+ # config.timeout = 10.0
116
+ # end
117
+ #
118
+ # @yield [config] Configure the PolicyBasedRoutingService client.
119
+ # @yieldparam config [Client::Configuration]
120
+ #
121
+ def initialize
122
+ # These require statements are intentionally placed here to initialize
123
+ # the gRPC module only when it's required.
124
+ # See https://github.com/googleapis/toolkit/issues/446
125
+ require "gapic/grpc"
126
+ require "google/cloud/networkconnectivity/v1/policy_based_routing_services_pb"
127
+
128
+ # Create the configuration object
129
+ @config = Configuration.new Client.configure
130
+
131
+ # Yield the configuration if needed
132
+ yield @config if block_given?
133
+
134
+ # Create credentials
135
+ credentials = @config.credentials
136
+ # Use self-signed JWT if the endpoint is unchanged from default,
137
+ # but only if the default endpoint does not have a region prefix.
138
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
139
+ !@config.endpoint.split(".").first.include?("-")
140
+ credentials ||= Credentials.default scope: @config.scope,
141
+ enable_self_signed_jwt: enable_self_signed_jwt
142
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
143
+ credentials = Credentials.new credentials, scope: @config.scope
144
+ end
145
+ @quota_project_id = @config.quota_project
146
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
147
+
148
+ @operations_client = Operations.new do |config|
149
+ config.credentials = credentials
150
+ config.quota_project = @quota_project_id
151
+ config.endpoint = @config.endpoint
152
+ end
153
+
154
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
155
+ config.credentials = credentials
156
+ config.quota_project = @quota_project_id
157
+ config.endpoint = @config.endpoint
158
+ end
159
+
160
+ @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
161
+ config.credentials = credentials
162
+ config.quota_project = @quota_project_id
163
+ config.endpoint = @config.endpoint
164
+ end
165
+
166
+ @policy_based_routing_service_stub = ::Gapic::ServiceStub.new(
167
+ ::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Stub,
168
+ credentials: credentials,
169
+ endpoint: @config.endpoint,
170
+ channel_args: @config.channel_args,
171
+ interceptors: @config.interceptors,
172
+ channel_pool_config: @config.channel_pool
173
+ )
174
+ end
175
+
176
+ ##
177
+ # Get the associated client for long-running operations.
178
+ #
179
+ # @return [::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Operations]
180
+ #
181
+ attr_reader :operations_client
182
+
183
+ ##
184
+ # Get the associated client for mix-in of the Locations.
185
+ #
186
+ # @return [Google::Cloud::Location::Locations::Client]
187
+ #
188
+ attr_reader :location_client
189
+
190
+ ##
191
+ # Get the associated client for mix-in of the IAMPolicy.
192
+ #
193
+ # @return [Google::Iam::V1::IAMPolicy::Client]
194
+ #
195
+ attr_reader :iam_policy_client
196
+
197
+ # Service calls
198
+
199
+ ##
200
+ # Lists PolicyBasedRoutes in a given project and location.
201
+ #
202
+ # @overload list_policy_based_routes(request, options = nil)
203
+ # Pass arguments to `list_policy_based_routes` via a request object, either of type
204
+ # {::Google::Cloud::NetworkConnectivity::V1::ListPolicyBasedRoutesRequest} or an equivalent Hash.
205
+ #
206
+ # @param request [::Google::Cloud::NetworkConnectivity::V1::ListPolicyBasedRoutesRequest, ::Hash]
207
+ # A request object representing the call parameters. Required. To specify no
208
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
209
+ # @param options [::Gapic::CallOptions, ::Hash]
210
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
211
+ #
212
+ # @overload list_policy_based_routes(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
213
+ # Pass arguments to `list_policy_based_routes` via keyword arguments. Note that at
214
+ # least one keyword argument is required. To specify no parameters, or to keep all
215
+ # the default parameter values, pass an empty Hash as a request object (see above).
216
+ #
217
+ # @param parent [::String]
218
+ # Required. The parent resource's name.
219
+ # @param page_size [::Integer]
220
+ # The maximum number of results per page that should be returned.
221
+ # @param page_token [::String]
222
+ # The page token.
223
+ # @param filter [::String]
224
+ # A filter expression that filters the results listed in the response.
225
+ # @param order_by [::String]
226
+ # Sort the results by a certain order.
227
+ #
228
+ # @yield [response, operation] Access the result along with the RPC operation
229
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoute>]
230
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
231
+ #
232
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoute>]
233
+ #
234
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
235
+ #
236
+ # @example Basic example
237
+ # require "google/cloud/network_connectivity/v1"
238
+ #
239
+ # # Create a client object. The client can be reused for multiple calls.
240
+ # client = Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client.new
241
+ #
242
+ # # Create a request. To set request fields, pass in keyword arguments.
243
+ # request = Google::Cloud::NetworkConnectivity::V1::ListPolicyBasedRoutesRequest.new
244
+ #
245
+ # # Call the list_policy_based_routes method.
246
+ # result = client.list_policy_based_routes request
247
+ #
248
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
249
+ # # over elements, and API calls will be issued to fetch pages as needed.
250
+ # result.each do |item|
251
+ # # Each element is of type ::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoute.
252
+ # p item
253
+ # end
254
+ #
255
+ def list_policy_based_routes request, options = nil
256
+ raise ::ArgumentError, "request must be provided" if request.nil?
257
+
258
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::NetworkConnectivity::V1::ListPolicyBasedRoutesRequest
259
+
260
+ # Converts hash and nil to an options object
261
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
262
+
263
+ # Customize the options with defaults
264
+ metadata = @config.rpcs.list_policy_based_routes.metadata.to_h
265
+
266
+ # Set x-goog-api-client and x-goog-user-project headers
267
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
268
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
269
+ gapic_version: ::Google::Cloud::NetworkConnectivity::V1::VERSION
270
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
271
+
272
+ header_params = {}
273
+ if request.parent
274
+ header_params["parent"] = request.parent
275
+ end
276
+
277
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
278
+ metadata[:"x-goog-request-params"] ||= request_params_header
279
+
280
+ options.apply_defaults timeout: @config.rpcs.list_policy_based_routes.timeout,
281
+ metadata: metadata,
282
+ retry_policy: @config.rpcs.list_policy_based_routes.retry_policy
283
+
284
+ options.apply_defaults timeout: @config.timeout,
285
+ metadata: @config.metadata,
286
+ retry_policy: @config.retry_policy
287
+
288
+ @policy_based_routing_service_stub.call_rpc :list_policy_based_routes, request, options: options do |response, operation|
289
+ response = ::Gapic::PagedEnumerable.new @policy_based_routing_service_stub, :list_policy_based_routes, request, response, operation, options
290
+ yield response, operation if block_given?
291
+ return response
292
+ end
293
+ rescue ::GRPC::BadStatus => e
294
+ raise ::Google::Cloud::Error.from_error(e)
295
+ end
296
+
297
+ ##
298
+ # Gets details of a single PolicyBasedRoute.
299
+ #
300
+ # @overload get_policy_based_route(request, options = nil)
301
+ # Pass arguments to `get_policy_based_route` via a request object, either of type
302
+ # {::Google::Cloud::NetworkConnectivity::V1::GetPolicyBasedRouteRequest} or an equivalent Hash.
303
+ #
304
+ # @param request [::Google::Cloud::NetworkConnectivity::V1::GetPolicyBasedRouteRequest, ::Hash]
305
+ # A request object representing the call parameters. Required. To specify no
306
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
307
+ # @param options [::Gapic::CallOptions, ::Hash]
308
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
309
+ #
310
+ # @overload get_policy_based_route(name: nil)
311
+ # Pass arguments to `get_policy_based_route` via keyword arguments. Note that at
312
+ # least one keyword argument is required. To specify no parameters, or to keep all
313
+ # the default parameter values, pass an empty Hash as a request object (see above).
314
+ #
315
+ # @param name [::String]
316
+ # Required. Name of the PolicyBasedRoute resource to get.
317
+ #
318
+ # @yield [response, operation] Access the result along with the RPC operation
319
+ # @yieldparam response [::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoute]
320
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
321
+ #
322
+ # @return [::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoute]
323
+ #
324
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
325
+ #
326
+ # @example Basic example
327
+ # require "google/cloud/network_connectivity/v1"
328
+ #
329
+ # # Create a client object. The client can be reused for multiple calls.
330
+ # client = Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client.new
331
+ #
332
+ # # Create a request. To set request fields, pass in keyword arguments.
333
+ # request = Google::Cloud::NetworkConnectivity::V1::GetPolicyBasedRouteRequest.new
334
+ #
335
+ # # Call the get_policy_based_route method.
336
+ # result = client.get_policy_based_route request
337
+ #
338
+ # # The returned object is of type Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoute.
339
+ # p result
340
+ #
341
+ def get_policy_based_route request, options = nil
342
+ raise ::ArgumentError, "request must be provided" if request.nil?
343
+
344
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::NetworkConnectivity::V1::GetPolicyBasedRouteRequest
345
+
346
+ # Converts hash and nil to an options object
347
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
348
+
349
+ # Customize the options with defaults
350
+ metadata = @config.rpcs.get_policy_based_route.metadata.to_h
351
+
352
+ # Set x-goog-api-client and x-goog-user-project headers
353
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
354
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
355
+ gapic_version: ::Google::Cloud::NetworkConnectivity::V1::VERSION
356
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
357
+
358
+ header_params = {}
359
+ if request.name
360
+ header_params["name"] = request.name
361
+ end
362
+
363
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
364
+ metadata[:"x-goog-request-params"] ||= request_params_header
365
+
366
+ options.apply_defaults timeout: @config.rpcs.get_policy_based_route.timeout,
367
+ metadata: metadata,
368
+ retry_policy: @config.rpcs.get_policy_based_route.retry_policy
369
+
370
+ options.apply_defaults timeout: @config.timeout,
371
+ metadata: @config.metadata,
372
+ retry_policy: @config.retry_policy
373
+
374
+ @policy_based_routing_service_stub.call_rpc :get_policy_based_route, request, options: options do |response, operation|
375
+ yield response, operation if block_given?
376
+ return response
377
+ end
378
+ rescue ::GRPC::BadStatus => e
379
+ raise ::Google::Cloud::Error.from_error(e)
380
+ end
381
+
382
+ ##
383
+ # Creates a new PolicyBasedRoute in a given project and location.
384
+ #
385
+ # @overload create_policy_based_route(request, options = nil)
386
+ # Pass arguments to `create_policy_based_route` via a request object, either of type
387
+ # {::Google::Cloud::NetworkConnectivity::V1::CreatePolicyBasedRouteRequest} or an equivalent Hash.
388
+ #
389
+ # @param request [::Google::Cloud::NetworkConnectivity::V1::CreatePolicyBasedRouteRequest, ::Hash]
390
+ # A request object representing the call parameters. Required. To specify no
391
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
392
+ # @param options [::Gapic::CallOptions, ::Hash]
393
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
394
+ #
395
+ # @overload create_policy_based_route(parent: nil, policy_based_route_id: nil, policy_based_route: nil, request_id: nil)
396
+ # Pass arguments to `create_policy_based_route` via keyword arguments. Note that at
397
+ # least one keyword argument is required. To specify no parameters, or to keep all
398
+ # the default parameter values, pass an empty Hash as a request object (see above).
399
+ #
400
+ # @param parent [::String]
401
+ # Required. The parent resource's name of the PolicyBasedRoute.
402
+ # @param policy_based_route_id [::String]
403
+ # Required. Unique id for the Policy Based Route to create.
404
+ # @param policy_based_route [::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoute, ::Hash]
405
+ # Required. Initial values for a new Policy Based Route.
406
+ # @param request_id [::String]
407
+ # Optional. An optional request ID to identify requests. Specify a unique
408
+ # request ID so that if you must retry your request, the server will know to
409
+ # ignore the request if it has already been completed. The server will
410
+ # guarantee that for at least 60 minutes since the first request.
411
+ #
412
+ # For example, consider a situation where you make an initial request and
413
+ # the request times out. If you make the request again with the same request
414
+ # ID, the server can check if original operation with the same request ID
415
+ # was received, and if so, will ignore the second request. This prevents
416
+ # clients from accidentally creating duplicate commitments.
417
+ #
418
+ # The request ID must be a valid UUID with the exception that zero UUID is
419
+ # not supported (00000000-0000-0000-0000-000000000000).
420
+ #
421
+ # @yield [response, operation] Access the result along with the RPC operation
422
+ # @yieldparam response [::Gapic::Operation]
423
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
424
+ #
425
+ # @return [::Gapic::Operation]
426
+ #
427
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
428
+ #
429
+ # @example Basic example
430
+ # require "google/cloud/network_connectivity/v1"
431
+ #
432
+ # # Create a client object. The client can be reused for multiple calls.
433
+ # client = Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client.new
434
+ #
435
+ # # Create a request. To set request fields, pass in keyword arguments.
436
+ # request = Google::Cloud::NetworkConnectivity::V1::CreatePolicyBasedRouteRequest.new
437
+ #
438
+ # # Call the create_policy_based_route method.
439
+ # result = client.create_policy_based_route request
440
+ #
441
+ # # The returned object is of type Gapic::Operation. You can use it to
442
+ # # check the status of an operation, cancel it, or wait for results.
443
+ # # Here is how to wait for a response.
444
+ # result.wait_until_done! timeout: 60
445
+ # if result.response?
446
+ # p result.response
447
+ # else
448
+ # puts "No response received."
449
+ # end
450
+ #
451
+ def create_policy_based_route request, options = nil
452
+ raise ::ArgumentError, "request must be provided" if request.nil?
453
+
454
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::NetworkConnectivity::V1::CreatePolicyBasedRouteRequest
455
+
456
+ # Converts hash and nil to an options object
457
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
458
+
459
+ # Customize the options with defaults
460
+ metadata = @config.rpcs.create_policy_based_route.metadata.to_h
461
+
462
+ # Set x-goog-api-client and x-goog-user-project headers
463
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
464
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
465
+ gapic_version: ::Google::Cloud::NetworkConnectivity::V1::VERSION
466
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
467
+
468
+ header_params = {}
469
+ if request.parent
470
+ header_params["parent"] = request.parent
471
+ end
472
+
473
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
474
+ metadata[:"x-goog-request-params"] ||= request_params_header
475
+
476
+ options.apply_defaults timeout: @config.rpcs.create_policy_based_route.timeout,
477
+ metadata: metadata,
478
+ retry_policy: @config.rpcs.create_policy_based_route.retry_policy
479
+
480
+ options.apply_defaults timeout: @config.timeout,
481
+ metadata: @config.metadata,
482
+ retry_policy: @config.retry_policy
483
+
484
+ @policy_based_routing_service_stub.call_rpc :create_policy_based_route, request, options: options do |response, operation|
485
+ response = ::Gapic::Operation.new response, @operations_client, options: options
486
+ yield response, operation if block_given?
487
+ return response
488
+ end
489
+ rescue ::GRPC::BadStatus => e
490
+ raise ::Google::Cloud::Error.from_error(e)
491
+ end
492
+
493
+ ##
494
+ # Deletes a single PolicyBasedRoute.
495
+ #
496
+ # @overload delete_policy_based_route(request, options = nil)
497
+ # Pass arguments to `delete_policy_based_route` via a request object, either of type
498
+ # {::Google::Cloud::NetworkConnectivity::V1::DeletePolicyBasedRouteRequest} or an equivalent Hash.
499
+ #
500
+ # @param request [::Google::Cloud::NetworkConnectivity::V1::DeletePolicyBasedRouteRequest, ::Hash]
501
+ # A request object representing the call parameters. Required. To specify no
502
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
503
+ # @param options [::Gapic::CallOptions, ::Hash]
504
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
505
+ #
506
+ # @overload delete_policy_based_route(name: nil, request_id: nil)
507
+ # Pass arguments to `delete_policy_based_route` via keyword arguments. Note that at
508
+ # least one keyword argument is required. To specify no parameters, or to keep all
509
+ # the default parameter values, pass an empty Hash as a request object (see above).
510
+ #
511
+ # @param name [::String]
512
+ # Required. Name of the PolicyBasedRoute resource to delete.
513
+ # @param request_id [::String]
514
+ # Optional. An optional request ID to identify requests. Specify a unique
515
+ # request ID so that if you must retry your request, the server will know to
516
+ # ignore the request if it has already been completed. The server will
517
+ # guarantee that for at least 60 minutes after the first request.
518
+ #
519
+ # For example, consider a situation where you make an initial request and
520
+ # the request times out. If you make the request again with the same request
521
+ # ID, the server can check if original operation with the same request ID
522
+ # was received, and if so, will ignore the second request. This prevents
523
+ # clients from accidentally creating duplicate commitments.
524
+ #
525
+ # The request ID must be a valid UUID with the exception that zero UUID is
526
+ # not supported (00000000-0000-0000-0000-000000000000).
527
+ #
528
+ # @yield [response, operation] Access the result along with the RPC operation
529
+ # @yieldparam response [::Gapic::Operation]
530
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
531
+ #
532
+ # @return [::Gapic::Operation]
533
+ #
534
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
535
+ #
536
+ # @example Basic example
537
+ # require "google/cloud/network_connectivity/v1"
538
+ #
539
+ # # Create a client object. The client can be reused for multiple calls.
540
+ # client = Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client.new
541
+ #
542
+ # # Create a request. To set request fields, pass in keyword arguments.
543
+ # request = Google::Cloud::NetworkConnectivity::V1::DeletePolicyBasedRouteRequest.new
544
+ #
545
+ # # Call the delete_policy_based_route method.
546
+ # result = client.delete_policy_based_route request
547
+ #
548
+ # # The returned object is of type Gapic::Operation. You can use it to
549
+ # # check the status of an operation, cancel it, or wait for results.
550
+ # # Here is how to wait for a response.
551
+ # result.wait_until_done! timeout: 60
552
+ # if result.response?
553
+ # p result.response
554
+ # else
555
+ # puts "No response received."
556
+ # end
557
+ #
558
+ def delete_policy_based_route request, options = nil
559
+ raise ::ArgumentError, "request must be provided" if request.nil?
560
+
561
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::NetworkConnectivity::V1::DeletePolicyBasedRouteRequest
562
+
563
+ # Converts hash and nil to an options object
564
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
565
+
566
+ # Customize the options with defaults
567
+ metadata = @config.rpcs.delete_policy_based_route.metadata.to_h
568
+
569
+ # Set x-goog-api-client and x-goog-user-project headers
570
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
571
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
572
+ gapic_version: ::Google::Cloud::NetworkConnectivity::V1::VERSION
573
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
574
+
575
+ header_params = {}
576
+ if request.name
577
+ header_params["name"] = request.name
578
+ end
579
+
580
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
581
+ metadata[:"x-goog-request-params"] ||= request_params_header
582
+
583
+ options.apply_defaults timeout: @config.rpcs.delete_policy_based_route.timeout,
584
+ metadata: metadata,
585
+ retry_policy: @config.rpcs.delete_policy_based_route.retry_policy
586
+
587
+ options.apply_defaults timeout: @config.timeout,
588
+ metadata: @config.metadata,
589
+ retry_policy: @config.retry_policy
590
+
591
+ @policy_based_routing_service_stub.call_rpc :delete_policy_based_route, request, options: options do |response, operation|
592
+ response = ::Gapic::Operation.new response, @operations_client, options: options
593
+ yield response, operation if block_given?
594
+ return response
595
+ end
596
+ rescue ::GRPC::BadStatus => e
597
+ raise ::Google::Cloud::Error.from_error(e)
598
+ end
599
+
600
+ ##
601
+ # Configuration class for the PolicyBasedRoutingService API.
602
+ #
603
+ # This class represents the configuration for PolicyBasedRoutingService,
604
+ # providing control over timeouts, retry behavior, logging, transport
605
+ # parameters, and other low-level controls. Certain parameters can also be
606
+ # applied individually to specific RPCs. See
607
+ # {::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client::Configuration::Rpcs}
608
+ # for a list of RPCs that can be configured independently.
609
+ #
610
+ # Configuration can be applied globally to all clients, or to a single client
611
+ # on construction.
612
+ #
613
+ # @example
614
+ #
615
+ # # Modify the global config, setting the timeout for
616
+ # # list_policy_based_routes to 20 seconds,
617
+ # # and all remaining timeouts to 10 seconds.
618
+ # ::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client.configure do |config|
619
+ # config.timeout = 10.0
620
+ # config.rpcs.list_policy_based_routes.timeout = 20.0
621
+ # end
622
+ #
623
+ # # Apply the above configuration only to a new client.
624
+ # client = ::Google::Cloud::NetworkConnectivity::V1::PolicyBasedRoutingService::Client.new do |config|
625
+ # config.timeout = 10.0
626
+ # config.rpcs.list_policy_based_routes.timeout = 20.0
627
+ # end
628
+ #
629
+ # @!attribute [rw] endpoint
630
+ # The hostname or hostname:port of the service endpoint.
631
+ # Defaults to `"networkconnectivity.googleapis.com"`.
632
+ # @return [::String]
633
+ # @!attribute [rw] credentials
634
+ # Credentials to send with calls. You may provide any of the following types:
635
+ # * (`String`) The path to a service account key file in JSON format
636
+ # * (`Hash`) A service account key as a Hash
637
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
638
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
639
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
640
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
641
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
642
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
643
+ # * (`nil`) indicating no credentials
644
+ # @return [::Object]
645
+ # @!attribute [rw] scope
646
+ # The OAuth scopes
647
+ # @return [::Array<::String>]
648
+ # @!attribute [rw] lib_name
649
+ # The library name as recorded in instrumentation and logging
650
+ # @return [::String]
651
+ # @!attribute [rw] lib_version
652
+ # The library version as recorded in instrumentation and logging
653
+ # @return [::String]
654
+ # @!attribute [rw] channel_args
655
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
656
+ # `GRPC::Core::Channel` object is provided as the credential.
657
+ # @return [::Hash]
658
+ # @!attribute [rw] interceptors
659
+ # An array of interceptors that are run before calls are executed.
660
+ # @return [::Array<::GRPC::ClientInterceptor>]
661
+ # @!attribute [rw] timeout
662
+ # The call timeout in seconds.
663
+ # @return [::Numeric]
664
+ # @!attribute [rw] metadata
665
+ # Additional gRPC headers to be sent with the call.
666
+ # @return [::Hash{::Symbol=>::String}]
667
+ # @!attribute [rw] retry_policy
668
+ # The retry policy. The value is a hash with the following keys:
669
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
670
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
671
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
672
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
673
+ # trigger a retry.
674
+ # @return [::Hash]
675
+ # @!attribute [rw] quota_project
676
+ # A separate project against which to charge quota.
677
+ # @return [::String]
678
+ #
679
+ class Configuration
680
+ extend ::Gapic::Config
681
+
682
+ DEFAULT_ENDPOINT = "networkconnectivity.googleapis.com"
683
+
684
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
685
+ config_attr :credentials, nil do |value|
686
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
687
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
688
+ allowed.any? { |klass| klass === value }
689
+ end
690
+ config_attr :scope, nil, ::String, ::Array, nil
691
+ config_attr :lib_name, nil, ::String, nil
692
+ config_attr :lib_version, nil, ::String, nil
693
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
694
+ config_attr :interceptors, nil, ::Array, nil
695
+ config_attr :timeout, nil, ::Numeric, nil
696
+ config_attr :metadata, nil, ::Hash, nil
697
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
698
+ config_attr :quota_project, nil, ::String, nil
699
+
700
+ # @private
701
+ def initialize parent_config = nil
702
+ @parent_config = parent_config unless parent_config.nil?
703
+
704
+ yield self if block_given?
705
+ end
706
+
707
+ ##
708
+ # Configurations for individual RPCs
709
+ # @return [Rpcs]
710
+ #
711
+ def rpcs
712
+ @rpcs ||= begin
713
+ parent_rpcs = nil
714
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
715
+ Rpcs.new parent_rpcs
716
+ end
717
+ end
718
+
719
+ ##
720
+ # Configuration for the channel pool
721
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
722
+ #
723
+ def channel_pool
724
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
725
+ end
726
+
727
+ ##
728
+ # Configuration RPC class for the PolicyBasedRoutingService API.
729
+ #
730
+ # Includes fields providing the configuration for each RPC in this service.
731
+ # Each configuration object is of type `Gapic::Config::Method` and includes
732
+ # the following configuration fields:
733
+ #
734
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
735
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
736
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
737
+ # include the following keys:
738
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
739
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
740
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
741
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
742
+ # trigger a retry.
743
+ #
744
+ class Rpcs
745
+ ##
746
+ # RPC-specific configuration for `list_policy_based_routes`
747
+ # @return [::Gapic::Config::Method]
748
+ #
749
+ attr_reader :list_policy_based_routes
750
+ ##
751
+ # RPC-specific configuration for `get_policy_based_route`
752
+ # @return [::Gapic::Config::Method]
753
+ #
754
+ attr_reader :get_policy_based_route
755
+ ##
756
+ # RPC-specific configuration for `create_policy_based_route`
757
+ # @return [::Gapic::Config::Method]
758
+ #
759
+ attr_reader :create_policy_based_route
760
+ ##
761
+ # RPC-specific configuration for `delete_policy_based_route`
762
+ # @return [::Gapic::Config::Method]
763
+ #
764
+ attr_reader :delete_policy_based_route
765
+
766
+ # @private
767
+ def initialize parent_rpcs = nil
768
+ list_policy_based_routes_config = parent_rpcs.list_policy_based_routes if parent_rpcs.respond_to? :list_policy_based_routes
769
+ @list_policy_based_routes = ::Gapic::Config::Method.new list_policy_based_routes_config
770
+ get_policy_based_route_config = parent_rpcs.get_policy_based_route if parent_rpcs.respond_to? :get_policy_based_route
771
+ @get_policy_based_route = ::Gapic::Config::Method.new get_policy_based_route_config
772
+ create_policy_based_route_config = parent_rpcs.create_policy_based_route if parent_rpcs.respond_to? :create_policy_based_route
773
+ @create_policy_based_route = ::Gapic::Config::Method.new create_policy_based_route_config
774
+ delete_policy_based_route_config = parent_rpcs.delete_policy_based_route if parent_rpcs.respond_to? :delete_policy_based_route
775
+ @delete_policy_based_route = ::Gapic::Config::Method.new delete_policy_based_route_config
776
+
777
+ yield self if block_given?
778
+ end
779
+ end
780
+ end
781
+ end
782
+ end
783
+ end
784
+ end
785
+ end
786
+ end