google-cloud-security_center-v1 0.32.0 → 0.34.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,6 +32,9 @@ module Google
32
32
  # V1 APIs for Security Center service.
33
33
  #
34
34
  class Client
35
+ # @private
36
+ DEFAULT_ENDPOINT_TEMPLATE = "securitycenter.$UNIVERSE_DOMAIN$"
37
+
35
38
  include Paths
36
39
 
37
40
  # @private
@@ -202,6 +205,15 @@ module Google
202
205
  @config
203
206
  end
204
207
 
208
+ ##
209
+ # The effective universe domain
210
+ #
211
+ # @return [String]
212
+ #
213
+ def universe_domain
214
+ @security_center_stub.universe_domain
215
+ end
216
+
205
217
  ##
206
218
  # Create a new SecurityCenter REST client object.
207
219
  #
@@ -229,8 +241,9 @@ module Google
229
241
  credentials = @config.credentials
230
242
  # Use self-signed JWT if the endpoint is unchanged from default,
231
243
  # but only if the default endpoint does not have a region prefix.
232
- enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
233
- !@config.endpoint.split(".").first.include?("-")
244
+ enable_self_signed_jwt = @config.endpoint.nil? ||
245
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
246
+ !@config.endpoint.split(".").first.include?("-"))
234
247
  credentials ||= Credentials.default scope: @config.scope,
235
248
  enable_self_signed_jwt: enable_self_signed_jwt
236
249
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
@@ -244,9 +257,15 @@ module Google
244
257
  config.credentials = credentials
245
258
  config.quota_project = @quota_project_id
246
259
  config.endpoint = @config.endpoint
260
+ config.universe_domain = @config.universe_domain
247
261
  end
248
262
 
249
- @security_center_stub = ::Google::Cloud::SecurityCenter::V1::SecurityCenter::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
263
+ @security_center_stub = ::Google::Cloud::SecurityCenter::V1::SecurityCenter::Rest::ServiceStub.new(
264
+ endpoint: @config.endpoint,
265
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
266
+ universe_domain: @config.universe_domain,
267
+ credentials: credentials
268
+ )
250
269
  end
251
270
 
252
271
  ##
@@ -3550,6 +3569,92 @@ module Google
3550
3569
  raise ::Google::Cloud::Error.from_error(e)
3551
3570
  end
3552
3571
 
3572
+ ##
3573
+ # Simulates a given SecurityHealthAnalyticsCustomModule and Resource.
3574
+ #
3575
+ # @overload simulate_security_health_analytics_custom_module(request, options = nil)
3576
+ # Pass arguments to `simulate_security_health_analytics_custom_module` via a request object, either of type
3577
+ # {::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleRequest} or an equivalent Hash.
3578
+ #
3579
+ # @param request [::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleRequest, ::Hash]
3580
+ # A request object representing the call parameters. Required. To specify no
3581
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
3582
+ # @param options [::Gapic::CallOptions, ::Hash]
3583
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
3584
+ #
3585
+ # @overload simulate_security_health_analytics_custom_module(parent: nil, custom_config: nil, resource: nil)
3586
+ # Pass arguments to `simulate_security_health_analytics_custom_module` via keyword arguments. Note that at
3587
+ # least one keyword argument is required. To specify no parameters, or to keep all
3588
+ # the default parameter values, pass an empty Hash as a request object (see above).
3589
+ #
3590
+ # @param parent [::String]
3591
+ # Required. The relative resource name of the organization, project, or
3592
+ # folder. For more information about relative resource names, see [Relative
3593
+ # Resource
3594
+ # Name](https://cloud.google.com/apis/design/resource_names#relative_resource_name)
3595
+ # Example: `organizations/{organization_id}`
3596
+ # @param custom_config [::Google::Cloud::SecurityCenter::V1::CustomConfig, ::Hash]
3597
+ # Required. The custom configuration that you need to test.
3598
+ # @param resource [::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleRequest::SimulatedResource, ::Hash]
3599
+ # Required. Resource data to simulate custom module against.
3600
+ # @yield [result, operation] Access the result along with the TransportOperation object
3601
+ # @yieldparam result [::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleResponse]
3602
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
3603
+ #
3604
+ # @return [::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleResponse]
3605
+ #
3606
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
3607
+ #
3608
+ # @example Basic example
3609
+ # require "google/cloud/security_center/v1"
3610
+ #
3611
+ # # Create a client object. The client can be reused for multiple calls.
3612
+ # client = Google::Cloud::SecurityCenter::V1::SecurityCenter::Rest::Client.new
3613
+ #
3614
+ # # Create a request. To set request fields, pass in keyword arguments.
3615
+ # request = Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleRequest.new
3616
+ #
3617
+ # # Call the simulate_security_health_analytics_custom_module method.
3618
+ # result = client.simulate_security_health_analytics_custom_module request
3619
+ #
3620
+ # # The returned object is of type Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleResponse.
3621
+ # p result
3622
+ #
3623
+ def simulate_security_health_analytics_custom_module request, options = nil
3624
+ raise ::ArgumentError, "request must be provided" if request.nil?
3625
+
3626
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleRequest
3627
+
3628
+ # Converts hash and nil to an options object
3629
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
3630
+
3631
+ # Customize the options with defaults
3632
+ call_metadata = @config.rpcs.simulate_security_health_analytics_custom_module.metadata.to_h
3633
+
3634
+ # Set x-goog-api-client and x-goog-user-project headers
3635
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
3636
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
3637
+ gapic_version: ::Google::Cloud::SecurityCenter::V1::VERSION,
3638
+ transports_version_send: [:rest]
3639
+
3640
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
3641
+
3642
+ options.apply_defaults timeout: @config.rpcs.simulate_security_health_analytics_custom_module.timeout,
3643
+ metadata: call_metadata,
3644
+ retry_policy: @config.rpcs.simulate_security_health_analytics_custom_module.retry_policy
3645
+
3646
+ options.apply_defaults timeout: @config.timeout,
3647
+ metadata: @config.metadata,
3648
+ retry_policy: @config.retry_policy
3649
+
3650
+ @security_center_stub.simulate_security_health_analytics_custom_module request, options do |result, operation|
3651
+ yield result, operation if block_given?
3652
+ return result
3653
+ end
3654
+ rescue ::Gapic::Rest::Error => e
3655
+ raise ::Google::Cloud::Error.from_error(e)
3656
+ end
3657
+
3553
3658
  ##
3554
3659
  # Updates external system. This is for a given finding.
3555
3660
  #
@@ -4603,9 +4708,9 @@ module Google
4603
4708
  # end
4604
4709
  #
4605
4710
  # @!attribute [rw] endpoint
4606
- # The hostname or hostname:port of the service endpoint.
4607
- # Defaults to `"securitycenter.googleapis.com"`.
4608
- # @return [::String]
4711
+ # A custom service endpoint, as a hostname or hostname:port. The default is
4712
+ # nil, indicating to use the default endpoint in the current universe domain.
4713
+ # @return [::String,nil]
4609
4714
  # @!attribute [rw] credentials
4610
4715
  # Credentials to send with calls. You may provide any of the following types:
4611
4716
  # * (`String`) The path to a service account key file in JSON format
@@ -4642,13 +4747,20 @@ module Google
4642
4747
  # @!attribute [rw] quota_project
4643
4748
  # A separate project against which to charge quota.
4644
4749
  # @return [::String]
4750
+ # @!attribute [rw] universe_domain
4751
+ # The universe domain within which to make requests. This determines the
4752
+ # default endpoint URL. The default value of nil uses the environment
4753
+ # universe (usually the default "googleapis.com" universe).
4754
+ # @return [::String,nil]
4645
4755
  #
4646
4756
  class Configuration
4647
4757
  extend ::Gapic::Config
4648
4758
 
4759
+ # @private
4760
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
4649
4761
  DEFAULT_ENDPOINT = "securitycenter.googleapis.com"
4650
4762
 
4651
- config_attr :endpoint, DEFAULT_ENDPOINT, ::String
4763
+ config_attr :endpoint, nil, ::String, nil
4652
4764
  config_attr :credentials, nil do |value|
4653
4765
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
4654
4766
  allowed.any? { |klass| klass === value }
@@ -4660,6 +4772,7 @@ module Google
4660
4772
  config_attr :metadata, nil, ::Hash, nil
4661
4773
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
4662
4774
  config_attr :quota_project, nil, ::String, nil
4775
+ config_attr :universe_domain, nil, ::String, nil
4663
4776
 
4664
4777
  # @private
4665
4778
  def initialize parent_config = nil
@@ -4859,6 +4972,11 @@ module Google
4859
4972
  #
4860
4973
  attr_reader :test_iam_permissions
4861
4974
  ##
4975
+ # RPC-specific configuration for `simulate_security_health_analytics_custom_module`
4976
+ # @return [::Gapic::Config::Method]
4977
+ #
4978
+ attr_reader :simulate_security_health_analytics_custom_module
4979
+ ##
4862
4980
  # RPC-specific configuration for `update_external_system`
4863
4981
  # @return [::Gapic::Config::Method]
4864
4982
  #
@@ -4985,6 +5103,8 @@ module Google
4985
5103
  @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
4986
5104
  test_iam_permissions_config = parent_rpcs.test_iam_permissions if parent_rpcs.respond_to? :test_iam_permissions
4987
5105
  @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config
5106
+ simulate_security_health_analytics_custom_module_config = parent_rpcs.simulate_security_health_analytics_custom_module if parent_rpcs.respond_to? :simulate_security_health_analytics_custom_module
5107
+ @simulate_security_health_analytics_custom_module = ::Gapic::Config::Method.new simulate_security_health_analytics_custom_module_config
4988
5108
  update_external_system_config = parent_rpcs.update_external_system if parent_rpcs.respond_to? :update_external_system
4989
5109
  @update_external_system = ::Gapic::Config::Method.new update_external_system_config
4990
5110
  update_finding_config = parent_rpcs.update_finding if parent_rpcs.respond_to? :update_finding
@@ -26,6 +26,9 @@ module Google
26
26
  module Rest
27
27
  # Service that implements Longrunning Operations API.
28
28
  class Operations
29
+ # @private
30
+ DEFAULT_ENDPOINT_TEMPLATE = "securitycenter.$UNIVERSE_DOMAIN$"
31
+
29
32
  # @private
30
33
  attr_reader :operations_stub
31
34
 
@@ -60,6 +63,15 @@ module Google
60
63
  @config
61
64
  end
62
65
 
66
+ ##
67
+ # The effective universe domain
68
+ #
69
+ # @return [String]
70
+ #
71
+ def universe_domain
72
+ @operations_stub.universe_domain
73
+ end
74
+
63
75
  ##
64
76
  # Create a new Operations client object.
65
77
  #
@@ -84,8 +96,10 @@ module Google
84
96
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
85
97
 
86
98
  @operations_stub = OperationsServiceStub.new(
87
- endpoint: @config.endpoint,
88
- credentials: credentials
99
+ endpoint: @config.endpoint,
100
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
101
+ universe_domain: @config.universe_domain,
102
+ credentials: credentials
89
103
  )
90
104
 
91
105
  # Used by an LRO wrapper for some methods of this service
@@ -478,9 +492,9 @@ module Google
478
492
  # end
479
493
  #
480
494
  # @!attribute [rw] endpoint
481
- # The hostname or hostname:port of the service endpoint.
482
- # Defaults to `"securitycenter.googleapis.com"`.
483
- # @return [::String]
495
+ # A custom service endpoint, as a hostname or hostname:port. The default is
496
+ # nil, indicating to use the default endpoint in the current universe domain.
497
+ # @return [::String,nil]
484
498
  # @!attribute [rw] credentials
485
499
  # Credentials to send with calls. You may provide any of the following types:
486
500
  # * (`String`) The path to a service account key file in JSON format
@@ -517,13 +531,20 @@ module Google
517
531
  # @!attribute [rw] quota_project
518
532
  # A separate project against which to charge quota.
519
533
  # @return [::String]
534
+ # @!attribute [rw] universe_domain
535
+ # The universe domain within which to make requests. This determines the
536
+ # default endpoint URL. The default value of nil uses the environment
537
+ # universe (usually the default "googleapis.com" universe).
538
+ # @return [::String,nil]
520
539
  #
521
540
  class Configuration
522
541
  extend ::Gapic::Config
523
542
 
543
+ # @private
544
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
524
545
  DEFAULT_ENDPOINT = "securitycenter.googleapis.com"
525
546
 
526
- config_attr :endpoint, DEFAULT_ENDPOINT, ::String
547
+ config_attr :endpoint, nil, ::String, nil
527
548
  config_attr :credentials, nil do |value|
528
549
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
529
550
  allowed.any? { |klass| klass === value }
@@ -535,6 +556,7 @@ module Google
535
556
  config_attr :metadata, nil, ::Hash, nil
536
557
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
537
558
  config_attr :quota_project, nil, ::String, nil
559
+ config_attr :universe_domain, nil, ::String, nil
538
560
 
539
561
  # @private
540
562
  def initialize parent_config = nil
@@ -617,12 +639,15 @@ module Google
617
639
  # Service stub contains baseline method implementations
618
640
  # including transcoding, making the REST call, and deserialing the response.
619
641
  class OperationsServiceStub
620
- def initialize endpoint:, credentials:
642
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
621
643
  # These require statements are intentionally placed here to initialize
622
644
  # the REST modules only when it's required.
623
645
  require "gapic/rest"
624
646
 
625
- @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials
647
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
648
+ endpoint_template: endpoint_template,
649
+ universe_domain: universe_domain,
650
+ credentials: credentials
626
651
  end
627
652
 
628
653
  ##
@@ -30,16 +30,28 @@ module Google
30
30
  # including transcoding, making the REST call, and deserialing the response.
31
31
  #
32
32
  class ServiceStub
33
- def initialize endpoint:, credentials:
33
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
34
34
  # These require statements are intentionally placed here to initialize
35
35
  # the REST modules only when it's required.
36
36
  require "gapic/rest"
37
37
 
38
- @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
39
+ endpoint_template: endpoint_template,
40
+ universe_domain: universe_domain,
41
+ credentials: credentials,
39
42
  numeric_enums: true,
40
43
  raise_faraday_errors: false
41
44
  end
42
45
 
46
+ ##
47
+ # The effective universe domain
48
+ #
49
+ # @return [String]
50
+ #
51
+ def universe_domain
52
+ @client_stub.universe_domain
53
+ end
54
+
43
55
  ##
44
56
  # Baseline implementation for the bulk_mute_findings REST call
45
57
  #
@@ -1256,6 +1268,44 @@ module Google
1256
1268
  result
1257
1269
  end
1258
1270
 
1271
+ ##
1272
+ # Baseline implementation for the simulate_security_health_analytics_custom_module REST call
1273
+ #
1274
+ # @param request_pb [::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleRequest]
1275
+ # A request object representing the call parameters. Required.
1276
+ # @param options [::Gapic::CallOptions]
1277
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1278
+ #
1279
+ # @yield [result, operation] Access the result along with the TransportOperation object
1280
+ # @yieldparam result [::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleResponse]
1281
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1282
+ #
1283
+ # @return [::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleResponse]
1284
+ # A result object deserialized from the server's reply
1285
+ def simulate_security_health_analytics_custom_module request_pb, options = nil
1286
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
1287
+
1288
+ verb, uri, query_string_params, body = ServiceStub.transcode_simulate_security_health_analytics_custom_module_request request_pb
1289
+ query_string_params = if query_string_params.any?
1290
+ query_string_params.to_h { |p| p.split "=", 2 }
1291
+ else
1292
+ {}
1293
+ end
1294
+
1295
+ response = @client_stub.make_http_request(
1296
+ verb,
1297
+ uri: uri,
1298
+ body: body || "",
1299
+ params: query_string_params,
1300
+ options: options
1301
+ )
1302
+ operation = ::Gapic::Rest::TransportOperation.new response
1303
+ result = ::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleResponse.decode_json response.body, ignore_unknown_fields: true
1304
+
1305
+ yield result, operation if block_given?
1306
+ result
1307
+ end
1308
+
1259
1309
  ##
1260
1310
  # Baseline implementation for the update_external_system REST call
1261
1311
  #
@@ -2750,6 +2800,44 @@ module Google
2750
2800
  transcoder.transcode request_pb
2751
2801
  end
2752
2802
 
2803
+ ##
2804
+ # @private
2805
+ #
2806
+ # GRPC transcoding helper method for the simulate_security_health_analytics_custom_module REST call
2807
+ #
2808
+ # @param request_pb [::Google::Cloud::SecurityCenter::V1::SimulateSecurityHealthAnalyticsCustomModuleRequest]
2809
+ # A request object representing the call parameters. Required.
2810
+ # @return [Array(String, [String, nil], Hash{String => String})]
2811
+ # Uri, Body, Query string parameters
2812
+ def self.transcode_simulate_security_health_analytics_custom_module_request request_pb
2813
+ transcoder = Gapic::Rest::GrpcTranscoder.new
2814
+ .with_bindings(
2815
+ uri_method: :post,
2816
+ uri_template: "/v1/{parent}/customModules:simulate",
2817
+ body: "*",
2818
+ matches: [
2819
+ ["parent", %r{^organizations/[^/]+/securityHealthAnalyticsSettings/?$}, false]
2820
+ ]
2821
+ )
2822
+ .with_bindings(
2823
+ uri_method: :post,
2824
+ uri_template: "/v1/{parent}/customModules:simulate",
2825
+ body: "*",
2826
+ matches: [
2827
+ ["parent", %r{^folders/[^/]+/securityHealthAnalyticsSettings/?$}, false]
2828
+ ]
2829
+ )
2830
+ .with_bindings(
2831
+ uri_method: :post,
2832
+ uri_template: "/v1/{parent}/customModules:simulate",
2833
+ body: "*",
2834
+ matches: [
2835
+ ["parent", %r{^projects/[^/]+/securityHealthAnalyticsSettings/?$}, false]
2836
+ ]
2837
+ )
2838
+ transcoder.transcode request_pb
2839
+ end
2840
+
2753
2841
  ##
2754
2842
  # @private
2755
2843
  #
@@ -21,7 +21,7 @@ module Google
21
21
  module Cloud
22
22
  module SecurityCenter
23
23
  module V1
24
- VERSION = "0.32.0"
24
+ VERSION = "0.34.0"
25
25
  end
26
26
  end
27
27
  end