google-cloud-asset-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +24 -0
  6. data/lib/google-cloud-asset-v1.rb +1 -0
  7. data/lib/google/cloud/asset/v1.rb +19 -0
  8. data/lib/google/cloud/asset/v1/asset_service.rb +21 -0
  9. data/lib/google/cloud/asset/v1/asset_service/client.rb +878 -0
  10. data/lib/google/cloud/asset/v1/asset_service/credentials.rb +51 -0
  11. data/lib/google/cloud/asset/v1/asset_service/helpers.rb +43 -0
  12. data/lib/google/cloud/asset/v1/asset_service/operations.rb +558 -0
  13. data/lib/google/cloud/asset/v1/asset_service/paths.rb +85 -0
  14. data/lib/google/cloud/asset/v1/asset_service_pb.rb +124 -0
  15. data/lib/google/cloud/asset/v1/asset_service_services_pb.rb +68 -0
  16. data/lib/google/cloud/asset/v1/assets_pb.rb +52 -0
  17. data/lib/google/cloud/asset/v1/version.rb +28 -0
  18. data/lib/google/cloud/common_resources_pb.rb +15 -0
  19. data/lib/google/cloud/orgpolicy/v1/orgpolicy_pb.rb +54 -0
  20. data/proto_docs/README.md +4 -0
  21. data/proto_docs/google/api/field_behavior.rb +59 -0
  22. data/proto_docs/google/api/resource.rb +247 -0
  23. data/proto_docs/google/cloud/asset/v1/asset_service.rb +347 -0
  24. data/proto_docs/google/cloud/asset/v1/assets.rb +132 -0
  25. data/proto_docs/google/cloud/orgpolicy/v1/orgpolicy.rb +307 -0
  26. data/proto_docs/google/iam/v1/policy.rb +156 -0
  27. data/proto_docs/google/longrunning/operations.rb +150 -0
  28. data/proto_docs/google/protobuf/any.rb +137 -0
  29. data/proto_docs/google/protobuf/empty.rb +36 -0
  30. data/proto_docs/google/protobuf/field_mask.rb +237 -0
  31. data/proto_docs/google/protobuf/struct.rb +96 -0
  32. data/proto_docs/google/protobuf/timestamp.rb +116 -0
  33. data/proto_docs/google/rpc/status.rb +46 -0
  34. metadata +201 -0
@@ -0,0 +1,878 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/errors"
24
+ require "google/cloud/asset/v1/version"
25
+ require "google/cloud/asset/v1/asset_service_pb"
26
+ require "google/cloud/asset/v1/asset_service/credentials"
27
+ require "google/cloud/asset/v1/asset_service/paths"
28
+ require "google/cloud/asset/v1/asset_service/operations"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Asset
33
+ module V1
34
+ module AssetService
35
+ ##
36
+ # Client for the AssetService service.
37
+ #
38
+ # Asset service definition.
39
+ #
40
+ class Client
41
+ include Paths
42
+
43
+ # @private
44
+ attr_reader :asset_service_stub
45
+
46
+ ##
47
+ # Configure the AssetService Client class.
48
+ #
49
+ # See {Google::Cloud::Asset::V1::AssetService::Client::Configuration}
50
+ # for a description of the configuration fields.
51
+ #
52
+ # ## Example
53
+ #
54
+ # To modify the configuration for all AssetService clients:
55
+ #
56
+ # Google::Cloud::Asset::V1::AssetService::Client.configure do |config|
57
+ # config.timeout = 10_000
58
+ # end
59
+ #
60
+ # @yield [config] Configure the Client client.
61
+ # @yieldparam config [Client::Configuration]
62
+ #
63
+ # @return [Client::Configuration]
64
+ #
65
+ def self.configure
66
+ @configure ||= begin
67
+ namespace = ["Google", "Cloud", "Asset", "V1"]
68
+ parent_config = while namespace.any?
69
+ parent_name = namespace.join "::"
70
+ parent_const = const_get parent_name
71
+ break parent_const.configure if parent_const&.respond_to? :configure
72
+ namespace.pop
73
+ end
74
+ default_config = Client::Configuration.new parent_config
75
+
76
+ default_config.rpcs.export_assets.timeout = 60.0
77
+
78
+ default_config.rpcs.batch_get_assets_history.timeout = 60.0
79
+ default_config.rpcs.batch_get_assets_history.retry_policy = {
80
+ initial_delay: 0.1,
81
+ max_delay: 60.0,
82
+ multiplier: 1.3,
83
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
84
+ }
85
+
86
+ default_config
87
+ end
88
+ yield @configure if block_given?
89
+ @configure
90
+ end
91
+
92
+ ##
93
+ # Configure the AssetService Client instance.
94
+ #
95
+ # The configuration is set to the derived mode, meaning that values can be changed,
96
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
97
+ # should be made on {Client.configure}.
98
+ #
99
+ # See {Google::Cloud::Asset::V1::AssetService::Client::Configuration}
100
+ # for a description of the configuration fields.
101
+ #
102
+ # @yield [config] Configure the Client client.
103
+ # @yieldparam config [Client::Configuration]
104
+ #
105
+ # @return [Client::Configuration]
106
+ #
107
+ def configure
108
+ yield @config if block_given?
109
+ @config
110
+ end
111
+
112
+ ##
113
+ # Create a new AssetService client object.
114
+ #
115
+ # ## Examples
116
+ #
117
+ # To create a new AssetService client with the default
118
+ # configuration:
119
+ #
120
+ # client = Google::Cloud::Asset::V1::AssetService::Client.new
121
+ #
122
+ # To create a new AssetService client with a custom
123
+ # configuration:
124
+ #
125
+ # client = Google::Cloud::Asset::V1::AssetService::Client.new do |config|
126
+ # config.timeout = 10_000
127
+ # end
128
+ #
129
+ # @yield [config] Configure the AssetService client.
130
+ # @yieldparam config [Client::Configuration]
131
+ #
132
+ def initialize
133
+ # These require statements are intentionally placed here to initialize
134
+ # the gRPC module only when it's required.
135
+ # See https://github.com/googleapis/toolkit/issues/446
136
+ require "gapic/grpc"
137
+ require "google/cloud/asset/v1/asset_service_services_pb"
138
+
139
+ # Create the configuration object
140
+ @config = Configuration.new Client.configure
141
+
142
+ # Yield the configuration if needed
143
+ yield @config if block_given?
144
+
145
+ # Create credentials
146
+ credentials = @config.credentials
147
+ credentials ||= Credentials.default scope: @config.scope
148
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
149
+ credentials = Credentials.new credentials, scope: @config.scope
150
+ end
151
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
152
+
153
+ @operations_client = Operations.new do |config|
154
+ config.credentials = credentials
155
+ end
156
+
157
+ @asset_service_stub = Gapic::ServiceStub.new(
158
+ Google::Cloud::Asset::V1::AssetService::Stub,
159
+ credentials: credentials,
160
+ endpoint: @config.endpoint,
161
+ channel_args: @config.channel_args,
162
+ interceptors: @config.interceptors
163
+ )
164
+ end
165
+
166
+ # Service calls
167
+
168
+ ##
169
+ # Exports assets with time and resource types to a given Cloud Storage
170
+ # location. The output format is newline-delimited JSON.
171
+ # This API implements the {Google::Longrunning::Operation google.longrunning.Operation} API allowing you
172
+ # to keep track of the export.
173
+ #
174
+ # @overload export_assets(request, options = nil)
175
+ # @param request [Google::Cloud::Asset::V1::ExportAssetsRequest | Hash]
176
+ # Exports assets with time and resource types to a given Cloud Storage
177
+ # location. The output format is newline-delimited JSON.
178
+ # This API implements the {Google::Longrunning::Operation google.longrunning.Operation} API allowing you
179
+ # to keep track of the export.
180
+ # @param options [Gapic::CallOptions, Hash]
181
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
182
+ #
183
+ # @overload export_assets(parent: nil, read_time: nil, asset_types: nil, content_type: nil, output_config: nil)
184
+ # @param parent [String]
185
+ # Required. The relative name of the root asset. This can only be an
186
+ # organization number (such as "organizations/123"), a project ID (such as
187
+ # "projects/my-project-id"), or a project number (such as "projects/12345"),
188
+ # or a folder number (such as "folders/123").
189
+ # @param read_time [Google::Protobuf::Timestamp | Hash]
190
+ # Timestamp to take an asset snapshot. This can only be set to a timestamp
191
+ # between 2018-10-02 UTC (inclusive) and the current time. If not specified,
192
+ # the current time will be used. Due to delays in resource data collection
193
+ # and indexing, there is a volatile window during which running the same
194
+ # query may get different results.
195
+ # @param asset_types [Array<String>]
196
+ # A list of asset types of which to take a snapshot for. For example:
197
+ # "compute.googleapis.com/Disk". If specified, only matching assets will be
198
+ # returned. See [Introduction to Cloud Asset
199
+ # Inventory](https://cloud.google.com/asset-inventory/docs/overview)
200
+ # for all supported asset types.
201
+ # @param content_type [Google::Cloud::Asset::V1::ContentType]
202
+ # Asset content type. If not specified, no content but the asset name will be
203
+ # returned.
204
+ # @param output_config [Google::Cloud::Asset::V1::OutputConfig | Hash]
205
+ # Required. Output configuration indicating where the results will be output
206
+ # to. All results will be in newline delimited JSON format.
207
+ #
208
+ #
209
+ # @yield [response, operation] Access the result along with the RPC operation
210
+ # @yieldparam response [Gapic::Operation]
211
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
212
+ #
213
+ # @return [Gapic::Operation]
214
+ #
215
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
216
+ #
217
+ def export_assets request, options = nil
218
+ raise ArgumentError, "request must be provided" if request.nil?
219
+
220
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Asset::V1::ExportAssetsRequest
221
+
222
+ # Converts hash and nil to an options object
223
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
224
+
225
+ # Customize the options with defaults
226
+ metadata = @config.rpcs.export_assets.metadata.to_h
227
+
228
+ # Set x-goog-api-client and x-goog-user-project headers
229
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
230
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
231
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
232
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
233
+
234
+ header_params = {
235
+ "parent" => request.parent
236
+ }
237
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
238
+ metadata[:"x-goog-request-params"] ||= request_params_header
239
+
240
+ options.apply_defaults timeout: @config.rpcs.export_assets.timeout,
241
+ metadata: metadata,
242
+ retry_policy: @config.rpcs.export_assets.retry_policy
243
+ options.apply_defaults metadata: @config.metadata,
244
+ retry_policy: @config.retry_policy
245
+
246
+ @asset_service_stub.call_rpc :export_assets, request, options: options do |response, operation|
247
+ response = Gapic::Operation.new response, @operations_client, options: options
248
+ yield response, operation if block_given?
249
+ return response
250
+ end
251
+ rescue GRPC::BadStatus => e
252
+ raise Google::Cloud::Error.from_error(e)
253
+ end
254
+
255
+ ##
256
+ # Batch gets the update history of assets that overlap a time window.
257
+ # For RESOURCE content, this API outputs history with asset in both
258
+ # non-delete or deleted status.
259
+ # For IAM_POLICY content, this API outputs history when the asset and its
260
+ # attached IAM POLICY both exist. This can create gaps in the output history.
261
+ # If a specified asset does not exist, this API returns an INVALID_ARGUMENT
262
+ # error.
263
+ #
264
+ # @overload batch_get_assets_history(request, options = nil)
265
+ # @param request [Google::Cloud::Asset::V1::BatchGetAssetsHistoryRequest | Hash]
266
+ # Batch gets the update history of assets that overlap a time window.
267
+ # For RESOURCE content, this API outputs history with asset in both
268
+ # non-delete or deleted status.
269
+ # For IAM_POLICY content, this API outputs history when the asset and its
270
+ # attached IAM POLICY both exist. This can create gaps in the output history.
271
+ # If a specified asset does not exist, this API returns an INVALID_ARGUMENT
272
+ # error.
273
+ # @param options [Gapic::CallOptions, Hash]
274
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
275
+ #
276
+ # @overload batch_get_assets_history(parent: nil, asset_names: nil, content_type: nil, read_time_window: nil)
277
+ # @param parent [String]
278
+ # Required. The relative name of the root asset. It can only be an
279
+ # organization number (such as "organizations/123"), a project ID (such as
280
+ # "projects/my-project-id")", or a project number (such as "projects/12345").
281
+ # @param asset_names [Array<String>]
282
+ # A list of the full names of the assets. For example:
283
+ # `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`.
284
+ # See [Resource
285
+ # Names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
286
+ # and [Resource Name
287
+ # Format](https://cloud.google.com/asset-inventory/docs/resource-name-format)
288
+ # for more info.
289
+ #
290
+ # The request becomes a no-op if the asset name list is empty, and the max
291
+ # size of the asset name list is 100 in one request.
292
+ # @param content_type [Google::Cloud::Asset::V1::ContentType]
293
+ # Optional. The content type.
294
+ # @param read_time_window [Google::Cloud::Asset::V1::TimeWindow | Hash]
295
+ # Optional. The time window for the asset history. Both start_time and
296
+ # end_time are optional and if set, it must be after 2018-10-02 UTC. If
297
+ # end_time is not set, it is default to current timestamp. If start_time is
298
+ # not set, the snapshot of the assets at end_time will be returned. The
299
+ # returned results contain all temporal assets whose time window overlap with
300
+ # read_time_window.
301
+ #
302
+ #
303
+ # @yield [response, operation] Access the result along with the RPC operation
304
+ # @yieldparam response [Google::Cloud::Asset::V1::BatchGetAssetsHistoryResponse]
305
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
306
+ #
307
+ # @return [Google::Cloud::Asset::V1::BatchGetAssetsHistoryResponse]
308
+ #
309
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
310
+ #
311
+ def batch_get_assets_history request, options = nil
312
+ raise ArgumentError, "request must be provided" if request.nil?
313
+
314
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Asset::V1::BatchGetAssetsHistoryRequest
315
+
316
+ # Converts hash and nil to an options object
317
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
318
+
319
+ # Customize the options with defaults
320
+ metadata = @config.rpcs.batch_get_assets_history.metadata.to_h
321
+
322
+ # Set x-goog-api-client and x-goog-user-project headers
323
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
324
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
325
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
326
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
327
+
328
+ header_params = {
329
+ "parent" => request.parent
330
+ }
331
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
332
+ metadata[:"x-goog-request-params"] ||= request_params_header
333
+
334
+ options.apply_defaults timeout: @config.rpcs.batch_get_assets_history.timeout,
335
+ metadata: metadata,
336
+ retry_policy: @config.rpcs.batch_get_assets_history.retry_policy
337
+ options.apply_defaults metadata: @config.metadata,
338
+ retry_policy: @config.retry_policy
339
+
340
+ @asset_service_stub.call_rpc :batch_get_assets_history, request, options: options do |response, operation|
341
+ yield response, operation if block_given?
342
+ return response
343
+ end
344
+ rescue GRPC::BadStatus => e
345
+ raise Google::Cloud::Error.from_error(e)
346
+ end
347
+
348
+ ##
349
+ # Creates a feed in a parent project/folder/organization to listen to its
350
+ # asset updates.
351
+ #
352
+ # @overload create_feed(request, options = nil)
353
+ # @param request [Google::Cloud::Asset::V1::CreateFeedRequest | Hash]
354
+ # Creates a feed in a parent project/folder/organization to listen to its
355
+ # asset updates.
356
+ # @param options [Gapic::CallOptions, Hash]
357
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
358
+ #
359
+ # @overload create_feed(parent: nil, feed_id: nil, feed: nil)
360
+ # @param parent [String]
361
+ # Required. The name of the project/folder/organization where this feed
362
+ # should be created in. It can only be an organization number (such as
363
+ # "organizations/123"), a folder number (such as "folders/123"), a project ID
364
+ # (such as "projects/my-project-id")", or a project number (such as
365
+ # "projects/12345").
366
+ # @param feed_id [String]
367
+ # Required. This is the client-assigned asset feed identifier and it needs to
368
+ # be unique under a specific parent project/folder/organization.
369
+ # @param feed [Google::Cloud::Asset::V1::Feed | Hash]
370
+ # Required. The feed details. The field `name` must be empty and it will be generated
371
+ # in the format of:
372
+ # projects/project_number/feeds/feed_id
373
+ # folders/folder_number/feeds/feed_id
374
+ # organizations/organization_number/feeds/feed_id
375
+ #
376
+ #
377
+ # @yield [response, operation] Access the result along with the RPC operation
378
+ # @yieldparam response [Google::Cloud::Asset::V1::Feed]
379
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
380
+ #
381
+ # @return [Google::Cloud::Asset::V1::Feed]
382
+ #
383
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
384
+ #
385
+ def create_feed request, options = nil
386
+ raise ArgumentError, "request must be provided" if request.nil?
387
+
388
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Asset::V1::CreateFeedRequest
389
+
390
+ # Converts hash and nil to an options object
391
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
392
+
393
+ # Customize the options with defaults
394
+ metadata = @config.rpcs.create_feed.metadata.to_h
395
+
396
+ # Set x-goog-api-client and x-goog-user-project headers
397
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
398
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
399
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
400
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
401
+
402
+ header_params = {
403
+ "parent" => request.parent
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.create_feed.timeout,
409
+ metadata: metadata,
410
+ retry_policy: @config.rpcs.create_feed.retry_policy
411
+ options.apply_defaults metadata: @config.metadata,
412
+ retry_policy: @config.retry_policy
413
+
414
+ @asset_service_stub.call_rpc :create_feed, request, options: options do |response, operation|
415
+ yield response, operation if block_given?
416
+ return response
417
+ end
418
+ rescue GRPC::BadStatus => e
419
+ raise Google::Cloud::Error.from_error(e)
420
+ end
421
+
422
+ ##
423
+ # Gets details about an asset feed.
424
+ #
425
+ # @overload get_feed(request, options = nil)
426
+ # @param request [Google::Cloud::Asset::V1::GetFeedRequest | Hash]
427
+ # Gets details about an asset feed.
428
+ # @param options [Gapic::CallOptions, Hash]
429
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
430
+ #
431
+ # @overload get_feed(name: nil)
432
+ # @param name [String]
433
+ # Required. The name of the Feed and it must be in the format of:
434
+ # projects/project_number/feeds/feed_id
435
+ # folders/folder_number/feeds/feed_id
436
+ # organizations/organization_number/feeds/feed_id
437
+ #
438
+ #
439
+ # @yield [response, operation] Access the result along with the RPC operation
440
+ # @yieldparam response [Google::Cloud::Asset::V1::Feed]
441
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
442
+ #
443
+ # @return [Google::Cloud::Asset::V1::Feed]
444
+ #
445
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
446
+ #
447
+ def get_feed request, options = nil
448
+ raise ArgumentError, "request must be provided" if request.nil?
449
+
450
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Asset::V1::GetFeedRequest
451
+
452
+ # Converts hash and nil to an options object
453
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
454
+
455
+ # Customize the options with defaults
456
+ metadata = @config.rpcs.get_feed.metadata.to_h
457
+
458
+ # Set x-goog-api-client and x-goog-user-project headers
459
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
460
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
461
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
462
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
463
+
464
+ header_params = {
465
+ "name" => request.name
466
+ }
467
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
468
+ metadata[:"x-goog-request-params"] ||= request_params_header
469
+
470
+ options.apply_defaults timeout: @config.rpcs.get_feed.timeout,
471
+ metadata: metadata,
472
+ retry_policy: @config.rpcs.get_feed.retry_policy
473
+ options.apply_defaults metadata: @config.metadata,
474
+ retry_policy: @config.retry_policy
475
+
476
+ @asset_service_stub.call_rpc :get_feed, request, options: options do |response, operation|
477
+ yield response, operation if block_given?
478
+ return response
479
+ end
480
+ rescue GRPC::BadStatus => e
481
+ raise Google::Cloud::Error.from_error(e)
482
+ end
483
+
484
+ ##
485
+ # Lists all asset feeds in a parent project/folder/organization.
486
+ #
487
+ # @overload list_feeds(request, options = nil)
488
+ # @param request [Google::Cloud::Asset::V1::ListFeedsRequest | Hash]
489
+ # Lists all asset feeds in a parent project/folder/organization.
490
+ # @param options [Gapic::CallOptions, Hash]
491
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
492
+ #
493
+ # @overload list_feeds(parent: nil)
494
+ # @param parent [String]
495
+ # Required. The parent project/folder/organization whose feeds are to be
496
+ # listed. It can only be using project/folder/organization number (such as
497
+ # "folders/12345")", or a project ID (such as "projects/my-project-id").
498
+ #
499
+ #
500
+ # @yield [response, operation] Access the result along with the RPC operation
501
+ # @yieldparam response [Google::Cloud::Asset::V1::ListFeedsResponse]
502
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
503
+ #
504
+ # @return [Google::Cloud::Asset::V1::ListFeedsResponse]
505
+ #
506
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
507
+ #
508
+ def list_feeds request, options = nil
509
+ raise ArgumentError, "request must be provided" if request.nil?
510
+
511
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Asset::V1::ListFeedsRequest
512
+
513
+ # Converts hash and nil to an options object
514
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
515
+
516
+ # Customize the options with defaults
517
+ metadata = @config.rpcs.list_feeds.metadata.to_h
518
+
519
+ # Set x-goog-api-client and x-goog-user-project headers
520
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
521
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
522
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
523
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
524
+
525
+ header_params = {
526
+ "parent" => request.parent
527
+ }
528
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
529
+ metadata[:"x-goog-request-params"] ||= request_params_header
530
+
531
+ options.apply_defaults timeout: @config.rpcs.list_feeds.timeout,
532
+ metadata: metadata,
533
+ retry_policy: @config.rpcs.list_feeds.retry_policy
534
+ options.apply_defaults metadata: @config.metadata,
535
+ retry_policy: @config.retry_policy
536
+
537
+ @asset_service_stub.call_rpc :list_feeds, request, options: options do |response, operation|
538
+ yield response, operation if block_given?
539
+ return response
540
+ end
541
+ rescue GRPC::BadStatus => e
542
+ raise Google::Cloud::Error.from_error(e)
543
+ end
544
+
545
+ ##
546
+ # Updates an asset feed configuration.
547
+ #
548
+ # @overload update_feed(request, options = nil)
549
+ # @param request [Google::Cloud::Asset::V1::UpdateFeedRequest | Hash]
550
+ # Updates an asset feed configuration.
551
+ # @param options [Gapic::CallOptions, Hash]
552
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
553
+ #
554
+ # @overload update_feed(feed: nil, update_mask: nil)
555
+ # @param feed [Google::Cloud::Asset::V1::Feed | Hash]
556
+ # Required. The new values of feed details. It must match an existing feed and the
557
+ # field `name` must be in the format of:
558
+ # projects/project_number/feeds/feed_id or
559
+ # folders/folder_number/feeds/feed_id or
560
+ # organizations/organization_number/feeds/feed_id.
561
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
562
+ # Required. Only updates the `feed` fields indicated by this mask.
563
+ # The field mask must not be empty, and it must not contain fields that
564
+ # are immutable or only set by the server.
565
+ #
566
+ #
567
+ # @yield [response, operation] Access the result along with the RPC operation
568
+ # @yieldparam response [Google::Cloud::Asset::V1::Feed]
569
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
570
+ #
571
+ # @return [Google::Cloud::Asset::V1::Feed]
572
+ #
573
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
574
+ #
575
+ def update_feed request, options = nil
576
+ raise ArgumentError, "request must be provided" if request.nil?
577
+
578
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Asset::V1::UpdateFeedRequest
579
+
580
+ # Converts hash and nil to an options object
581
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
582
+
583
+ # Customize the options with defaults
584
+ metadata = @config.rpcs.update_feed.metadata.to_h
585
+
586
+ # Set x-goog-api-client and x-goog-user-project headers
587
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
588
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
589
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
590
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
591
+
592
+ header_params = {
593
+ "feed.name" => request.feed.name
594
+ }
595
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
596
+ metadata[:"x-goog-request-params"] ||= request_params_header
597
+
598
+ options.apply_defaults timeout: @config.rpcs.update_feed.timeout,
599
+ metadata: metadata,
600
+ retry_policy: @config.rpcs.update_feed.retry_policy
601
+ options.apply_defaults metadata: @config.metadata,
602
+ retry_policy: @config.retry_policy
603
+
604
+ @asset_service_stub.call_rpc :update_feed, request, options: options do |response, operation|
605
+ yield response, operation if block_given?
606
+ return response
607
+ end
608
+ rescue GRPC::BadStatus => e
609
+ raise Google::Cloud::Error.from_error(e)
610
+ end
611
+
612
+ ##
613
+ # Deletes an asset feed.
614
+ #
615
+ # @overload delete_feed(request, options = nil)
616
+ # @param request [Google::Cloud::Asset::V1::DeleteFeedRequest | Hash]
617
+ # Deletes an asset feed.
618
+ # @param options [Gapic::CallOptions, Hash]
619
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
620
+ #
621
+ # @overload delete_feed(name: nil)
622
+ # @param name [String]
623
+ # Required. The name of the feed and it must be in the format of:
624
+ # projects/project_number/feeds/feed_id
625
+ # folders/folder_number/feeds/feed_id
626
+ # organizations/organization_number/feeds/feed_id
627
+ #
628
+ #
629
+ # @yield [response, operation] Access the result along with the RPC operation
630
+ # @yieldparam response [Google::Protobuf::Empty]
631
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
632
+ #
633
+ # @return [Google::Protobuf::Empty]
634
+ #
635
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
636
+ #
637
+ def delete_feed request, options = nil
638
+ raise ArgumentError, "request must be provided" if request.nil?
639
+
640
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Asset::V1::DeleteFeedRequest
641
+
642
+ # Converts hash and nil to an options object
643
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
644
+
645
+ # Customize the options with defaults
646
+ metadata = @config.rpcs.delete_feed.metadata.to_h
647
+
648
+ # Set x-goog-api-client and x-goog-user-project headers
649
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
650
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
651
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
652
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
653
+
654
+ header_params = {
655
+ "name" => request.name
656
+ }
657
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
658
+ metadata[:"x-goog-request-params"] ||= request_params_header
659
+
660
+ options.apply_defaults timeout: @config.rpcs.delete_feed.timeout,
661
+ metadata: metadata,
662
+ retry_policy: @config.rpcs.delete_feed.retry_policy
663
+ options.apply_defaults metadata: @config.metadata,
664
+ retry_policy: @config.retry_policy
665
+
666
+ @asset_service_stub.call_rpc :delete_feed, request, options: options do |response, operation|
667
+ yield response, operation if block_given?
668
+ return response
669
+ end
670
+ rescue GRPC::BadStatus => e
671
+ raise Google::Cloud::Error.from_error(e)
672
+ end
673
+
674
+ ##
675
+ # Configuration class for the AssetService API.
676
+ #
677
+ # This class represents the configuration for AssetService,
678
+ # providing control over timeouts, retry behavior, logging, transport
679
+ # parameters, and other low-level controls. Certain parameters can also be
680
+ # applied individually to specific RPCs. See
681
+ # {Google::Cloud::Asset::V1::AssetService::Client::Configuration::Rpcs}
682
+ # for a list of RPCs that can be configured independently.
683
+ #
684
+ # Configuration can be applied globally to all clients, or to a single client
685
+ # on construction.
686
+ #
687
+ # # Examples
688
+ #
689
+ # To modify the global config, setting the timeout for export_assets
690
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
691
+ #
692
+ # Google::Cloud::Asset::V1::AssetService::Client.configure do |config|
693
+ # config.timeout = 10_000
694
+ # config.rpcs.export_assets.timeout = 20_000
695
+ # end
696
+ #
697
+ # To apply the above configuration only to a new client:
698
+ #
699
+ # client = Google::Cloud::Asset::V1::AssetService::Client.new do |config|
700
+ # config.timeout = 10_000
701
+ # config.rpcs.export_assets.timeout = 20_000
702
+ # end
703
+ #
704
+ # @!attribute [rw] endpoint
705
+ # The hostname or hostname:port of the service endpoint.
706
+ # Defaults to `"cloudasset.googleapis.com"`.
707
+ # @return [String]
708
+ # @!attribute [rw] credentials
709
+ # Credentials to send with calls. You may provide any of the following types:
710
+ # * (`String`) The path to a service account key file in JSON format
711
+ # * (`Hash`) A service account key as a Hash
712
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
713
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
714
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
715
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
716
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
717
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
718
+ # * (`nil`) indicating no credentials
719
+ # @return [Object]
720
+ # @!attribute [rw] scope
721
+ # The OAuth scopes
722
+ # @return [Array<String>]
723
+ # @!attribute [rw] lib_name
724
+ # The library name as recorded in instrumentation and logging
725
+ # @return [String]
726
+ # @!attribute [rw] lib_version
727
+ # The library version as recorded in instrumentation and logging
728
+ # @return [String]
729
+ # @!attribute [rw] channel_args
730
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
731
+ # `GRPC::Core::Channel` object is provided as the credential.
732
+ # @return [Hash]
733
+ # @!attribute [rw] interceptors
734
+ # An array of interceptors that are run before calls are executed.
735
+ # @return [Array<GRPC::ClientInterceptor>]
736
+ # @!attribute [rw] timeout
737
+ # The call timeout in milliseconds.
738
+ # @return [Numeric]
739
+ # @!attribute [rw] metadata
740
+ # Additional gRPC headers to be sent with the call.
741
+ # @return [Hash{Symbol=>String}]
742
+ # @!attribute [rw] retry_policy
743
+ # The retry policy. The value is a hash with the following keys:
744
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
745
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
746
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
747
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
748
+ # trigger a retry.
749
+ # @return [Hash]
750
+ #
751
+ class Configuration
752
+ extend Gapic::Config
753
+
754
+ config_attr :endpoint, "cloudasset.googleapis.com", String
755
+ config_attr :credentials, nil do |value|
756
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
757
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
758
+ allowed.any? { |klass| klass === value }
759
+ end
760
+ config_attr :scope, nil, String, Array, nil
761
+ config_attr :lib_name, nil, String, nil
762
+ config_attr :lib_version, nil, String, nil
763
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
764
+ config_attr :interceptors, nil, Array, nil
765
+ config_attr :timeout, nil, Numeric, nil
766
+ config_attr :metadata, nil, Hash, nil
767
+ config_attr :retry_policy, nil, Hash, Proc, nil
768
+
769
+ # @private
770
+ def initialize parent_config = nil
771
+ @parent_config = parent_config unless parent_config.nil?
772
+
773
+ yield self if block_given?
774
+ end
775
+
776
+ ##
777
+ # Configurations for individual RPCs
778
+ # @return [Rpcs]
779
+ #
780
+ def rpcs
781
+ @rpcs ||= begin
782
+ parent_rpcs = nil
783
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
784
+ Rpcs.new parent_rpcs
785
+ end
786
+ end
787
+
788
+ ##
789
+ # Configuration RPC class for the AssetService API.
790
+ #
791
+ # Includes fields providing the configuration for each RPC in this service.
792
+ # Each configuration object is of type `Gapic::Config::Method` and includes
793
+ # the following configuration fields:
794
+ #
795
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
796
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
797
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
798
+ # include the following keys:
799
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
800
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
801
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
802
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
803
+ # trigger a retry.
804
+ #
805
+ class Rpcs
806
+ ##
807
+ # RPC-specific configuration for `export_assets`
808
+ # @return [Gapic::Config::Method]
809
+ #
810
+ attr_reader :export_assets
811
+ ##
812
+ # RPC-specific configuration for `batch_get_assets_history`
813
+ # @return [Gapic::Config::Method]
814
+ #
815
+ attr_reader :batch_get_assets_history
816
+ ##
817
+ # RPC-specific configuration for `create_feed`
818
+ # @return [Gapic::Config::Method]
819
+ #
820
+ attr_reader :create_feed
821
+ ##
822
+ # RPC-specific configuration for `get_feed`
823
+ # @return [Gapic::Config::Method]
824
+ #
825
+ attr_reader :get_feed
826
+ ##
827
+ # RPC-specific configuration for `list_feeds`
828
+ # @return [Gapic::Config::Method]
829
+ #
830
+ attr_reader :list_feeds
831
+ ##
832
+ # RPC-specific configuration for `update_feed`
833
+ # @return [Gapic::Config::Method]
834
+ #
835
+ attr_reader :update_feed
836
+ ##
837
+ # RPC-specific configuration for `delete_feed`
838
+ # @return [Gapic::Config::Method]
839
+ #
840
+ attr_reader :delete_feed
841
+
842
+ # @private
843
+ def initialize parent_rpcs = nil
844
+ export_assets_config = parent_rpcs&.export_assets if parent_rpcs&.respond_to? :export_assets
845
+ @export_assets = Gapic::Config::Method.new export_assets_config
846
+ batch_get_assets_history_config = parent_rpcs&.batch_get_assets_history if parent_rpcs&.respond_to? :batch_get_assets_history
847
+ @batch_get_assets_history = Gapic::Config::Method.new batch_get_assets_history_config
848
+ create_feed_config = parent_rpcs&.create_feed if parent_rpcs&.respond_to? :create_feed
849
+ @create_feed = Gapic::Config::Method.new create_feed_config
850
+ get_feed_config = parent_rpcs&.get_feed if parent_rpcs&.respond_to? :get_feed
851
+ @get_feed = Gapic::Config::Method.new get_feed_config
852
+ list_feeds_config = parent_rpcs&.list_feeds if parent_rpcs&.respond_to? :list_feeds
853
+ @list_feeds = Gapic::Config::Method.new list_feeds_config
854
+ update_feed_config = parent_rpcs&.update_feed if parent_rpcs&.respond_to? :update_feed
855
+ @update_feed = Gapic::Config::Method.new update_feed_config
856
+ delete_feed_config = parent_rpcs&.delete_feed if parent_rpcs&.respond_to? :delete_feed
857
+ @delete_feed = Gapic::Config::Method.new delete_feed_config
858
+
859
+ yield self if block_given?
860
+ end
861
+ end
862
+ end
863
+ end
864
+ end
865
+ end
866
+ end
867
+ end
868
+ end
869
+
870
+ # rubocop:disable Lint/HandleExceptions
871
+
872
+ # Once client is loaded, load helpers.rb if it exists.
873
+ begin
874
+ require "google/cloud/asset/v1/asset_service/helpers"
875
+ rescue LoadError
876
+ end
877
+
878
+ # rubocop:enable Lint/HandleExceptions