google-cloud-network_management-v1 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,949 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025 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/networkmanagement/v1/vpc_flow_logs_pb"
21
+ require "google/cloud/location"
22
+ require "google/iam/v1"
23
+
24
+ module Google
25
+ module Cloud
26
+ module NetworkManagement
27
+ module V1
28
+ module VpcFlowLogsService
29
+ ##
30
+ # Client for the VpcFlowLogsService service.
31
+ #
32
+ # The VPC Flow Logs service in the Google Cloud Network Management API provides
33
+ # configurations that generate Flow Logs. The service and the configuration
34
+ # resources created using this service are global.
35
+ #
36
+ class Client
37
+ # @private
38
+ API_VERSION = ""
39
+
40
+ # @private
41
+ DEFAULT_ENDPOINT_TEMPLATE = "networkmanagement.$UNIVERSE_DOMAIN$"
42
+
43
+ include Paths
44
+
45
+ # @private
46
+ attr_reader :vpc_flow_logs_service_stub
47
+
48
+ ##
49
+ # Configure the VpcFlowLogsService Client class.
50
+ #
51
+ # See {::Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client::Configuration}
52
+ # for a description of the configuration fields.
53
+ #
54
+ # @example
55
+ #
56
+ # # Modify the configuration for all VpcFlowLogsService clients
57
+ # ::Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.configure do |config|
58
+ # config.timeout = 10.0
59
+ # end
60
+ #
61
+ # @yield [config] Configure the Client client.
62
+ # @yieldparam config [Client::Configuration]
63
+ #
64
+ # @return [Client::Configuration]
65
+ #
66
+ def self.configure
67
+ @configure ||= begin
68
+ namespace = ["Google", "Cloud", "NetworkManagement", "V1"]
69
+ parent_config = while namespace.any?
70
+ parent_name = namespace.join "::"
71
+ parent_const = const_get parent_name
72
+ break parent_const.configure if parent_const.respond_to? :configure
73
+ namespace.pop
74
+ end
75
+ default_config = Client::Configuration.new parent_config
76
+
77
+ default_config
78
+ end
79
+ yield @configure if block_given?
80
+ @configure
81
+ end
82
+
83
+ ##
84
+ # Configure the VpcFlowLogsService 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::NetworkManagement::V1::VpcFlowLogsService::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
+ # The effective universe domain
105
+ #
106
+ # @return [String]
107
+ #
108
+ def universe_domain
109
+ @vpc_flow_logs_service_stub.universe_domain
110
+ end
111
+
112
+ ##
113
+ # Create a new VpcFlowLogsService client object.
114
+ #
115
+ # @example
116
+ #
117
+ # # Create a client using the default configuration
118
+ # client = ::Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.new
119
+ #
120
+ # # Create a client using a custom configuration
121
+ # client = ::Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.new do |config|
122
+ # config.timeout = 10.0
123
+ # end
124
+ #
125
+ # @yield [config] Configure the VpcFlowLogsService client.
126
+ # @yieldparam config [Client::Configuration]
127
+ #
128
+ def initialize
129
+ # These require statements are intentionally placed here to initialize
130
+ # the gRPC module only when it's required.
131
+ # See https://github.com/googleapis/toolkit/issues/446
132
+ require "gapic/grpc"
133
+ require "google/cloud/networkmanagement/v1/vpc_flow_logs_services_pb"
134
+
135
+ # Create the configuration object
136
+ @config = Configuration.new Client.configure
137
+
138
+ # Yield the configuration if needed
139
+ yield @config if block_given?
140
+
141
+ # Create credentials
142
+ credentials = @config.credentials
143
+ # Use self-signed JWT if the endpoint is unchanged from default,
144
+ # but only if the default endpoint does not have a region prefix.
145
+ enable_self_signed_jwt = @config.endpoint.nil? ||
146
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
147
+ !@config.endpoint.split(".").first.include?("-"))
148
+ credentials ||= Credentials.default scope: @config.scope,
149
+ enable_self_signed_jwt: enable_self_signed_jwt
150
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
151
+ credentials = Credentials.new credentials, scope: @config.scope
152
+ end
153
+ @quota_project_id = @config.quota_project
154
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
155
+
156
+ @operations_client = Operations.new do |config|
157
+ config.credentials = credentials
158
+ config.quota_project = @quota_project_id
159
+ config.endpoint = @config.endpoint
160
+ config.universe_domain = @config.universe_domain
161
+ end
162
+
163
+ @vpc_flow_logs_service_stub = ::Gapic::ServiceStub.new(
164
+ ::Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Stub,
165
+ credentials: credentials,
166
+ endpoint: @config.endpoint,
167
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
168
+ universe_domain: @config.universe_domain,
169
+ channel_args: @config.channel_args,
170
+ interceptors: @config.interceptors,
171
+ channel_pool_config: @config.channel_pool,
172
+ logger: @config.logger
173
+ )
174
+
175
+ @vpc_flow_logs_service_stub.stub_logger&.info do |entry|
176
+ entry.set_system_name
177
+ entry.set_service
178
+ entry.message = "Created client for #{entry.service}"
179
+ entry.set_credentials_fields credentials
180
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
181
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
182
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
183
+ end
184
+
185
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
186
+ config.credentials = credentials
187
+ config.quota_project = @quota_project_id
188
+ config.endpoint = @vpc_flow_logs_service_stub.endpoint
189
+ config.universe_domain = @vpc_flow_logs_service_stub.universe_domain
190
+ config.logger = @vpc_flow_logs_service_stub.logger if config.respond_to? :logger=
191
+ end
192
+
193
+ @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
194
+ config.credentials = credentials
195
+ config.quota_project = @quota_project_id
196
+ config.endpoint = @vpc_flow_logs_service_stub.endpoint
197
+ config.universe_domain = @vpc_flow_logs_service_stub.universe_domain
198
+ config.logger = @vpc_flow_logs_service_stub.logger if config.respond_to? :logger=
199
+ end
200
+ end
201
+
202
+ ##
203
+ # Get the associated client for long-running operations.
204
+ #
205
+ # @return [::Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Operations]
206
+ #
207
+ attr_reader :operations_client
208
+
209
+ ##
210
+ # Get the associated client for mix-in of the Locations.
211
+ #
212
+ # @return [Google::Cloud::Location::Locations::Client]
213
+ #
214
+ attr_reader :location_client
215
+
216
+ ##
217
+ # Get the associated client for mix-in of the IAMPolicy.
218
+ #
219
+ # @return [Google::Iam::V1::IAMPolicy::Client]
220
+ #
221
+ attr_reader :iam_policy_client
222
+
223
+ ##
224
+ # The logger used for request/response debug logging.
225
+ #
226
+ # @return [Logger]
227
+ #
228
+ def logger
229
+ @vpc_flow_logs_service_stub.logger
230
+ end
231
+
232
+ # Service calls
233
+
234
+ ##
235
+ # Lists all `VpcFlowLogsConfigs` in a given project.
236
+ #
237
+ # @overload list_vpc_flow_logs_configs(request, options = nil)
238
+ # Pass arguments to `list_vpc_flow_logs_configs` via a request object, either of type
239
+ # {::Google::Cloud::NetworkManagement::V1::ListVpcFlowLogsConfigsRequest} or an equivalent Hash.
240
+ #
241
+ # @param request [::Google::Cloud::NetworkManagement::V1::ListVpcFlowLogsConfigsRequest, ::Hash]
242
+ # A request object representing the call parameters. Required. To specify no
243
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
244
+ # @param options [::Gapic::CallOptions, ::Hash]
245
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
246
+ #
247
+ # @overload list_vpc_flow_logs_configs(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
248
+ # Pass arguments to `list_vpc_flow_logs_configs` via keyword arguments. Note that at
249
+ # least one keyword argument is required. To specify no parameters, or to keep all
250
+ # the default parameter values, pass an empty Hash as a request object (see above).
251
+ #
252
+ # @param parent [::String]
253
+ # Required. The parent resource of the VpcFlowLogsConfig:
254
+ # `projects/{project_id}/locations/global`
255
+ # @param page_size [::Integer]
256
+ # Optional. Number of `VpcFlowLogsConfigs` to return.
257
+ # @param page_token [::String]
258
+ # Optional. Page token from an earlier query, as returned in
259
+ # `next_page_token`.
260
+ # @param filter [::String]
261
+ # Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression.
262
+ # A filter expression must use the supported [CEL logic operators]
263
+ # (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators).
264
+ # @param order_by [::String]
265
+ # Optional. Field to use to sort the list.
266
+ #
267
+ # @yield [response, operation] Access the result along with the RPC operation
268
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::NetworkManagement::V1::VpcFlowLogsConfig>]
269
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
270
+ #
271
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::NetworkManagement::V1::VpcFlowLogsConfig>]
272
+ #
273
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
274
+ #
275
+ # @example Basic example
276
+ # require "google/cloud/network_management/v1"
277
+ #
278
+ # # Create a client object. The client can be reused for multiple calls.
279
+ # client = Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.new
280
+ #
281
+ # # Create a request. To set request fields, pass in keyword arguments.
282
+ # request = Google::Cloud::NetworkManagement::V1::ListVpcFlowLogsConfigsRequest.new
283
+ #
284
+ # # Call the list_vpc_flow_logs_configs method.
285
+ # result = client.list_vpc_flow_logs_configs request
286
+ #
287
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
288
+ # # over elements, and API calls will be issued to fetch pages as needed.
289
+ # result.each do |item|
290
+ # # Each element is of type ::Google::Cloud::NetworkManagement::V1::VpcFlowLogsConfig.
291
+ # p item
292
+ # end
293
+ #
294
+ def list_vpc_flow_logs_configs request, options = nil
295
+ raise ::ArgumentError, "request must be provided" if request.nil?
296
+
297
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::NetworkManagement::V1::ListVpcFlowLogsConfigsRequest
298
+
299
+ # Converts hash and nil to an options object
300
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
301
+
302
+ # Customize the options with defaults
303
+ metadata = @config.rpcs.list_vpc_flow_logs_configs.metadata.to_h
304
+
305
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
306
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
307
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
308
+ gapic_version: ::Google::Cloud::NetworkManagement::V1::VERSION
309
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
310
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
311
+
312
+ header_params = {}
313
+ if request.parent
314
+ header_params["parent"] = request.parent
315
+ end
316
+
317
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
318
+ metadata[:"x-goog-request-params"] ||= request_params_header
319
+
320
+ options.apply_defaults timeout: @config.rpcs.list_vpc_flow_logs_configs.timeout,
321
+ metadata: metadata,
322
+ retry_policy: @config.rpcs.list_vpc_flow_logs_configs.retry_policy
323
+
324
+ options.apply_defaults timeout: @config.timeout,
325
+ metadata: @config.metadata,
326
+ retry_policy: @config.retry_policy
327
+
328
+ @vpc_flow_logs_service_stub.call_rpc :list_vpc_flow_logs_configs, request, options: options do |response, operation|
329
+ response = ::Gapic::PagedEnumerable.new @vpc_flow_logs_service_stub, :list_vpc_flow_logs_configs, request, response, operation, options
330
+ yield response, operation if block_given?
331
+ throw :response, response
332
+ end
333
+ rescue ::GRPC::BadStatus => e
334
+ raise ::Google::Cloud::Error.from_error(e)
335
+ end
336
+
337
+ ##
338
+ # Gets the details of a specific `VpcFlowLogsConfig`.
339
+ #
340
+ # @overload get_vpc_flow_logs_config(request, options = nil)
341
+ # Pass arguments to `get_vpc_flow_logs_config` via a request object, either of type
342
+ # {::Google::Cloud::NetworkManagement::V1::GetVpcFlowLogsConfigRequest} or an equivalent Hash.
343
+ #
344
+ # @param request [::Google::Cloud::NetworkManagement::V1::GetVpcFlowLogsConfigRequest, ::Hash]
345
+ # A request object representing the call parameters. Required. To specify no
346
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
347
+ # @param options [::Gapic::CallOptions, ::Hash]
348
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
349
+ #
350
+ # @overload get_vpc_flow_logs_config(name: nil)
351
+ # Pass arguments to `get_vpc_flow_logs_config` via keyword arguments. Note that at
352
+ # least one keyword argument is required. To specify no parameters, or to keep all
353
+ # the default parameter values, pass an empty Hash as a request object (see above).
354
+ #
355
+ # @param name [::String]
356
+ # Required. `VpcFlowLogsConfig` resource name using the form:
357
+ # `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config}`
358
+ #
359
+ # @yield [response, operation] Access the result along with the RPC operation
360
+ # @yieldparam response [::Google::Cloud::NetworkManagement::V1::VpcFlowLogsConfig]
361
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
362
+ #
363
+ # @return [::Google::Cloud::NetworkManagement::V1::VpcFlowLogsConfig]
364
+ #
365
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
366
+ #
367
+ # @example Basic example
368
+ # require "google/cloud/network_management/v1"
369
+ #
370
+ # # Create a client object. The client can be reused for multiple calls.
371
+ # client = Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.new
372
+ #
373
+ # # Create a request. To set request fields, pass in keyword arguments.
374
+ # request = Google::Cloud::NetworkManagement::V1::GetVpcFlowLogsConfigRequest.new
375
+ #
376
+ # # Call the get_vpc_flow_logs_config method.
377
+ # result = client.get_vpc_flow_logs_config request
378
+ #
379
+ # # The returned object is of type Google::Cloud::NetworkManagement::V1::VpcFlowLogsConfig.
380
+ # p result
381
+ #
382
+ def get_vpc_flow_logs_config request, options = nil
383
+ raise ::ArgumentError, "request must be provided" if request.nil?
384
+
385
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::NetworkManagement::V1::GetVpcFlowLogsConfigRequest
386
+
387
+ # Converts hash and nil to an options object
388
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
389
+
390
+ # Customize the options with defaults
391
+ metadata = @config.rpcs.get_vpc_flow_logs_config.metadata.to_h
392
+
393
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
394
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
395
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
396
+ gapic_version: ::Google::Cloud::NetworkManagement::V1::VERSION
397
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
398
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
399
+
400
+ header_params = {}
401
+ if request.name
402
+ header_params["name"] = request.name
403
+ end
404
+
405
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
406
+ metadata[:"x-goog-request-params"] ||= request_params_header
407
+
408
+ options.apply_defaults timeout: @config.rpcs.get_vpc_flow_logs_config.timeout,
409
+ metadata: metadata,
410
+ retry_policy: @config.rpcs.get_vpc_flow_logs_config.retry_policy
411
+
412
+ options.apply_defaults timeout: @config.timeout,
413
+ metadata: @config.metadata,
414
+ retry_policy: @config.retry_policy
415
+
416
+ @vpc_flow_logs_service_stub.call_rpc :get_vpc_flow_logs_config, request, options: options do |response, operation|
417
+ yield response, operation if block_given?
418
+ end
419
+ rescue ::GRPC::BadStatus => e
420
+ raise ::Google::Cloud::Error.from_error(e)
421
+ end
422
+
423
+ ##
424
+ # Creates a new `VpcFlowLogsConfig`.
425
+ # If a configuration with the exact same settings already exists (even if the
426
+ # ID is different), the creation fails.
427
+ # Notes:
428
+ #
429
+ # 1. Creating a configuration with state=DISABLED will fail
430
+ # 2. The following fields are not considered as `settings` for the purpose
431
+ # of the check mentioned above, therefore - creating another configuration
432
+ # with the same fields but different values for the following fields will
433
+ # fail as well:
434
+ # * name
435
+ # * create_time
436
+ # * update_time
437
+ # * labels
438
+ # * description
439
+ #
440
+ # @overload create_vpc_flow_logs_config(request, options = nil)
441
+ # Pass arguments to `create_vpc_flow_logs_config` via a request object, either of type
442
+ # {::Google::Cloud::NetworkManagement::V1::CreateVpcFlowLogsConfigRequest} or an equivalent Hash.
443
+ #
444
+ # @param request [::Google::Cloud::NetworkManagement::V1::CreateVpcFlowLogsConfigRequest, ::Hash]
445
+ # A request object representing the call parameters. Required. To specify no
446
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
447
+ # @param options [::Gapic::CallOptions, ::Hash]
448
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
449
+ #
450
+ # @overload create_vpc_flow_logs_config(parent: nil, vpc_flow_logs_config_id: nil, vpc_flow_logs_config: nil)
451
+ # Pass arguments to `create_vpc_flow_logs_config` via keyword arguments. Note that at
452
+ # least one keyword argument is required. To specify no parameters, or to keep all
453
+ # the default parameter values, pass an empty Hash as a request object (see above).
454
+ #
455
+ # @param parent [::String]
456
+ # Required. The parent resource of the VPC Flow Logs configuration to create:
457
+ # `projects/{project_id}/locations/global`
458
+ # @param vpc_flow_logs_config_id [::String]
459
+ # Required. ID of the `VpcFlowLogsConfig`.
460
+ # @param vpc_flow_logs_config [::Google::Cloud::NetworkManagement::V1::VpcFlowLogsConfig, ::Hash]
461
+ # Required. A `VpcFlowLogsConfig` resource
462
+ #
463
+ # @yield [response, operation] Access the result along with the RPC operation
464
+ # @yieldparam response [::Gapic::Operation]
465
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
466
+ #
467
+ # @return [::Gapic::Operation]
468
+ #
469
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
470
+ #
471
+ # @example Basic example
472
+ # require "google/cloud/network_management/v1"
473
+ #
474
+ # # Create a client object. The client can be reused for multiple calls.
475
+ # client = Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.new
476
+ #
477
+ # # Create a request. To set request fields, pass in keyword arguments.
478
+ # request = Google::Cloud::NetworkManagement::V1::CreateVpcFlowLogsConfigRequest.new
479
+ #
480
+ # # Call the create_vpc_flow_logs_config method.
481
+ # result = client.create_vpc_flow_logs_config request
482
+ #
483
+ # # The returned object is of type Gapic::Operation. You can use it to
484
+ # # check the status of an operation, cancel it, or wait for results.
485
+ # # Here is how to wait for a response.
486
+ # result.wait_until_done! timeout: 60
487
+ # if result.response?
488
+ # p result.response
489
+ # else
490
+ # puts "No response received."
491
+ # end
492
+ #
493
+ def create_vpc_flow_logs_config request, options = nil
494
+ raise ::ArgumentError, "request must be provided" if request.nil?
495
+
496
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::NetworkManagement::V1::CreateVpcFlowLogsConfigRequest
497
+
498
+ # Converts hash and nil to an options object
499
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
500
+
501
+ # Customize the options with defaults
502
+ metadata = @config.rpcs.create_vpc_flow_logs_config.metadata.to_h
503
+
504
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
505
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
506
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
507
+ gapic_version: ::Google::Cloud::NetworkManagement::V1::VERSION
508
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
509
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
510
+
511
+ header_params = {}
512
+ if request.parent
513
+ header_params["parent"] = request.parent
514
+ end
515
+
516
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
517
+ metadata[:"x-goog-request-params"] ||= request_params_header
518
+
519
+ options.apply_defaults timeout: @config.rpcs.create_vpc_flow_logs_config.timeout,
520
+ metadata: metadata,
521
+ retry_policy: @config.rpcs.create_vpc_flow_logs_config.retry_policy
522
+
523
+ options.apply_defaults timeout: @config.timeout,
524
+ metadata: @config.metadata,
525
+ retry_policy: @config.retry_policy
526
+
527
+ @vpc_flow_logs_service_stub.call_rpc :create_vpc_flow_logs_config, request, options: options do |response, operation|
528
+ response = ::Gapic::Operation.new response, @operations_client, options: options
529
+ yield response, operation if block_given?
530
+ throw :response, response
531
+ end
532
+ rescue ::GRPC::BadStatus => e
533
+ raise ::Google::Cloud::Error.from_error(e)
534
+ end
535
+
536
+ ##
537
+ # Updates an existing `VpcFlowLogsConfig`.
538
+ # If a configuration with the exact same settings already exists (even if the
539
+ # ID is different), the creation fails.
540
+ # Notes:
541
+ #
542
+ # 1. Updating a configuration with state=DISABLED will fail.
543
+ # 2. The following fields are not considered as `settings` for the purpose
544
+ # of the check mentioned above, therefore - updating another configuration
545
+ # with the same fields but different values for the following fields will
546
+ # fail as well:
547
+ # * name
548
+ # * create_time
549
+ # * update_time
550
+ # * labels
551
+ # * description
552
+ #
553
+ # @overload update_vpc_flow_logs_config(request, options = nil)
554
+ # Pass arguments to `update_vpc_flow_logs_config` via a request object, either of type
555
+ # {::Google::Cloud::NetworkManagement::V1::UpdateVpcFlowLogsConfigRequest} or an equivalent Hash.
556
+ #
557
+ # @param request [::Google::Cloud::NetworkManagement::V1::UpdateVpcFlowLogsConfigRequest, ::Hash]
558
+ # A request object representing the call parameters. Required. To specify no
559
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
560
+ # @param options [::Gapic::CallOptions, ::Hash]
561
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
562
+ #
563
+ # @overload update_vpc_flow_logs_config(update_mask: nil, vpc_flow_logs_config: nil)
564
+ # Pass arguments to `update_vpc_flow_logs_config` via keyword arguments. Note that at
565
+ # least one keyword argument is required. To specify no parameters, or to keep all
566
+ # the default parameter values, pass an empty Hash as a request object (see above).
567
+ #
568
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
569
+ # Required. Mask of fields to update. At least one path must be supplied in
570
+ # this field.
571
+ # @param vpc_flow_logs_config [::Google::Cloud::NetworkManagement::V1::VpcFlowLogsConfig, ::Hash]
572
+ # Required. Only fields specified in update_mask are updated.
573
+ #
574
+ # @yield [response, operation] Access the result along with the RPC operation
575
+ # @yieldparam response [::Gapic::Operation]
576
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
577
+ #
578
+ # @return [::Gapic::Operation]
579
+ #
580
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
581
+ #
582
+ # @example Basic example
583
+ # require "google/cloud/network_management/v1"
584
+ #
585
+ # # Create a client object. The client can be reused for multiple calls.
586
+ # client = Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.new
587
+ #
588
+ # # Create a request. To set request fields, pass in keyword arguments.
589
+ # request = Google::Cloud::NetworkManagement::V1::UpdateVpcFlowLogsConfigRequest.new
590
+ #
591
+ # # Call the update_vpc_flow_logs_config method.
592
+ # result = client.update_vpc_flow_logs_config request
593
+ #
594
+ # # The returned object is of type Gapic::Operation. You can use it to
595
+ # # check the status of an operation, cancel it, or wait for results.
596
+ # # Here is how to wait for a response.
597
+ # result.wait_until_done! timeout: 60
598
+ # if result.response?
599
+ # p result.response
600
+ # else
601
+ # puts "No response received."
602
+ # end
603
+ #
604
+ def update_vpc_flow_logs_config request, options = nil
605
+ raise ::ArgumentError, "request must be provided" if request.nil?
606
+
607
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::NetworkManagement::V1::UpdateVpcFlowLogsConfigRequest
608
+
609
+ # Converts hash and nil to an options object
610
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
611
+
612
+ # Customize the options with defaults
613
+ metadata = @config.rpcs.update_vpc_flow_logs_config.metadata.to_h
614
+
615
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
616
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
617
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
618
+ gapic_version: ::Google::Cloud::NetworkManagement::V1::VERSION
619
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
620
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
621
+
622
+ header_params = {}
623
+ if request.vpc_flow_logs_config&.name
624
+ header_params["vpc_flow_logs_config.name"] = request.vpc_flow_logs_config.name
625
+ end
626
+
627
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
628
+ metadata[:"x-goog-request-params"] ||= request_params_header
629
+
630
+ options.apply_defaults timeout: @config.rpcs.update_vpc_flow_logs_config.timeout,
631
+ metadata: metadata,
632
+ retry_policy: @config.rpcs.update_vpc_flow_logs_config.retry_policy
633
+
634
+ options.apply_defaults timeout: @config.timeout,
635
+ metadata: @config.metadata,
636
+ retry_policy: @config.retry_policy
637
+
638
+ @vpc_flow_logs_service_stub.call_rpc :update_vpc_flow_logs_config, request, options: options do |response, operation|
639
+ response = ::Gapic::Operation.new response, @operations_client, options: options
640
+ yield response, operation if block_given?
641
+ throw :response, response
642
+ end
643
+ rescue ::GRPC::BadStatus => e
644
+ raise ::Google::Cloud::Error.from_error(e)
645
+ end
646
+
647
+ ##
648
+ # Deletes a specific `VpcFlowLogsConfig`.
649
+ #
650
+ # @overload delete_vpc_flow_logs_config(request, options = nil)
651
+ # Pass arguments to `delete_vpc_flow_logs_config` via a request object, either of type
652
+ # {::Google::Cloud::NetworkManagement::V1::DeleteVpcFlowLogsConfigRequest} or an equivalent Hash.
653
+ #
654
+ # @param request [::Google::Cloud::NetworkManagement::V1::DeleteVpcFlowLogsConfigRequest, ::Hash]
655
+ # A request object representing the call parameters. Required. To specify no
656
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
657
+ # @param options [::Gapic::CallOptions, ::Hash]
658
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
659
+ #
660
+ # @overload delete_vpc_flow_logs_config(name: nil)
661
+ # Pass arguments to `delete_vpc_flow_logs_config` via keyword arguments. Note that at
662
+ # least one keyword argument is required. To specify no parameters, or to keep all
663
+ # the default parameter values, pass an empty Hash as a request object (see above).
664
+ #
665
+ # @param name [::String]
666
+ # Required. `VpcFlowLogsConfig` resource name using the form:
667
+ # `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config}`
668
+ #
669
+ # @yield [response, operation] Access the result along with the RPC operation
670
+ # @yieldparam response [::Gapic::Operation]
671
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
672
+ #
673
+ # @return [::Gapic::Operation]
674
+ #
675
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
676
+ #
677
+ # @example Basic example
678
+ # require "google/cloud/network_management/v1"
679
+ #
680
+ # # Create a client object. The client can be reused for multiple calls.
681
+ # client = Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.new
682
+ #
683
+ # # Create a request. To set request fields, pass in keyword arguments.
684
+ # request = Google::Cloud::NetworkManagement::V1::DeleteVpcFlowLogsConfigRequest.new
685
+ #
686
+ # # Call the delete_vpc_flow_logs_config method.
687
+ # result = client.delete_vpc_flow_logs_config request
688
+ #
689
+ # # The returned object is of type Gapic::Operation. You can use it to
690
+ # # check the status of an operation, cancel it, or wait for results.
691
+ # # Here is how to wait for a response.
692
+ # result.wait_until_done! timeout: 60
693
+ # if result.response?
694
+ # p result.response
695
+ # else
696
+ # puts "No response received."
697
+ # end
698
+ #
699
+ def delete_vpc_flow_logs_config request, options = nil
700
+ raise ::ArgumentError, "request must be provided" if request.nil?
701
+
702
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::NetworkManagement::V1::DeleteVpcFlowLogsConfigRequest
703
+
704
+ # Converts hash and nil to an options object
705
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
706
+
707
+ # Customize the options with defaults
708
+ metadata = @config.rpcs.delete_vpc_flow_logs_config.metadata.to_h
709
+
710
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
711
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
712
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
713
+ gapic_version: ::Google::Cloud::NetworkManagement::V1::VERSION
714
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
715
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
716
+
717
+ header_params = {}
718
+ if request.name
719
+ header_params["name"] = request.name
720
+ end
721
+
722
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
723
+ metadata[:"x-goog-request-params"] ||= request_params_header
724
+
725
+ options.apply_defaults timeout: @config.rpcs.delete_vpc_flow_logs_config.timeout,
726
+ metadata: metadata,
727
+ retry_policy: @config.rpcs.delete_vpc_flow_logs_config.retry_policy
728
+
729
+ options.apply_defaults timeout: @config.timeout,
730
+ metadata: @config.metadata,
731
+ retry_policy: @config.retry_policy
732
+
733
+ @vpc_flow_logs_service_stub.call_rpc :delete_vpc_flow_logs_config, request, options: options do |response, operation|
734
+ response = ::Gapic::Operation.new response, @operations_client, options: options
735
+ yield response, operation if block_given?
736
+ throw :response, response
737
+ end
738
+ rescue ::GRPC::BadStatus => e
739
+ raise ::Google::Cloud::Error.from_error(e)
740
+ end
741
+
742
+ ##
743
+ # Configuration class for the VpcFlowLogsService API.
744
+ #
745
+ # This class represents the configuration for VpcFlowLogsService,
746
+ # providing control over timeouts, retry behavior, logging, transport
747
+ # parameters, and other low-level controls. Certain parameters can also be
748
+ # applied individually to specific RPCs. See
749
+ # {::Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client::Configuration::Rpcs}
750
+ # for a list of RPCs that can be configured independently.
751
+ #
752
+ # Configuration can be applied globally to all clients, or to a single client
753
+ # on construction.
754
+ #
755
+ # @example
756
+ #
757
+ # # Modify the global config, setting the timeout for
758
+ # # list_vpc_flow_logs_configs to 20 seconds,
759
+ # # and all remaining timeouts to 10 seconds.
760
+ # ::Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.configure do |config|
761
+ # config.timeout = 10.0
762
+ # config.rpcs.list_vpc_flow_logs_configs.timeout = 20.0
763
+ # end
764
+ #
765
+ # # Apply the above configuration only to a new client.
766
+ # client = ::Google::Cloud::NetworkManagement::V1::VpcFlowLogsService::Client.new do |config|
767
+ # config.timeout = 10.0
768
+ # config.rpcs.list_vpc_flow_logs_configs.timeout = 20.0
769
+ # end
770
+ #
771
+ # @!attribute [rw] endpoint
772
+ # A custom service endpoint, as a hostname or hostname:port. The default is
773
+ # nil, indicating to use the default endpoint in the current universe domain.
774
+ # @return [::String,nil]
775
+ # @!attribute [rw] credentials
776
+ # Credentials to send with calls. You may provide any of the following types:
777
+ # * (`String`) The path to a service account key file in JSON format
778
+ # * (`Hash`) A service account key as a Hash
779
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
780
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
781
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
782
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
783
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
784
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
785
+ # * (`nil`) indicating no credentials
786
+ # @return [::Object]
787
+ # @!attribute [rw] scope
788
+ # The OAuth scopes
789
+ # @return [::Array<::String>]
790
+ # @!attribute [rw] lib_name
791
+ # The library name as recorded in instrumentation and logging
792
+ # @return [::String]
793
+ # @!attribute [rw] lib_version
794
+ # The library version as recorded in instrumentation and logging
795
+ # @return [::String]
796
+ # @!attribute [rw] channel_args
797
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
798
+ # `GRPC::Core::Channel` object is provided as the credential.
799
+ # @return [::Hash]
800
+ # @!attribute [rw] interceptors
801
+ # An array of interceptors that are run before calls are executed.
802
+ # @return [::Array<::GRPC::ClientInterceptor>]
803
+ # @!attribute [rw] timeout
804
+ # The call timeout in seconds.
805
+ # @return [::Numeric]
806
+ # @!attribute [rw] metadata
807
+ # Additional gRPC headers to be sent with the call.
808
+ # @return [::Hash{::Symbol=>::String}]
809
+ # @!attribute [rw] retry_policy
810
+ # The retry policy. The value is a hash with the following keys:
811
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
812
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
813
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
814
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
815
+ # trigger a retry.
816
+ # @return [::Hash]
817
+ # @!attribute [rw] quota_project
818
+ # A separate project against which to charge quota.
819
+ # @return [::String]
820
+ # @!attribute [rw] universe_domain
821
+ # The universe domain within which to make requests. This determines the
822
+ # default endpoint URL. The default value of nil uses the environment
823
+ # universe (usually the default "googleapis.com" universe).
824
+ # @return [::String,nil]
825
+ # @!attribute [rw] logger
826
+ # A custom logger to use for request/response debug logging, or the value
827
+ # `:default` (the default) to construct a default logger, or `nil` to
828
+ # explicitly disable logging.
829
+ # @return [::Logger,:default,nil]
830
+ #
831
+ class Configuration
832
+ extend ::Gapic::Config
833
+
834
+ # @private
835
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
836
+ DEFAULT_ENDPOINT = "networkmanagement.googleapis.com"
837
+
838
+ config_attr :endpoint, nil, ::String, nil
839
+ config_attr :credentials, nil do |value|
840
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
841
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
842
+ allowed.any? { |klass| klass === value }
843
+ end
844
+ config_attr :scope, nil, ::String, ::Array, nil
845
+ config_attr :lib_name, nil, ::String, nil
846
+ config_attr :lib_version, nil, ::String, nil
847
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
848
+ config_attr :interceptors, nil, ::Array, nil
849
+ config_attr :timeout, nil, ::Numeric, nil
850
+ config_attr :metadata, nil, ::Hash, nil
851
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
852
+ config_attr :quota_project, nil, ::String, nil
853
+ config_attr :universe_domain, nil, ::String, nil
854
+ config_attr :logger, :default, ::Logger, nil, :default
855
+
856
+ # @private
857
+ def initialize parent_config = nil
858
+ @parent_config = parent_config unless parent_config.nil?
859
+
860
+ yield self if block_given?
861
+ end
862
+
863
+ ##
864
+ # Configurations for individual RPCs
865
+ # @return [Rpcs]
866
+ #
867
+ def rpcs
868
+ @rpcs ||= begin
869
+ parent_rpcs = nil
870
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
871
+ Rpcs.new parent_rpcs
872
+ end
873
+ end
874
+
875
+ ##
876
+ # Configuration for the channel pool
877
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
878
+ #
879
+ def channel_pool
880
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
881
+ end
882
+
883
+ ##
884
+ # Configuration RPC class for the VpcFlowLogsService API.
885
+ #
886
+ # Includes fields providing the configuration for each RPC in this service.
887
+ # Each configuration object is of type `Gapic::Config::Method` and includes
888
+ # the following configuration fields:
889
+ #
890
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
891
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
892
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
893
+ # include the following keys:
894
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
895
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
896
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
897
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
898
+ # trigger a retry.
899
+ #
900
+ class Rpcs
901
+ ##
902
+ # RPC-specific configuration for `list_vpc_flow_logs_configs`
903
+ # @return [::Gapic::Config::Method]
904
+ #
905
+ attr_reader :list_vpc_flow_logs_configs
906
+ ##
907
+ # RPC-specific configuration for `get_vpc_flow_logs_config`
908
+ # @return [::Gapic::Config::Method]
909
+ #
910
+ attr_reader :get_vpc_flow_logs_config
911
+ ##
912
+ # RPC-specific configuration for `create_vpc_flow_logs_config`
913
+ # @return [::Gapic::Config::Method]
914
+ #
915
+ attr_reader :create_vpc_flow_logs_config
916
+ ##
917
+ # RPC-specific configuration for `update_vpc_flow_logs_config`
918
+ # @return [::Gapic::Config::Method]
919
+ #
920
+ attr_reader :update_vpc_flow_logs_config
921
+ ##
922
+ # RPC-specific configuration for `delete_vpc_flow_logs_config`
923
+ # @return [::Gapic::Config::Method]
924
+ #
925
+ attr_reader :delete_vpc_flow_logs_config
926
+
927
+ # @private
928
+ def initialize parent_rpcs = nil
929
+ list_vpc_flow_logs_configs_config = parent_rpcs.list_vpc_flow_logs_configs if parent_rpcs.respond_to? :list_vpc_flow_logs_configs
930
+ @list_vpc_flow_logs_configs = ::Gapic::Config::Method.new list_vpc_flow_logs_configs_config
931
+ get_vpc_flow_logs_config_config = parent_rpcs.get_vpc_flow_logs_config if parent_rpcs.respond_to? :get_vpc_flow_logs_config
932
+ @get_vpc_flow_logs_config = ::Gapic::Config::Method.new get_vpc_flow_logs_config_config
933
+ create_vpc_flow_logs_config_config = parent_rpcs.create_vpc_flow_logs_config if parent_rpcs.respond_to? :create_vpc_flow_logs_config
934
+ @create_vpc_flow_logs_config = ::Gapic::Config::Method.new create_vpc_flow_logs_config_config
935
+ update_vpc_flow_logs_config_config = parent_rpcs.update_vpc_flow_logs_config if parent_rpcs.respond_to? :update_vpc_flow_logs_config
936
+ @update_vpc_flow_logs_config = ::Gapic::Config::Method.new update_vpc_flow_logs_config_config
937
+ delete_vpc_flow_logs_config_config = parent_rpcs.delete_vpc_flow_logs_config if parent_rpcs.respond_to? :delete_vpc_flow_logs_config
938
+ @delete_vpc_flow_logs_config = ::Gapic::Config::Method.new delete_vpc_flow_logs_config_config
939
+
940
+ yield self if block_given?
941
+ end
942
+ end
943
+ end
944
+ end
945
+ end
946
+ end
947
+ end
948
+ end
949
+ end