google-cloud-security_center 1.7.1 → 2.0.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.
- checksums.yaml +4 -4
- data/.yardopts +0 -1
- data/README.md +31 -9
- data/lib/google/cloud/security_center/version.rb +1 -1
- data/lib/google/cloud/security_center.rb +41 -5
- metadata +12 -48
- data/MIGRATING.md +0 -327
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d83c6a1a67c993c37e82363e6e309043eade2eb64d5a0c4f9bed9b78aa08b2f9
|
4
|
+
data.tar.gz: fa33f7fd1022cd49f034398b18e8de004f614518adfa32541a90728da4cd6019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '083c78f9edd15d19203ed585585dde6f3769231baf97ec2649da6bd834abd052e02509216949439dd010bae129fe91321da4cc7e29dc6d7f53cbd82a7b229ca1'
|
7
|
+
data.tar.gz: 3a935e97abcf50fb18f29f589ee73b44640698974f393090691bbe2986bf444cc6672a40e0633b9c35f590724903e97e73bf5d20c20df49c3db5434ba931d18a
|
data/.yardopts
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,6 @@ constructing client objects. Reference documentation for the client objects
|
|
17
17
|
themselves can be found in the client library documentation for the versioned
|
18
18
|
client gems:
|
19
19
|
[google-cloud-security_center-v1](https://cloud.google.com/ruby/docs/reference/google-cloud-security_center-v1/latest),
|
20
|
-
[google-cloud-security_center-v1p1beta1](https://cloud.google.com/ruby/docs/reference/google-cloud-security_center-v1p1beta1/latest),
|
21
20
|
[google-cloud-security_center-v2](https://cloud.google.com/ruby/docs/reference/google-cloud-security_center-v2/latest).
|
22
21
|
|
23
22
|
See also the [Product Documentation](https://cloud.google.com/security-command-center)
|
@@ -36,17 +35,40 @@ In order to use this library, you first need to go through the following steps:
|
|
36
35
|
1. [Enable the API.](https://console.cloud.google.com/apis/library/securitycenter.googleapis.com)
|
37
36
|
1. {file:AUTHENTICATION.md Set up authentication.}
|
38
37
|
|
39
|
-
##
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
## Debug Logging
|
39
|
+
|
40
|
+
This library comes with opt-in Debug Logging that can help you troubleshoot
|
41
|
+
your application's integration with the API. When logging is activated, key
|
42
|
+
events such as requests and responses, along with data payloads and metadata
|
43
|
+
such as headers and client configuration, are logged to the standard error
|
44
|
+
stream.
|
45
|
+
|
46
|
+
**WARNING:** Client Library Debug Logging includes your data payloads in
|
47
|
+
plaintext, which could include sensitive data such as PII for yourself or your
|
48
|
+
customers, private keys, or other security data that could be compromising if
|
49
|
+
leaked. Always practice good data hygiene with your application logs, and follow
|
50
|
+
the principle of least access. Google also recommends that Client Library Debug
|
51
|
+
Logging be enabled only temporarily during active debugging, and not used
|
52
|
+
permanently in production.
|
53
|
+
|
54
|
+
To enable logging, set the environment variable `GOOGLE_SDK_RUBY_LOGGING_GEMS`
|
55
|
+
to the value `all`. Alternatively, you can set the value to a comma-delimited
|
56
|
+
list of client library gem names. This will select the default logging behavior,
|
57
|
+
which writes logs to the standard error stream. On a local workstation, this may
|
58
|
+
result in logs appearing on the console. When running on a Google Cloud hosting
|
59
|
+
service such as [Google Cloud Run](https://cloud.google.com/run), this generally
|
60
|
+
results in logs appearing alongside your application logs in the
|
61
|
+
[Google Cloud Logging](https://cloud.google.com/logging/) service.
|
62
|
+
|
63
|
+
Debug logging also requires that the versioned clients for this service be
|
64
|
+
sufficiently recent, released after about Dec 10, 2024. If logging is not
|
65
|
+
working, try updating the versioned clients in your bundle or installed gems:
|
66
|
+
[google-cloud-security_center-v1](https://cloud.google.com/ruby/docs/reference/google-cloud-security_center-v1/latest),
|
67
|
+
[google-cloud-security_center-v2](https://cloud.google.com/ruby/docs/reference/google-cloud-security_center-v2/latest).
|
46
68
|
|
47
69
|
## Supported Ruby Versions
|
48
70
|
|
49
|
-
This library is supported on Ruby
|
71
|
+
This library is supported on Ruby 3.0+.
|
50
72
|
|
51
73
|
Google provides official support for Ruby versions that are actively supported
|
52
74
|
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
@@ -49,8 +49,8 @@ module Google
|
|
49
49
|
# Create a new client object for SecurityCenter.
|
50
50
|
#
|
51
51
|
# By default, this returns an instance of
|
52
|
-
# [Google::Cloud::SecurityCenter::
|
53
|
-
# for a gRPC client for version
|
52
|
+
# [Google::Cloud::SecurityCenter::V2::SecurityCenter::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-security_center-v2/latest/Google-Cloud-SecurityCenter-V2-SecurityCenter-Client)
|
53
|
+
# for a gRPC client for version V2 of the API.
|
54
54
|
# However, you can specify a different API version by passing it in the
|
55
55
|
# `version` parameter. If the SecurityCenter service is
|
56
56
|
# supported by that API version, and the corresponding gem is available, the
|
@@ -58,16 +58,21 @@ module Google
|
|
58
58
|
# You can also specify a different transport by passing `:rest` or `:grpc` in
|
59
59
|
# the `transport` parameter.
|
60
60
|
#
|
61
|
+
# Raises an exception if the currently installed versioned client gem for the
|
62
|
+
# given API version does not support the given transport of the SecurityCenter service.
|
63
|
+
# You can determine whether the method will succeed by calling
|
64
|
+
# {Google::Cloud::SecurityCenter.security_center_available?}.
|
65
|
+
#
|
61
66
|
# ## About SecurityCenter
|
62
67
|
#
|
63
|
-
#
|
68
|
+
# V2 APIs for Security Center service.
|
64
69
|
#
|
65
70
|
# @param version [::String, ::Symbol] The API version to connect to. Optional.
|
66
|
-
# Defaults to `:
|
71
|
+
# Defaults to `:v2`.
|
67
72
|
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
|
68
73
|
# @return [::Object] A client object for the specified version.
|
69
74
|
#
|
70
|
-
def self.security_center version: :
|
75
|
+
def self.security_center version: :v2, transport: :grpc, &block
|
71
76
|
require "google/cloud/security_center/#{version.to_s.downcase}"
|
72
77
|
|
73
78
|
package_name = Google::Cloud::SecurityCenter
|
@@ -79,6 +84,37 @@ module Google
|
|
79
84
|
service_module.const_get(:Client).new(&block)
|
80
85
|
end
|
81
86
|
|
87
|
+
##
|
88
|
+
# Determines whether the SecurityCenter service is supported by the current client.
|
89
|
+
# If true, you can retrieve a client object by calling {Google::Cloud::SecurityCenter.security_center}.
|
90
|
+
# If false, that method will raise an exception. This could happen if the given
|
91
|
+
# API version does not exist or does not support the SecurityCenter service,
|
92
|
+
# or if the versioned client gem needs an update to support the SecurityCenter service.
|
93
|
+
#
|
94
|
+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
|
95
|
+
# Defaults to `:v2`.
|
96
|
+
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
|
97
|
+
# @return [boolean] Whether the service is available.
|
98
|
+
#
|
99
|
+
def self.security_center_available? version: :v2, transport: :grpc
|
100
|
+
require "google/cloud/security_center/#{version.to_s.downcase}"
|
101
|
+
package_name = Google::Cloud::SecurityCenter
|
102
|
+
.constants
|
103
|
+
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
|
104
|
+
.first
|
105
|
+
return false unless package_name
|
106
|
+
service_module = Google::Cloud::SecurityCenter.const_get package_name
|
107
|
+
return false unless service_module.const_defined? :SecurityCenter
|
108
|
+
service_module = service_module.const_get :SecurityCenter
|
109
|
+
if transport == :rest
|
110
|
+
return false unless service_module.const_defined? :Rest
|
111
|
+
service_module = service_module.const_get :Rest
|
112
|
+
end
|
113
|
+
service_module.const_defined? :Client
|
114
|
+
rescue ::LoadError
|
115
|
+
false
|
116
|
+
end
|
117
|
+
|
82
118
|
##
|
83
119
|
# Configure the google-cloud-security_center library.
|
84
120
|
#
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-security_center
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google LLC
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-13 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: google-cloud-core
|
@@ -28,62 +27,30 @@ dependencies:
|
|
28
27
|
name: google-cloud-security_center-v1
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.34'
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 2.a
|
37
|
-
type: :runtime
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0.34'
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 2.a
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: google-cloud-security_center-v1p1beta1
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.13'
|
54
|
-
- - "<"
|
30
|
+
- - "~>"
|
55
31
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
32
|
+
version: '1.0'
|
57
33
|
type: :runtime
|
58
34
|
prerelease: false
|
59
35
|
version_requirements: !ruby/object:Gem::Requirement
|
60
36
|
requirements:
|
61
|
-
- - "
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0.13'
|
64
|
-
- - "<"
|
37
|
+
- - "~>"
|
65
38
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
39
|
+
version: '1.0'
|
67
40
|
- !ruby/object:Gem::Dependency
|
68
41
|
name: google-cloud-security_center-v2
|
69
42
|
requirement: !ruby/object:Gem::Requirement
|
70
43
|
requirements:
|
71
|
-
- - "
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '0.0'
|
74
|
-
- - "<"
|
44
|
+
- - "~>"
|
75
45
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
46
|
+
version: '1.0'
|
77
47
|
type: :runtime
|
78
48
|
prerelease: false
|
79
49
|
version_requirements: !ruby/object:Gem::Requirement
|
80
50
|
requirements:
|
81
|
-
- - "
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0.0'
|
84
|
-
- - "<"
|
51
|
+
- - "~>"
|
85
52
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
53
|
+
version: '1.0'
|
87
54
|
description: Security Command Center API provides access to temporal views of assets
|
88
55
|
and findings within an organization.
|
89
56
|
email: googleapis-packages@google.com
|
@@ -94,7 +61,6 @@ files:
|
|
94
61
|
- ".yardopts"
|
95
62
|
- AUTHENTICATION.md
|
96
63
|
- LICENSE.md
|
97
|
-
- MIGRATING.md
|
98
64
|
- README.md
|
99
65
|
- lib/google-cloud-security_center.rb
|
100
66
|
- lib/google/cloud/security_center.rb
|
@@ -103,7 +69,6 @@ homepage: https://github.com/googleapis/google-cloud-ruby
|
|
103
69
|
licenses:
|
104
70
|
- Apache-2.0
|
105
71
|
metadata: {}
|
106
|
-
post_install_message:
|
107
72
|
rdoc_options: []
|
108
73
|
require_paths:
|
109
74
|
- lib
|
@@ -111,15 +76,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
76
|
requirements:
|
112
77
|
- - ">="
|
113
78
|
- !ruby/object:Gem::Version
|
114
|
-
version: '
|
79
|
+
version: '3.0'
|
115
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
81
|
requirements:
|
117
82
|
- - ">="
|
118
83
|
- !ruby/object:Gem::Version
|
119
84
|
version: '0'
|
120
85
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
122
|
-
signing_key:
|
86
|
+
rubygems_version: 3.6.3
|
123
87
|
specification_version: 4
|
124
88
|
summary: API Client library for the Security Command Center API
|
125
89
|
test_files: []
|
data/MIGRATING.md
DELETED
@@ -1,327 +0,0 @@
|
|
1
|
-
## Migrating to google-cloud-security_center 1.0
|
2
|
-
|
3
|
-
The 1.0 release of the google-cloud-security_center client is a significant upgrade
|
4
|
-
based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
|
5
|
-
and includes substantial interface changes. Existing code written for earlier
|
6
|
-
versions of this library will likely require updates to use this version.
|
7
|
-
This document describes the changes that have been made, and what you need to
|
8
|
-
do to update your usage.
|
9
|
-
|
10
|
-
To summarize:
|
11
|
-
|
12
|
-
* The library has been broken out into three libraries. The new gems
|
13
|
-
`google-cloud-security_center-v1` and `google-cloud-security_center-v1p1beta1` contain the
|
14
|
-
actual client classes for versions V1 and V1p1beta1 of the Cloud Security Command Center
|
15
|
-
service, and the gem `google-cloud-security_center` now simply provides a
|
16
|
-
convenience wrapper. See [Library Structure](#library-structure) for more
|
17
|
-
info.
|
18
|
-
* The library uses a new configuration mechanism giving you closer control
|
19
|
-
over endpoint address, network timeouts, and retry. See
|
20
|
-
[Client Configuration](#client-configuration) for more info. Furthermore,
|
21
|
-
when creating a client object, you can customize its configuration in a
|
22
|
-
block rather than passing arguments to the constructor. See
|
23
|
-
[Creating Clients](#creating-clients) for more info.
|
24
|
-
* Previously, positional arguments were used to indicate required arguments.
|
25
|
-
Now, all method arguments are keyword arguments, with documentation that
|
26
|
-
specifies whether they are required or optional. Additionally, you can pass
|
27
|
-
a proto request object instead of separate arguments. See
|
28
|
-
[Passing Arguments](#passing-arguments) for more info.
|
29
|
-
* Previously, some client classes included helper methods for constructing
|
30
|
-
resource paths. These methods now take keyword rather than positional
|
31
|
-
arguments, and are also available in a separate paths module. See
|
32
|
-
[Resource Path Helpers](#resource-path-helpers) for more info.
|
33
|
-
* Previously, clients reported RPC errors by raising instances of
|
34
|
-
`Google::Gax::GaxError` and its subclasses. Now, RPC exceptions are of type
|
35
|
-
`Google::Cloud::Error` and its subclasses. See
|
36
|
-
[Handling Errors](#handling-errors) for more info.
|
37
|
-
* Some classes have moved into different namespaces. See
|
38
|
-
[Class Namespaces](#class-namespaces) for more info.
|
39
|
-
|
40
|
-
### Library Structure
|
41
|
-
|
42
|
-
Older 0.x releases of the `google-cloud-security_center` gem were all-in-one gems that
|
43
|
-
included potentially multiple clients for multiple versions of the Security
|
44
|
-
Command Center service. The `Google::Cloud::SecurityCenter.new` factory method would
|
45
|
-
return you an instance of a `Google::Cloud::SecurityCenter::V1::SecurityCenterClient`
|
46
|
-
object for the V1 version of the service, or a
|
47
|
-
`Google::Cloud::SecurityCenter::V1p1beta1::SecurityCenterClient` object for the
|
48
|
-
V1p1beta1 version of the service. All these classes were defined in the same gem.
|
49
|
-
|
50
|
-
With the 1.0 release, the `google-cloud-security_center` gem still provides factory
|
51
|
-
methods for obtaining clients. (The method signatures will have changed. See
|
52
|
-
[Creating Clients](#creating-clients) for details.) However, the actual client
|
53
|
-
classes have been moved into separate gems, one per service version. The
|
54
|
-
`Google::Cloud::SecurityCenter::V1::SecurityCenter::Client` class, along with its
|
55
|
-
helpers and data types, is now part of the `google-cloud-security_center-v1` gem.
|
56
|
-
Similarly, the `Google::Cloud::SecurityCenter::V1p1beta1::SecurityCenter::Client`
|
57
|
-
class is part of the `google-cloud-security_center-v1p1beta1` gem.
|
58
|
-
|
59
|
-
For normal usage, you can continue to install the `google-cloud-security_center` gem
|
60
|
-
(which will bring in the versioned client gems as dependencies) and continue to
|
61
|
-
use factory methods to create clients. However, you may alternatively choose to
|
62
|
-
install only one of the versioned gems. For example, if you know you will only
|
63
|
-
`V1` of the service, you can install `google-cloud-security_center-v1` by itself, and
|
64
|
-
construct instances of the
|
65
|
-
`Google::Cloud::SecurityCenter::V1::SecurityCenter::Client` client class directly.
|
66
|
-
|
67
|
-
### Client Configuration
|
68
|
-
|
69
|
-
In older releases, if you wanted to customize performance parameters or
|
70
|
-
low-level behavior of the client (such as credentials, timeouts, or
|
71
|
-
instrumentation), you would pass a variety of keyword arguments to the client
|
72
|
-
constructor. It was also extremely difficult to customize the default settings.
|
73
|
-
|
74
|
-
With the 1.0 release, a configuration interface provides control over these
|
75
|
-
parameters, including defaults for all instances of a client, and settings for
|
76
|
-
each specific client instance. For example, to set default credentials and
|
77
|
-
timeout for all SecurityCenter V1 clients:
|
78
|
-
|
79
|
-
```
|
80
|
-
Google::Cloud::SecurityCenter::V1::SecurityCenter::Client.configure do |config|
|
81
|
-
config.credentials = "/path/to/credentials.json"
|
82
|
-
config.timeout = 10.0
|
83
|
-
end
|
84
|
-
```
|
85
|
-
|
86
|
-
Individual RPCs can also be configured independently. For example, to set the
|
87
|
-
timeout for the `list_findings` call:
|
88
|
-
|
89
|
-
```
|
90
|
-
Google::Cloud::SecurityCenter::V1::SecurityCenter::Client.configure do |config|
|
91
|
-
config.rpcs.list_findings.timeout = 20.0
|
92
|
-
end
|
93
|
-
```
|
94
|
-
|
95
|
-
Defaults for certain configurations can be set for all SecurityCenter versions
|
96
|
-
globally:
|
97
|
-
|
98
|
-
```
|
99
|
-
Google::Cloud::SecurityCenter.configure do |config|
|
100
|
-
config.credentials = "/path/to/credentials.json"
|
101
|
-
config.timeout = 10.0
|
102
|
-
end
|
103
|
-
```
|
104
|
-
|
105
|
-
Finally, you can override the configuration for each client instance. See the
|
106
|
-
next section on [Creating Clients](#creating-clients) for details.
|
107
|
-
|
108
|
-
### Creating Clients
|
109
|
-
|
110
|
-
In older releases, to create a client object, you would use the
|
111
|
-
`Google::Cloud::SecurityCenter.new` class method. Keyword arguments were available to
|
112
|
-
select a service version and to configure parameters such as credentials and
|
113
|
-
timeouts.
|
114
|
-
|
115
|
-
With the 1.0 release, use the `Google::Cloud::SecurityCenter.security_center` class
|
116
|
-
method to create a client object. You may select a service version using the
|
117
|
-
`:version` keyword argument. However, other configuration parameters should be
|
118
|
-
set in a configuration block when you create the client.
|
119
|
-
|
120
|
-
Old:
|
121
|
-
```
|
122
|
-
client = Google::Cloud::SecurityCenter.new credentials: "/path/to/credentials.json"
|
123
|
-
```
|
124
|
-
|
125
|
-
New:
|
126
|
-
```
|
127
|
-
client = Google::Cloud::SecurityCenter.security_center do |config|
|
128
|
-
config.credentials = "/path/to/credentials.json"
|
129
|
-
end
|
130
|
-
```
|
131
|
-
|
132
|
-
The configuration block is optional. If you do not provide it, or you do not
|
133
|
-
set some configuration parameters, then the default configuration is used. See
|
134
|
-
[Client Configuration](#client-configuration).
|
135
|
-
|
136
|
-
### Passing Arguments
|
137
|
-
|
138
|
-
In older releases, required arguments would be passed as positional method
|
139
|
-
arguments, while most optional arguments would be passed as keyword arguments.
|
140
|
-
|
141
|
-
With the 1.0 release, all RPC arguments are passed as keyword arguments,
|
142
|
-
regardless of whether they are required or optional. For example:
|
143
|
-
|
144
|
-
Old:
|
145
|
-
```
|
146
|
-
client = Google::Cloud::SecurityCenter.new
|
147
|
-
|
148
|
-
parent = "organizations/my-org/sources/-"
|
149
|
-
ordering = "name"
|
150
|
-
|
151
|
-
# Parent is a positional argument, while order_by is a keyword argument.
|
152
|
-
response = client.list_findings parent, order_by: ordering
|
153
|
-
```
|
154
|
-
|
155
|
-
New:
|
156
|
-
```
|
157
|
-
client = Google::Cloud::SecurityCenter.security_center
|
158
|
-
|
159
|
-
parent = "organizations/my-org/sources/-"
|
160
|
-
ordering = "name"
|
161
|
-
|
162
|
-
# Both parent and order_by are keyword arguments.
|
163
|
-
response = client.list_findings parent: parent, order_by: ordering
|
164
|
-
```
|
165
|
-
|
166
|
-
In the 1.0 release, it is also possible to pass a request object, either
|
167
|
-
as a hash or as a protocol buffer.
|
168
|
-
|
169
|
-
New:
|
170
|
-
```
|
171
|
-
client = Google::Cloud::SecurityCenter.security_center
|
172
|
-
|
173
|
-
request = Google::Cloud::SecurityCenter::V1::ListFindingsRequest.new(
|
174
|
-
parent: "organizations/my-org/sources/-",
|
175
|
-
order_by: "name"
|
176
|
-
)
|
177
|
-
|
178
|
-
# Pass a request object as a positional argument:
|
179
|
-
response = client.list_findings request
|
180
|
-
```
|
181
|
-
|
182
|
-
Finally, in older releases, to provide call options, you would pass a
|
183
|
-
`Google::Gax::CallOptions` object with the `:options` keyword argument. In the
|
184
|
-
1.0 release, pass call options using a _second set_ of keyword arguments.
|
185
|
-
|
186
|
-
Old:
|
187
|
-
```
|
188
|
-
client = Google::Cloud::SecurityCenter.new
|
189
|
-
|
190
|
-
parent = "organizations/my-org/sources/-"
|
191
|
-
ordering = "name"
|
192
|
-
|
193
|
-
options = Google::Gax::CallOptions.new timeout: 10.0
|
194
|
-
|
195
|
-
response = client.list_findings parent, order_by: ordering, options: options
|
196
|
-
```
|
197
|
-
|
198
|
-
New:
|
199
|
-
```
|
200
|
-
client = Google::Cloud::SecurityCenter.security_center
|
201
|
-
|
202
|
-
parent = "organizations/my-org/sources/-"
|
203
|
-
ordering = "name"
|
204
|
-
|
205
|
-
# Use a hash to wrap the normal call arguments (or pass a request object), and
|
206
|
-
# then add further keyword arguments for the call options.
|
207
|
-
response = client.list_findings(
|
208
|
-
{ parent: parent, order_by: ordering },
|
209
|
-
timeout: 10.0
|
210
|
-
)
|
211
|
-
```
|
212
|
-
|
213
|
-
### Resource Path Helpers
|
214
|
-
|
215
|
-
The client library includes helper methods for generating the resource path
|
216
|
-
strings passed to many calls. These helpers have changed in two ways:
|
217
|
-
|
218
|
-
* In older releases, they are both _class_ methods and _instance_ methods on
|
219
|
-
the client class. In the 1.0 release, they are _instance methods only_.
|
220
|
-
However, they are also available on a separate paths module that you can
|
221
|
-
include elsewhere for convenience.
|
222
|
-
* In older releases, arguments to a resource path helper are passed as
|
223
|
-
_positional_ arguments. In the 1.0 release, they are passed as named _keyword_
|
224
|
-
arguments.
|
225
|
-
|
226
|
-
Following is an example involving using a resource path helper.
|
227
|
-
|
228
|
-
Old:
|
229
|
-
```
|
230
|
-
client = Google::Cloud::SecurityCenter.new
|
231
|
-
|
232
|
-
# Call the helper using positional arguments.
|
233
|
-
parent = client.source_path "my-org", "my-source"
|
234
|
-
|
235
|
-
response = client.list_findings parent
|
236
|
-
```
|
237
|
-
|
238
|
-
New:
|
239
|
-
```
|
240
|
-
client = Google::Cloud::SecurityCenter.security_center
|
241
|
-
|
242
|
-
# Call the helper using keyword arguments
|
243
|
-
parent = client.source_path organization: "my-org", source: "my-source"
|
244
|
-
|
245
|
-
response = client.list_findings parent: parent
|
246
|
-
```
|
247
|
-
|
248
|
-
In the 1.0 client, you can also use the paths module as a convenience module.
|
249
|
-
|
250
|
-
New:
|
251
|
-
```
|
252
|
-
# Bring the path helper methods into the current class
|
253
|
-
include Google::Cloud::SecurityCenter::V1::SecurityCenterService::Paths
|
254
|
-
|
255
|
-
def foo
|
256
|
-
client = Google::Cloud::SecurityCenter.security_center
|
257
|
-
|
258
|
-
# Call the included helper method
|
259
|
-
parent = source_path organization: "my-org", source: "my-source"
|
260
|
-
|
261
|
-
response = client.list_findings parent: parent
|
262
|
-
|
263
|
-
# Do something with response...
|
264
|
-
end
|
265
|
-
```
|
266
|
-
|
267
|
-
### Handling Errors
|
268
|
-
|
269
|
-
The client reports standard
|
270
|
-
[gRPC error codes](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md)
|
271
|
-
by raising exceptions. In older releases, these exceptions were located in the
|
272
|
-
`Google::Gax` namespace and were subclasses of the `Google::Gax::GaxError` base
|
273
|
-
exception class, defined in the `google-gax` gem. However, these classes were
|
274
|
-
different from the standard exceptions (subclasses of `Google::Cloud::Error`)
|
275
|
-
thrown by other client libraries such as `google-cloud-storage`.
|
276
|
-
|
277
|
-
The 1.0 client library now uses the `Google::Cloud::Error` exception hierarchy,
|
278
|
-
for consistency across all the Google Cloud client libraries. In general, these
|
279
|
-
exceptions have the same name as their counterparts from older releases, but
|
280
|
-
are located in the `Google::Cloud` namespace rather than the `Google::Gax`
|
281
|
-
namespace.
|
282
|
-
|
283
|
-
Old:
|
284
|
-
```
|
285
|
-
client = Google::Cloud::SecurityCenter.new
|
286
|
-
|
287
|
-
parent = "organizations/my-org/sources/-"
|
288
|
-
ordering = "name"
|
289
|
-
|
290
|
-
begin
|
291
|
-
response = client.list_findings parent, order_by: ordering
|
292
|
-
rescue Google::Gax::Error => e
|
293
|
-
# Handle exceptions that subclass Google::Gax::Error
|
294
|
-
end
|
295
|
-
```
|
296
|
-
|
297
|
-
New:
|
298
|
-
```
|
299
|
-
client = Google::Cloud::SecurityCenter.security_center
|
300
|
-
|
301
|
-
parent = "organizations/my-org/sources/-"
|
302
|
-
ordering = "name"
|
303
|
-
|
304
|
-
begin
|
305
|
-
response = client.list_findings parent: parent, order_by: ordering
|
306
|
-
rescue Google::Cloud::Error => e
|
307
|
-
# Handle exceptions that subclass Google::Cloud::Error
|
308
|
-
end
|
309
|
-
```
|
310
|
-
|
311
|
-
### Class Namespaces
|
312
|
-
|
313
|
-
In older releases, the client object was of class
|
314
|
-
`Google::Cloud::SecurityCenter::V1::SecurityCenterClient`.
|
315
|
-
In the 1.0 release, the client object is of class
|
316
|
-
`Google::Cloud::SecurityCenter::V1::SecurityCenter::Client`.
|
317
|
-
Note that most users will use the `Google::Cloud::SecurityCenter.security_center`
|
318
|
-
factory method to create instances of the client object, so you may not need to
|
319
|
-
reference the actual class directly.
|
320
|
-
See [Creating Clients](#creating-clients).
|
321
|
-
|
322
|
-
In older releases, the credentials object was of class
|
323
|
-
`Google::Cloud::SecurityCenter::V1::Credentials`.
|
324
|
-
In the 1.0 release, the credentials object is of class
|
325
|
-
`Google::Cloud::SecurityCenter::V1::SecurityCenter::Credentials`.
|
326
|
-
Again, most users will not need to reference this class directly.
|
327
|
-
See [Client Configuration](#client-configuration).
|