google-cloud-security_center-v1p1beta1 0.14.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -236,8 +236,19 @@ module Google
236
236
  endpoint: @config.endpoint,
237
237
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
238
238
  universe_domain: @config.universe_domain,
239
- credentials: credentials
239
+ credentials: credentials,
240
+ logger: @config.logger
240
241
  )
242
+
243
+ @security_center_stub.logger(stub: true)&.info do |entry|
244
+ entry.set_system_name
245
+ entry.set_service
246
+ entry.message = "Created client for #{entry.service}"
247
+ entry.set_credentials_fields credentials
248
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
249
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
250
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
251
+ end
241
252
  end
242
253
 
243
254
  ##
@@ -247,6 +258,15 @@ module Google
247
258
  #
248
259
  attr_reader :operations_client
249
260
 
261
+ ##
262
+ # The logger used for request/response debug logging.
263
+ #
264
+ # @return [Logger]
265
+ #
266
+ def logger
267
+ @security_center_stub.logger
268
+ end
269
+
250
270
  # Service calls
251
271
 
252
272
  ##
@@ -326,7 +346,6 @@ module Google
326
346
 
327
347
  @security_center_stub.create_source request, options do |result, operation|
328
348
  yield result, operation if block_given?
329
- return result
330
349
  end
331
350
  rescue ::Gapic::Rest::Error => e
332
351
  raise ::Google::Cloud::Error.from_error(e)
@@ -412,7 +431,6 @@ module Google
412
431
 
413
432
  @security_center_stub.create_finding request, options do |result, operation|
414
433
  yield result, operation if block_given?
415
- return result
416
434
  end
417
435
  rescue ::Gapic::Rest::Error => e
418
436
  raise ::Google::Cloud::Error.from_error(e)
@@ -499,7 +517,6 @@ module Google
499
517
 
500
518
  @security_center_stub.create_notification_config request, options do |result, operation|
501
519
  yield result, operation if block_given?
502
- return result
503
520
  end
504
521
  rescue ::Gapic::Rest::Error => e
505
522
  raise ::Google::Cloud::Error.from_error(e)
@@ -579,7 +596,6 @@ module Google
579
596
 
580
597
  @security_center_stub.delete_notification_config request, options do |result, operation|
581
598
  yield result, operation if block_given?
582
- return result
583
599
  end
584
600
  rescue ::Gapic::Rest::Error => e
585
601
  raise ::Google::Cloud::Error.from_error(e)
@@ -662,7 +678,6 @@ module Google
662
678
 
663
679
  @security_center_stub.get_iam_policy request, options do |result, operation|
664
680
  yield result, operation if block_given?
665
- return result
666
681
  end
667
682
  rescue ::Gapic::Rest::Error => e
668
683
  raise ::Google::Cloud::Error.from_error(e)
@@ -742,7 +757,6 @@ module Google
742
757
 
743
758
  @security_center_stub.get_notification_config request, options do |result, operation|
744
759
  yield result, operation if block_given?
745
- return result
746
760
  end
747
761
  rescue ::Gapic::Rest::Error => e
748
762
  raise ::Google::Cloud::Error.from_error(e)
@@ -822,7 +836,6 @@ module Google
822
836
 
823
837
  @security_center_stub.get_organization_settings request, options do |result, operation|
824
838
  yield result, operation if block_given?
825
- return result
826
839
  end
827
840
  rescue ::Gapic::Rest::Error => e
828
841
  raise ::Google::Cloud::Error.from_error(e)
@@ -902,7 +915,6 @@ module Google
902
915
 
903
916
  @security_center_stub.get_source request, options do |result, operation|
904
917
  yield result, operation if block_given?
905
- return result
906
918
  end
907
919
  rescue ::Gapic::Rest::Error => e
908
920
  raise ::Google::Cloud::Error.from_error(e)
@@ -1111,7 +1123,7 @@ module Google
1111
1123
  @security_center_stub.group_assets request, options do |result, operation|
1112
1124
  result = ::Gapic::Rest::PagedEnumerable.new @security_center_stub, :group_assets, "group_by_results", request, result, options
1113
1125
  yield result, operation if block_given?
1114
- return result
1126
+ throw :response, result
1115
1127
  end
1116
1128
  rescue ::Gapic::Rest::Error => e
1117
1129
  raise ::Google::Cloud::Error.from_error(e)
@@ -1319,7 +1331,7 @@ module Google
1319
1331
  @security_center_stub.group_findings request, options do |result, operation|
1320
1332
  result = ::Gapic::Rest::PagedEnumerable.new @security_center_stub, :group_findings, "group_by_results", request, result, options
1321
1333
  yield result, operation if block_given?
1322
- return result
1334
+ throw :response, result
1323
1335
  end
1324
1336
  rescue ::Gapic::Rest::Error => e
1325
1337
  raise ::Google::Cloud::Error.from_error(e)
@@ -1531,7 +1543,7 @@ module Google
1531
1543
  @security_center_stub.list_assets request, options do |result, operation|
1532
1544
  result = ::Gapic::Rest::PagedEnumerable.new @security_center_stub, :list_assets, "list_assets_results", request, result, options
1533
1545
  yield result, operation if block_given?
1534
- return result
1546
+ throw :response, result
1535
1547
  end
1536
1548
  rescue ::Gapic::Rest::Error => e
1537
1549
  raise ::Google::Cloud::Error.from_error(e)
@@ -1740,7 +1752,7 @@ module Google
1740
1752
  @security_center_stub.list_findings request, options do |result, operation|
1741
1753
  result = ::Gapic::Rest::PagedEnumerable.new @security_center_stub, :list_findings, "list_findings_results", request, result, options
1742
1754
  yield result, operation if block_given?
1743
- return result
1755
+ throw :response, result
1744
1756
  end
1745
1757
  rescue ::Gapic::Rest::Error => e
1746
1758
  raise ::Google::Cloud::Error.from_error(e)
@@ -1832,7 +1844,7 @@ module Google
1832
1844
  @security_center_stub.list_notification_configs request, options do |result, operation|
1833
1845
  result = ::Gapic::Rest::PagedEnumerable.new @security_center_stub, :list_notification_configs, "notification_configs", request, result, options
1834
1846
  yield result, operation if block_given?
1835
- return result
1847
+ throw :response, result
1836
1848
  end
1837
1849
  rescue ::Gapic::Rest::Error => e
1838
1850
  raise ::Google::Cloud::Error.from_error(e)
@@ -1925,7 +1937,7 @@ module Google
1925
1937
  @security_center_stub.list_sources request, options do |result, operation|
1926
1938
  result = ::Gapic::Rest::PagedEnumerable.new @security_center_stub, :list_sources, "sources", request, result, options
1927
1939
  yield result, operation if block_given?
1928
- return result
1940
+ throw :response, result
1929
1941
  end
1930
1942
  rescue ::Gapic::Rest::Error => e
1931
1943
  raise ::Google::Cloud::Error.from_error(e)
@@ -2018,7 +2030,7 @@ module Google
2018
2030
  @security_center_stub.run_asset_discovery request, options do |result, operation|
2019
2031
  result = ::Gapic::Operation.new result, @operations_client, options: options
2020
2032
  yield result, operation if block_given?
2021
- return result
2033
+ throw :response, result
2022
2034
  end
2023
2035
  rescue ::Gapic::Rest::Error => e
2024
2036
  raise ::Google::Cloud::Error.from_error(e)
@@ -2104,7 +2116,6 @@ module Google
2104
2116
 
2105
2117
  @security_center_stub.set_finding_state request, options do |result, operation|
2106
2118
  yield result, operation if block_given?
2107
- return result
2108
2119
  end
2109
2120
  rescue ::Gapic::Rest::Error => e
2110
2121
  raise ::Google::Cloud::Error.from_error(e)
@@ -2195,7 +2206,6 @@ module Google
2195
2206
 
2196
2207
  @security_center_stub.set_iam_policy request, options do |result, operation|
2197
2208
  yield result, operation if block_given?
2198
- return result
2199
2209
  end
2200
2210
  rescue ::Gapic::Rest::Error => e
2201
2211
  raise ::Google::Cloud::Error.from_error(e)
@@ -2280,7 +2290,6 @@ module Google
2280
2290
 
2281
2291
  @security_center_stub.test_iam_permissions request, options do |result, operation|
2282
2292
  yield result, operation if block_given?
2283
- return result
2284
2293
  end
2285
2294
  rescue ::Gapic::Rest::Error => e
2286
2295
  raise ::Google::Cloud::Error.from_error(e)
@@ -2373,7 +2382,6 @@ module Google
2373
2382
 
2374
2383
  @security_center_stub.update_finding request, options do |result, operation|
2375
2384
  yield result, operation if block_given?
2376
- return result
2377
2385
  end
2378
2386
  rescue ::Gapic::Rest::Error => e
2379
2387
  raise ::Google::Cloud::Error.from_error(e)
@@ -2457,7 +2465,6 @@ module Google
2457
2465
 
2458
2466
  @security_center_stub.update_notification_config request, options do |result, operation|
2459
2467
  yield result, operation if block_given?
2460
- return result
2461
2468
  end
2462
2469
  rescue ::Gapic::Rest::Error => e
2463
2470
  raise ::Google::Cloud::Error.from_error(e)
@@ -2540,7 +2547,6 @@ module Google
2540
2547
 
2541
2548
  @security_center_stub.update_organization_settings request, options do |result, operation|
2542
2549
  yield result, operation if block_given?
2543
- return result
2544
2550
  end
2545
2551
  rescue ::Gapic::Rest::Error => e
2546
2552
  raise ::Google::Cloud::Error.from_error(e)
@@ -2623,7 +2629,6 @@ module Google
2623
2629
 
2624
2630
  @security_center_stub.update_source request, options do |result, operation|
2625
2631
  yield result, operation if block_given?
2626
- return result
2627
2632
  end
2628
2633
  rescue ::Gapic::Rest::Error => e
2629
2634
  raise ::Google::Cloud::Error.from_error(e)
@@ -2712,7 +2717,6 @@ module Google
2712
2717
 
2713
2718
  @security_center_stub.update_security_marks request, options do |result, operation|
2714
2719
  yield result, operation if block_given?
2715
- return result
2716
2720
  end
2717
2721
  rescue ::Gapic::Rest::Error => e
2718
2722
  raise ::Google::Cloud::Error.from_error(e)
@@ -2760,6 +2764,13 @@ module Google
2760
2764
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
2761
2765
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
2762
2766
  # * (`nil`) indicating no credentials
2767
+ #
2768
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
2769
+ # external source for authentication to Google Cloud, you must validate it before
2770
+ # providing it to a Google API client library. Providing an unvalidated credential
2771
+ # configuration to Google APIs can compromise the security of your systems and data.
2772
+ # For more information, refer to [Validate credential configurations from external
2773
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
2763
2774
  # @return [::Object]
2764
2775
  # @!attribute [rw] scope
2765
2776
  # The OAuth scopes
@@ -2792,6 +2803,11 @@ module Google
2792
2803
  # default endpoint URL. The default value of nil uses the environment
2793
2804
  # universe (usually the default "googleapis.com" universe).
2794
2805
  # @return [::String,nil]
2806
+ # @!attribute [rw] logger
2807
+ # A custom logger to use for request/response debug logging, or the value
2808
+ # `:default` (the default) to construct a default logger, or `nil` to
2809
+ # explicitly disable logging.
2810
+ # @return [::Logger,:default,nil]
2795
2811
  #
2796
2812
  class Configuration
2797
2813
  extend ::Gapic::Config
@@ -2813,6 +2829,7 @@ module Google
2813
2829
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2814
2830
  config_attr :quota_project, nil, ::String, nil
2815
2831
  config_attr :universe_domain, nil, ::String, nil
2832
+ config_attr :logger, :default, ::Logger, nil, :default
2816
2833
 
2817
2834
  # @private
2818
2835
  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
  ##