google-cloud-asset-v1 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -249,8 +249,19 @@ module Google
249
249
  endpoint: @config.endpoint,
250
250
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
251
251
  universe_domain: @config.universe_domain,
252
- credentials: credentials
252
+ credentials: credentials,
253
+ logger: @config.logger
253
254
  )
255
+
256
+ @asset_service_stub.logger(stub: true)&.info do |entry|
257
+ entry.set_system_name
258
+ entry.set_service
259
+ entry.message = "Created client for #{entry.service}"
260
+ entry.set_credentials_fields credentials
261
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
262
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
263
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
264
+ end
254
265
  end
255
266
 
256
267
  ##
@@ -260,6 +271,15 @@ module Google
260
271
  #
261
272
  attr_reader :operations_client
262
273
 
274
+ ##
275
+ # The logger used for request/response debug logging.
276
+ #
277
+ # @return [Logger]
278
+ #
279
+ def logger
280
+ @asset_service_stub.logger
281
+ end
282
+
263
283
  # Service calls
264
284
 
265
285
  ##
@@ -403,7 +423,7 @@ module Google
403
423
  @asset_service_stub.export_assets request, options do |result, operation|
404
424
  result = ::Gapic::Operation.new result, @operations_client, options: options
405
425
  yield result, operation if block_given?
406
- return result
426
+ throw :response, result
407
427
  end
408
428
  rescue ::Gapic::Rest::Error => e
409
429
  raise ::Google::Cloud::Error.from_error(e)
@@ -543,7 +563,7 @@ module Google
543
563
  @asset_service_stub.list_assets request, options do |result, operation|
544
564
  result = ::Gapic::Rest::PagedEnumerable.new @asset_service_stub, :list_assets, "assets", request, result, options
545
565
  yield result, operation if block_given?
546
- return result
566
+ throw :response, result
547
567
  end
548
568
  rescue ::Gapic::Rest::Error => e
549
569
  raise ::Google::Cloud::Error.from_error(e)
@@ -665,7 +685,6 @@ module Google
665
685
 
666
686
  @asset_service_stub.batch_get_assets_history request, options do |result, operation|
667
687
  yield result, operation if block_given?
668
- return result
669
688
  end
670
689
  rescue ::Gapic::Rest::Error => e
671
690
  raise ::Google::Cloud::Error.from_error(e)
@@ -757,7 +776,6 @@ module Google
757
776
 
758
777
  @asset_service_stub.create_feed request, options do |result, operation|
759
778
  yield result, operation if block_given?
760
- return result
761
779
  end
762
780
  rescue ::Gapic::Rest::Error => e
763
781
  raise ::Google::Cloud::Error.from_error(e)
@@ -839,7 +857,6 @@ module Google
839
857
 
840
858
  @asset_service_stub.get_feed request, options do |result, operation|
841
859
  yield result, operation if block_given?
842
- return result
843
860
  end
844
861
  rescue ::Gapic::Rest::Error => e
845
862
  raise ::Google::Cloud::Error.from_error(e)
@@ -920,7 +937,6 @@ module Google
920
937
 
921
938
  @asset_service_stub.list_feeds request, options do |result, operation|
922
939
  yield result, operation if block_given?
923
- return result
924
940
  end
925
941
  rescue ::Gapic::Rest::Error => e
926
942
  raise ::Google::Cloud::Error.from_error(e)
@@ -1007,7 +1023,6 @@ module Google
1007
1023
 
1008
1024
  @asset_service_stub.update_feed request, options do |result, operation|
1009
1025
  yield result, operation if block_given?
1010
- return result
1011
1026
  end
1012
1027
  rescue ::Gapic::Rest::Error => e
1013
1028
  raise ::Google::Cloud::Error.from_error(e)
@@ -1089,7 +1104,6 @@ module Google
1089
1104
 
1090
1105
  @asset_service_stub.delete_feed request, options do |result, operation|
1091
1106
  yield result, operation if block_given?
1092
- return result
1093
1107
  end
1094
1108
  rescue ::Gapic::Rest::Error => e
1095
1109
  raise ::Google::Cloud::Error.from_error(e)
@@ -1344,7 +1358,7 @@ module Google
1344
1358
  @asset_service_stub.search_all_resources request, options do |result, operation|
1345
1359
  result = ::Gapic::Rest::PagedEnumerable.new @asset_service_stub, :search_all_resources, "results", request, result, options
1346
1360
  yield result, operation if block_given?
1347
- return result
1361
+ throw :response, result
1348
1362
  end
1349
1363
  rescue ::Gapic::Rest::Error => e
1350
1364
  raise ::Google::Cloud::Error.from_error(e)
@@ -1525,7 +1539,7 @@ module Google
1525
1539
  @asset_service_stub.search_all_iam_policies request, options do |result, operation|
1526
1540
  result = ::Gapic::Rest::PagedEnumerable.new @asset_service_stub, :search_all_iam_policies, "results", request, result, options
1527
1541
  yield result, operation if block_given?
1528
- return result
1542
+ throw :response, result
1529
1543
  end
1530
1544
  rescue ::Gapic::Rest::Error => e
1531
1545
  raise ::Google::Cloud::Error.from_error(e)
@@ -1634,7 +1648,6 @@ module Google
1634
1648
 
1635
1649
  @asset_service_stub.analyze_iam_policy request, options do |result, operation|
1636
1650
  yield result, operation if block_given?
1637
- return result
1638
1651
  end
1639
1652
  rescue ::Gapic::Rest::Error => e
1640
1653
  raise ::Google::Cloud::Error.from_error(e)
@@ -1750,7 +1763,7 @@ module Google
1750
1763
  @asset_service_stub.analyze_iam_policy_longrunning request, options do |result, operation|
1751
1764
  result = ::Gapic::Operation.new result, @operations_client, options: options
1752
1765
  yield result, operation if block_given?
1753
- return result
1766
+ throw :response, result
1754
1767
  end
1755
1768
  rescue ::Gapic::Rest::Error => e
1756
1769
  raise ::Google::Cloud::Error.from_error(e)
@@ -1845,7 +1858,6 @@ module Google
1845
1858
 
1846
1859
  @asset_service_stub.analyze_move request, options do |result, operation|
1847
1860
  yield result, operation if block_given?
1848
- return result
1849
1861
  end
1850
1862
  rescue ::Gapic::Rest::Error => e
1851
1863
  raise ::Google::Cloud::Error.from_error(e)
@@ -1890,9 +1902,13 @@ module Google
1890
1902
  # @param statement [::String]
1891
1903
  # Optional. A SQL statement that's compatible with [BigQuery
1892
1904
  # SQL](https://cloud.google.com/bigquery/docs/introduction-sql).
1905
+ #
1906
+ # Note: The following fields are mutually exclusive: `statement`, `job_reference`. If a field in that set is populated, all other fields in the set will automatically be cleared.
1893
1907
  # @param job_reference [::String]
1894
1908
  # Optional. Reference to the query job, which is from the
1895
1909
  # `QueryAssetsResponse` of previous `QueryAssets` call.
1910
+ #
1911
+ # Note: The following fields are mutually exclusive: `job_reference`, `statement`. If a field in that set is populated, all other fields in the set will automatically be cleared.
1896
1912
  # @param page_size [::Integer]
1897
1913
  # Optional. The maximum number of rows to return in the results. Responses
1898
1914
  # are limited to 10 MB and 1000 rows.
@@ -1923,9 +1939,13 @@ module Google
1923
1939
  # Optional. [start_time] is required. [start_time] must be less than
1924
1940
  # [end_time] Defaults [end_time] to now if [start_time] is set and
1925
1941
  # [end_time] isn't. Maximum permitted time range is 7 days.
1942
+ #
1943
+ # Note: The following fields are mutually exclusive: `read_time_window`, `read_time`. If a field in that set is populated, all other fields in the set will automatically be cleared.
1926
1944
  # @param read_time [::Google::Protobuf::Timestamp, ::Hash]
1927
1945
  # Optional. Queries cloud assets as they appeared at the specified point in
1928
1946
  # time.
1947
+ #
1948
+ # Note: The following fields are mutually exclusive: `read_time`, `read_time_window`. If a field in that set is populated, all other fields in the set will automatically be cleared.
1929
1949
  # @param output_config [::Google::Cloud::Asset::V1::QueryAssetsOutputConfig, ::Hash]
1930
1950
  # Optional. Destination where the query results will be saved.
1931
1951
  #
@@ -1989,7 +2009,6 @@ module Google
1989
2009
 
1990
2010
  @asset_service_stub.query_assets request, options do |result, operation|
1991
2011
  yield result, operation if block_given?
1992
- return result
1993
2012
  end
1994
2013
  rescue ::Gapic::Rest::Error => e
1995
2014
  raise ::Google::Cloud::Error.from_error(e)
@@ -2085,7 +2104,6 @@ module Google
2085
2104
 
2086
2105
  @asset_service_stub.create_saved_query request, options do |result, operation|
2087
2106
  yield result, operation if block_given?
2088
- return result
2089
2107
  end
2090
2108
  rescue ::Gapic::Rest::Error => e
2091
2109
  raise ::Google::Cloud::Error.from_error(e)
@@ -2168,7 +2186,6 @@ module Google
2168
2186
 
2169
2187
  @asset_service_stub.get_saved_query request, options do |result, operation|
2170
2188
  yield result, operation if block_given?
2171
- return result
2172
2189
  end
2173
2190
  rescue ::Gapic::Rest::Error => e
2174
2191
  raise ::Google::Cloud::Error.from_error(e)
@@ -2273,7 +2290,7 @@ module Google
2273
2290
  @asset_service_stub.list_saved_queries request, options do |result, operation|
2274
2291
  result = ::Gapic::Rest::PagedEnumerable.new @asset_service_stub, :list_saved_queries, "saved_queries", request, result, options
2275
2292
  yield result, operation if block_given?
2276
- return result
2293
+ throw :response, result
2277
2294
  end
2278
2295
  rescue ::Gapic::Rest::Error => e
2279
2296
  raise ::Google::Cloud::Error.from_error(e)
@@ -2361,7 +2378,6 @@ module Google
2361
2378
 
2362
2379
  @asset_service_stub.update_saved_query request, options do |result, operation|
2363
2380
  yield result, operation if block_given?
2364
- return result
2365
2381
  end
2366
2382
  rescue ::Gapic::Rest::Error => e
2367
2383
  raise ::Google::Cloud::Error.from_error(e)
@@ -2445,7 +2461,6 @@ module Google
2445
2461
 
2446
2462
  @asset_service_stub.delete_saved_query request, options do |result, operation|
2447
2463
  yield result, operation if block_given?
2448
- return result
2449
2464
  end
2450
2465
  rescue ::Gapic::Rest::Error => e
2451
2466
  raise ::Google::Cloud::Error.from_error(e)
@@ -2540,7 +2555,6 @@ module Google
2540
2555
 
2541
2556
  @asset_service_stub.batch_get_effective_iam_policies request, options do |result, operation|
2542
2557
  yield result, operation if block_given?
2543
- return result
2544
2558
  end
2545
2559
  rescue ::Gapic::Rest::Error => e
2546
2560
  raise ::Google::Cloud::Error.from_error(e)
@@ -2649,7 +2663,7 @@ module Google
2649
2663
  @asset_service_stub.analyze_org_policies request, options do |result, operation|
2650
2664
  result = ::Gapic::Rest::PagedEnumerable.new @asset_service_stub, :analyze_org_policies, "org_policy_results", request, result, options
2651
2665
  yield result, operation if block_given?
2652
- return result
2666
+ throw :response, result
2653
2667
  end
2654
2668
  rescue ::Gapic::Rest::Error => e
2655
2669
  raise ::Google::Cloud::Error.from_error(e)
@@ -2761,7 +2775,7 @@ module Google
2761
2775
  @asset_service_stub.analyze_org_policy_governed_containers request, options do |result, operation|
2762
2776
  result = ::Gapic::Rest::PagedEnumerable.new @asset_service_stub, :analyze_org_policy_governed_containers, "governed_containers", request, result, options
2763
2777
  yield result, operation if block_given?
2764
- return result
2778
+ throw :response, result
2765
2779
  end
2766
2780
  rescue ::Gapic::Rest::Error => e
2767
2781
  raise ::Google::Cloud::Error.from_error(e)
@@ -2936,7 +2950,7 @@ module Google
2936
2950
  @asset_service_stub.analyze_org_policy_governed_assets request, options do |result, operation|
2937
2951
  result = ::Gapic::Rest::PagedEnumerable.new @asset_service_stub, :analyze_org_policy_governed_assets, "governed_assets", request, result, options
2938
2952
  yield result, operation if block_given?
2939
- return result
2953
+ throw :response, result
2940
2954
  end
2941
2955
  rescue ::Gapic::Rest::Error => e
2942
2956
  raise ::Google::Cloud::Error.from_error(e)
@@ -2984,6 +2998,13 @@ module Google
2984
2998
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
2985
2999
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
2986
3000
  # * (`nil`) indicating no credentials
3001
+ #
3002
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
3003
+ # external source for authentication to Google Cloud, you must validate it before
3004
+ # providing it to a Google API client library. Providing an unvalidated credential
3005
+ # configuration to Google APIs can compromise the security of your systems and data.
3006
+ # For more information, refer to [Validate credential configurations from external
3007
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
2987
3008
  # @return [::Object]
2988
3009
  # @!attribute [rw] scope
2989
3010
  # The OAuth scopes
@@ -3016,6 +3037,11 @@ module Google
3016
3037
  # default endpoint URL. The default value of nil uses the environment
3017
3038
  # universe (usually the default "googleapis.com" universe).
3018
3039
  # @return [::String,nil]
3040
+ # @!attribute [rw] logger
3041
+ # A custom logger to use for request/response debug logging, or the value
3042
+ # `:default` (the default) to construct a default logger, or `nil` to
3043
+ # explicitly disable logging.
3044
+ # @return [::Logger,:default,nil]
3019
3045
  #
3020
3046
  class Configuration
3021
3047
  extend ::Gapic::Config
@@ -3037,6 +3063,7 @@ module Google
3037
3063
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
3038
3064
  config_attr :quota_project, nil, ::String, nil
3039
3065
  config_attr :universe_domain, nil, ::String, nil
3066
+ config_attr :logger, :default, ::Logger, nil, :default
3040
3067
 
3041
3068
  # @private
3042
3069
  def initialize parent_config = nil
@@ -115,14 +115,6 @@ module Google
115
115
  # Lists operations that match the specified filter in the request. If the
116
116
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
117
117
  #
118
- # NOTE: the `name` binding allows API services to override the binding
119
- # to use different resource name schemes, such as `users/*/operations`. To
120
- # override the binding, API services can add a binding such as
121
- # `"/v1/{name=users/*}/operations"` to their service configuration.
122
- # For backwards compatibility, the default name includes the operations
123
- # collection id, however overriding users must ensure the name binding
124
- # is the parent resource, without the operations collection id.
125
- #
126
118
  # @overload list_operations(request, options = nil)
127
119
  # Pass arguments to `list_operations` via a request object, either of type
128
120
  # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
@@ -204,7 +196,7 @@ module Google
204
196
  @operations_stub.list_operations request, options do |result, operation|
205
197
  result = ::Gapic::Rest::PagedEnumerable.new @operations_stub, :list_operations, "operations", request, result, options
206
198
  yield result, operation if block_given?
207
- return result
199
+ throw :response, result
208
200
  end
209
201
  rescue ::Gapic::Rest::Error => e
210
202
  raise ::Google::Cloud::Error.from_error(e)
@@ -293,7 +285,7 @@ module Google
293
285
  @operations_stub.get_operation request, options do |result, operation|
294
286
  result = ::Gapic::Operation.new result, @operations_client, options: options
295
287
  yield result, operation if block_given?
296
- return result
288
+ throw :response, result
297
289
  end
298
290
  rescue ::Gapic::Rest::Error => e
299
291
  raise ::Google::Cloud::Error.from_error(e)
@@ -375,7 +367,6 @@ module Google
375
367
 
376
368
  @operations_stub.delete_operation request, options do |result, operation|
377
369
  yield result, operation if block_given?
378
- return result
379
370
  end
380
371
  rescue ::Gapic::Rest::Error => e
381
372
  raise ::Google::Cloud::Error.from_error(e)
@@ -390,8 +381,9 @@ module Google
390
381
  # other methods to check whether the cancellation succeeded or whether the
391
382
  # operation completed despite cancellation. On successful cancellation,
392
383
  # the operation is not deleted; instead, it becomes an operation with
393
- # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
394
- # corresponding to `Code.CANCELLED`.
384
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a
385
+ # {::Google::Rpc::Status#code google.rpc.Status.code} of `1`, corresponding to
386
+ # `Code.CANCELLED`.
395
387
  #
396
388
  # @overload cancel_operation(request, options = nil)
397
389
  # Pass arguments to `cancel_operation` via a request object, either of type
@@ -463,7 +455,6 @@ module Google
463
455
 
464
456
  @operations_stub.cancel_operation request, options do |result, operation|
465
457
  yield result, operation if block_given?
466
- return result
467
458
  end
468
459
  rescue ::Gapic::Rest::Error => e
469
460
  raise ::Google::Cloud::Error.from_error(e)
@@ -511,6 +502,13 @@ module Google
511
502
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
512
503
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
513
504
  # * (`nil`) indicating no credentials
505
+ #
506
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
507
+ # external source for authentication to Google Cloud, you must validate it before
508
+ # providing it to a Google API client library. Providing an unvalidated credential
509
+ # configuration to Google APIs can compromise the security of your systems and data.
510
+ # For more information, refer to [Validate credential configurations from external
511
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
514
512
  # @return [::Object]
515
513
  # @!attribute [rw] scope
516
514
  # The OAuth scopes
@@ -543,6 +541,11 @@ module Google
543
541
  # default endpoint URL. The default value of nil uses the environment
544
542
  # universe (usually the default "googleapis.com" universe).
545
543
  # @return [::String,nil]
544
+ # @!attribute [rw] logger
545
+ # A custom logger to use for request/response debug logging, or the value
546
+ # `:default` (the default) to construct a default logger, or `nil` to
547
+ # explicitly disable logging.
548
+ # @return [::Logger,:default,nil]
546
549
  #
547
550
  class Configuration
548
551
  extend ::Gapic::Config
@@ -564,6 +567,7 @@ module Google
564
567
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
565
568
  config_attr :quota_project, nil, ::String, nil
566
569
  config_attr :universe_domain, nil, ::String, nil
570
+ config_attr :logger, :default, ::Logger, nil, :default
567
571
 
568
572
  # @private
569
573
  def initialize parent_config = nil
@@ -683,16 +687,18 @@ module Google
683
687
 
684
688
  response = @client_stub.make_http_request(
685
689
  verb,
686
- uri: uri,
687
- body: body || "",
688
- params: query_string_params,
690
+ uri: uri,
691
+ body: body || "",
692
+ params: query_string_params,
693
+ method_name: "list_operations",
689
694
  options: options
690
695
  )
691
696
  operation = ::Gapic::Rest::TransportOperation.new response
692
697
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
693
-
694
- yield result, operation if block_given?
695
- result
698
+ catch :response do
699
+ yield result, operation if block_given?
700
+ result
701
+ end
696
702
  end
697
703
 
698
704
  ##
@@ -721,16 +727,18 @@ module Google
721
727
 
722
728
  response = @client_stub.make_http_request(
723
729
  verb,
724
- uri: uri,
725
- body: body || "",
726
- params: query_string_params,
730
+ uri: uri,
731
+ body: body || "",
732
+ params: query_string_params,
733
+ method_name: "get_operation",
727
734
  options: options
728
735
  )
729
736
  operation = ::Gapic::Rest::TransportOperation.new response
730
737
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
731
-
732
- yield result, operation if block_given?
733
- result
738
+ catch :response do
739
+ yield result, operation if block_given?
740
+ result
741
+ end
734
742
  end
735
743
 
736
744
  ##
@@ -759,16 +767,18 @@ module Google
759
767
 
760
768
  response = @client_stub.make_http_request(
761
769
  verb,
762
- uri: uri,
763
- body: body || "",
764
- params: query_string_params,
770
+ uri: uri,
771
+ body: body || "",
772
+ params: query_string_params,
773
+ method_name: "delete_operation",
765
774
  options: options
766
775
  )
767
776
  operation = ::Gapic::Rest::TransportOperation.new response
768
777
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
769
-
770
- yield result, operation if block_given?
771
- result
778
+ catch :response do
779
+ yield result, operation if block_given?
780
+ result
781
+ end
772
782
  end
773
783
 
774
784
  ##
@@ -797,16 +807,18 @@ module Google
797
807
 
798
808
  response = @client_stub.make_http_request(
799
809
  verb,
800
- uri: uri,
801
- body: body || "",
802
- params: query_string_params,
810
+ uri: uri,
811
+ body: body || "",
812
+ params: query_string_params,
813
+ method_name: "cancel_operation",
803
814
  options: options
804
815
  )
805
816
  operation = ::Gapic::Rest::TransportOperation.new response
806
817
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
807
-
808
- yield result, operation if block_given?
809
- result
818
+ catch :response do
819
+ yield result, operation if block_given?
820
+ result
821
+ end
810
822
  end
811
823
 
812
824
  ##