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