google-cloud-asset 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/google/cloud/asset.rb +2 -2
- data/lib/google/cloud/asset/v1.rb +138 -0
- data/lib/google/cloud/asset/v1/asset_service_client.rb +385 -0
- data/lib/google/cloud/asset/v1/asset_service_client_config.json +36 -0
- data/lib/google/cloud/asset/v1/asset_service_pb.rb +63 -0
- data/lib/google/cloud/asset/v1/asset_service_services_pb.rb +58 -0
- data/lib/google/cloud/asset/v1/assets_pb.rb +49 -0
- data/lib/google/cloud/asset/v1/credentials.rb +41 -0
- data/lib/google/cloud/asset/v1/doc/google/cloud/asset/v1/asset_service.rb +129 -0
- data/lib/google/cloud/asset/v1/doc/google/cloud/asset/v1/assets.rb +108 -0
- data/lib/google/cloud/asset/v1/doc/google/iam/v1/policy.rb +104 -0
- data/lib/google/cloud/asset/v1/doc/google/longrunning/operations.rb +51 -0
- data/lib/google/cloud/asset/v1/doc/google/protobuf/any.rb +130 -0
- data/lib/google/cloud/asset/v1/doc/google/protobuf/struct.rb +74 -0
- data/lib/google/cloud/asset/v1/doc/google/protobuf/timestamp.rb +109 -0
- data/lib/google/cloud/asset/v1/doc/google/rpc/status.rb +87 -0
- data/lib/google/cloud/asset/v1/helpers.rb +29 -0
- data/lib/google/cloud/asset/v1beta1.rb +1 -0
- data/lib/google/cloud/asset/v1beta1/asset_service_client.rb +9 -7
- data/lib/google/cloud/asset/v1beta1/asset_service_services_pb.rb +3 -2
- data/lib/google/cloud/asset/v1beta1/doc/google/cloud/asset/v1beta1/asset_service.rb +6 -3
- data/lib/google/cloud/asset/v1beta1/doc/google/cloud/asset/v1beta1/assets.rb +10 -6
- data/lib/google/cloud/asset/v1beta1/doc/google/longrunning/operations.rb +1 -1
- data/lib/google/cloud/asset/v1beta1/doc/google/rpc/status.rb +17 -14
- data/lib/google/cloud/asset/v1beta1/helpers.rb +29 -0
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b823afc43c96272ec4d02e1d5f4396a522e5e81c5b27fb63e6e4935ee80d0ad
|
4
|
+
data.tar.gz: 374a449c5410e6342ed2e12c1051042d94c41ad0c13c14d1ef71536e613c5886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12ee04691bc7f3ae7d3199b7adbda4d78e0a0adf4e78c2c643652018b40f912a09f94eb3fc1da2504315097d2c086dc6c8e41cfdd3b668eacbe5221df659e51a
|
7
|
+
data.tar.gz: aecc97f0ae21e4928cba3a990879ba4ba14583964382fefff23e445f386a6acdfc55b32e15ced8c1d56afc6546c2364d826db3b04ae4575629528b5c7ac91e38
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ $ gem install google-cloud-asset
|
|
27
27
|
- View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
28
28
|
to see the full list of Cloud APIs that we cover.
|
29
29
|
|
30
|
-
[Client Library Documentation]: https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-asset/latest/google/cloud/asset/
|
30
|
+
[Client Library Documentation]: https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-asset/latest/google/cloud/asset/v1
|
31
31
|
[Product Documentation]: https://cloud.google.com/asset
|
32
32
|
|
33
33
|
## Enabling Logging
|
data/lib/google/cloud/asset.rb
CHANGED
@@ -90,7 +90,7 @@ module Google
|
|
90
90
|
# Asset service definition.
|
91
91
|
#
|
92
92
|
# @param version [Symbol, String]
|
93
|
-
# The major version of the service to be used. By default :
|
93
|
+
# The major version of the service to be used. By default :v1
|
94
94
|
# is used.
|
95
95
|
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
96
96
|
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
@@ -122,7 +122,7 @@ module Google
|
|
122
122
|
# @param exception_transformer [Proc]
|
123
123
|
# An optional proc that intercepts any exceptions raised during an API call to inject
|
124
124
|
# custom error handling.
|
125
|
-
def self.new(*args, version: :
|
125
|
+
def self.new(*args, version: :v1, **kwargs)
|
126
126
|
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
127
127
|
raise "The version: #{version} is not available. The available versions " \
|
128
128
|
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
require "google/cloud/asset/v1/asset_service_client"
|
17
|
+
require "google/cloud/asset/v1/helpers"
|
18
|
+
|
19
|
+
module Google
|
20
|
+
module Cloud
|
21
|
+
module Asset
|
22
|
+
# rubocop:disable LineLength
|
23
|
+
|
24
|
+
##
|
25
|
+
# # Ruby Client for Cloud Asset API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
26
|
+
#
|
27
|
+
# [Cloud Asset API][Product Documentation]:
|
28
|
+
# The cloud asset API manages the history and inventory of cloud resources.
|
29
|
+
# - [Product Documentation][]
|
30
|
+
#
|
31
|
+
# ## Quick Start
|
32
|
+
# In order to use this library, you first need to go through the following
|
33
|
+
# steps:
|
34
|
+
#
|
35
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
36
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
37
|
+
# 3. [Enable the Cloud Asset API.](https://console.cloud.google.com/apis/library/asset.googleapis.com)
|
38
|
+
# 4. [Setup Authentication.](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
39
|
+
#
|
40
|
+
# ### Installation
|
41
|
+
# ```
|
42
|
+
# $ gem install google-cloud-asset
|
43
|
+
# ```
|
44
|
+
#
|
45
|
+
# ### Next Steps
|
46
|
+
# - Read the [Cloud Asset API Product documentation][Product Documentation]
|
47
|
+
# to learn more about the product and see How-to Guides.
|
48
|
+
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
49
|
+
# to see the full list of Cloud APIs that we cover.
|
50
|
+
#
|
51
|
+
# [Product Documentation]: https://cloud.google.com/asset
|
52
|
+
#
|
53
|
+
# ## Enabling Logging
|
54
|
+
#
|
55
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
56
|
+
# The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
|
57
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
58
|
+
# that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
59
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
60
|
+
#
|
61
|
+
# Configuring a Ruby stdlib logger:
|
62
|
+
#
|
63
|
+
# ```ruby
|
64
|
+
# require "logger"
|
65
|
+
#
|
66
|
+
# module MyLogger
|
67
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
68
|
+
# def logger
|
69
|
+
# LOGGER
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
74
|
+
# module GRPC
|
75
|
+
# extend MyLogger
|
76
|
+
# end
|
77
|
+
# ```
|
78
|
+
#
|
79
|
+
module V1
|
80
|
+
# rubocop:enable LineLength
|
81
|
+
|
82
|
+
##
|
83
|
+
# Asset service definition.
|
84
|
+
#
|
85
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
86
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
87
|
+
# be many types.
|
88
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
89
|
+
# authenticating requests made by this client.
|
90
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
91
|
+
# credentials for this client.
|
92
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
93
|
+
# credentials for this client.
|
94
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
95
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
96
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
97
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
98
|
+
# metadata for requests, generally, to give OAuth credentials.
|
99
|
+
# @param scopes [Array<String>]
|
100
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
101
|
+
# an updater_proc is supplied.
|
102
|
+
# @param client_config [Hash]
|
103
|
+
# A Hash for call options for each method. See
|
104
|
+
# Google::Gax#construct_settings for the structure of
|
105
|
+
# this data. Falls back to the default config if not specified
|
106
|
+
# or the specified config is missing data points.
|
107
|
+
# @param timeout [Numeric]
|
108
|
+
# The default timeout, in seconds, for calls made through this client.
|
109
|
+
# @param metadata [Hash]
|
110
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
111
|
+
# @param exception_transformer [Proc]
|
112
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
113
|
+
# custom error handling.
|
114
|
+
def self.new \
|
115
|
+
credentials: nil,
|
116
|
+
scopes: nil,
|
117
|
+
client_config: nil,
|
118
|
+
timeout: nil,
|
119
|
+
metadata: nil,
|
120
|
+
exception_transformer: nil,
|
121
|
+
lib_name: nil,
|
122
|
+
lib_version: nil
|
123
|
+
kwargs = {
|
124
|
+
credentials: credentials,
|
125
|
+
scopes: scopes,
|
126
|
+
client_config: client_config,
|
127
|
+
timeout: timeout,
|
128
|
+
metadata: metadata,
|
129
|
+
exception_transformer: exception_transformer,
|
130
|
+
lib_name: lib_name,
|
131
|
+
lib_version: lib_version
|
132
|
+
}.select { |_, v| v != nil }
|
133
|
+
Google::Cloud::Asset::V1::AssetServiceClient.new(**kwargs)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,385 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#
|
15
|
+
# EDITING INSTRUCTIONS
|
16
|
+
# This file was generated from the file
|
17
|
+
# https://github.com/googleapis/googleapis/blob/master/google/cloud/asset/v1/asset_service.proto,
|
18
|
+
# and updates to that file get reflected here through a refresh process.
|
19
|
+
# For the short term, the refresh process will only be runnable by Google
|
20
|
+
# engineers.
|
21
|
+
|
22
|
+
|
23
|
+
require "json"
|
24
|
+
require "pathname"
|
25
|
+
|
26
|
+
require "google/gax"
|
27
|
+
require "google/gax/operation"
|
28
|
+
require "google/longrunning/operations_client"
|
29
|
+
|
30
|
+
require "google/cloud/asset/v1/asset_service_pb"
|
31
|
+
require "google/cloud/asset/v1/credentials"
|
32
|
+
|
33
|
+
module Google
|
34
|
+
module Cloud
|
35
|
+
module Asset
|
36
|
+
module V1
|
37
|
+
# Asset service definition.
|
38
|
+
#
|
39
|
+
# @!attribute [r] asset_service_stub
|
40
|
+
# @return [Google::Cloud::Asset::V1::AssetService::Stub]
|
41
|
+
class AssetServiceClient
|
42
|
+
# @private
|
43
|
+
attr_reader :asset_service_stub
|
44
|
+
|
45
|
+
# The default address of the service.
|
46
|
+
SERVICE_ADDRESS = "cloudasset.googleapis.com".freeze
|
47
|
+
|
48
|
+
# The default port of the service.
|
49
|
+
DEFAULT_SERVICE_PORT = 443
|
50
|
+
|
51
|
+
# The default set of gRPC interceptors.
|
52
|
+
GRPC_INTERCEPTORS = []
|
53
|
+
|
54
|
+
DEFAULT_TIMEOUT = 30
|
55
|
+
|
56
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
57
|
+
# this service.
|
58
|
+
ALL_SCOPES = [
|
59
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
60
|
+
].freeze
|
61
|
+
|
62
|
+
# @private
|
63
|
+
class OperationsClient < Google::Longrunning::OperationsClient
|
64
|
+
self::SERVICE_ADDRESS = AssetServiceClient::SERVICE_ADDRESS
|
65
|
+
self::GRPC_INTERCEPTORS = AssetServiceClient::GRPC_INTERCEPTORS
|
66
|
+
end
|
67
|
+
|
68
|
+
PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
69
|
+
"projects/{project}"
|
70
|
+
)
|
71
|
+
|
72
|
+
private_constant :PROJECT_PATH_TEMPLATE
|
73
|
+
|
74
|
+
# Returns a fully-qualified project resource name string.
|
75
|
+
# @param project [String]
|
76
|
+
# @return [String]
|
77
|
+
def self.project_path project
|
78
|
+
PROJECT_PATH_TEMPLATE.render(
|
79
|
+
:"project" => project
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
84
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
85
|
+
# be many types.
|
86
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
87
|
+
# authenticating requests made by this client.
|
88
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
89
|
+
# credentials for this client.
|
90
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
91
|
+
# credentials for this client.
|
92
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
93
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
94
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
95
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
96
|
+
# metadata for requests, generally, to give OAuth credentials.
|
97
|
+
# @param scopes [Array<String>]
|
98
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
99
|
+
# an updater_proc is supplied.
|
100
|
+
# @param client_config [Hash]
|
101
|
+
# A Hash for call options for each method. See
|
102
|
+
# Google::Gax#construct_settings for the structure of
|
103
|
+
# this data. Falls back to the default config if not specified
|
104
|
+
# or the specified config is missing data points.
|
105
|
+
# @param timeout [Numeric]
|
106
|
+
# The default timeout, in seconds, for calls made through this client.
|
107
|
+
# @param metadata [Hash]
|
108
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
109
|
+
# @param exception_transformer [Proc]
|
110
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
111
|
+
# custom error handling.
|
112
|
+
def initialize \
|
113
|
+
credentials: nil,
|
114
|
+
scopes: ALL_SCOPES,
|
115
|
+
client_config: {},
|
116
|
+
timeout: DEFAULT_TIMEOUT,
|
117
|
+
metadata: nil,
|
118
|
+
exception_transformer: nil,
|
119
|
+
lib_name: nil,
|
120
|
+
lib_version: ""
|
121
|
+
# These require statements are intentionally placed here to initialize
|
122
|
+
# the gRPC module only when it's required.
|
123
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
124
|
+
require "google/gax/grpc"
|
125
|
+
require "google/cloud/asset/v1/asset_service_services_pb"
|
126
|
+
|
127
|
+
credentials ||= Google::Cloud::Asset::V1::Credentials.default
|
128
|
+
|
129
|
+
@operations_client = OperationsClient.new(
|
130
|
+
credentials: credentials,
|
131
|
+
scopes: scopes,
|
132
|
+
client_config: client_config,
|
133
|
+
timeout: timeout,
|
134
|
+
lib_name: lib_name,
|
135
|
+
lib_version: lib_version,
|
136
|
+
)
|
137
|
+
|
138
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
139
|
+
updater_proc = Google::Cloud::Asset::V1::Credentials.new(credentials).updater_proc
|
140
|
+
end
|
141
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
142
|
+
channel = credentials
|
143
|
+
end
|
144
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
145
|
+
chan_creds = credentials
|
146
|
+
end
|
147
|
+
if credentials.is_a?(Proc)
|
148
|
+
updater_proc = credentials
|
149
|
+
end
|
150
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
151
|
+
updater_proc = credentials.updater_proc
|
152
|
+
end
|
153
|
+
|
154
|
+
package_version = Gem.loaded_specs['google-cloud-asset'].version.version
|
155
|
+
|
156
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
157
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
158
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
159
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
160
|
+
google_api_client.freeze
|
161
|
+
|
162
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
163
|
+
headers.merge!(metadata) unless metadata.nil?
|
164
|
+
client_config_file = Pathname.new(__dir__).join(
|
165
|
+
"asset_service_client_config.json"
|
166
|
+
)
|
167
|
+
defaults = client_config_file.open do |f|
|
168
|
+
Google::Gax.construct_settings(
|
169
|
+
"google.cloud.asset.v1.AssetService",
|
170
|
+
JSON.parse(f.read),
|
171
|
+
client_config,
|
172
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
173
|
+
timeout,
|
174
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
175
|
+
metadata: headers
|
176
|
+
)
|
177
|
+
end
|
178
|
+
|
179
|
+
# Allow overriding the service path/port in subclasses.
|
180
|
+
service_path = self.class::SERVICE_ADDRESS
|
181
|
+
port = self.class::DEFAULT_SERVICE_PORT
|
182
|
+
interceptors = self.class::GRPC_INTERCEPTORS
|
183
|
+
@asset_service_stub = Google::Gax::Grpc.create_stub(
|
184
|
+
service_path,
|
185
|
+
port,
|
186
|
+
chan_creds: chan_creds,
|
187
|
+
channel: channel,
|
188
|
+
updater_proc: updater_proc,
|
189
|
+
scopes: scopes,
|
190
|
+
interceptors: interceptors,
|
191
|
+
&Google::Cloud::Asset::V1::AssetService::Stub.method(:new)
|
192
|
+
)
|
193
|
+
|
194
|
+
@export_assets = Google::Gax.create_api_call(
|
195
|
+
@asset_service_stub.method(:export_assets),
|
196
|
+
defaults["export_assets"],
|
197
|
+
exception_transformer: exception_transformer
|
198
|
+
)
|
199
|
+
@batch_get_assets_history = Google::Gax.create_api_call(
|
200
|
+
@asset_service_stub.method(:batch_get_assets_history),
|
201
|
+
defaults["batch_get_assets_history"],
|
202
|
+
exception_transformer: exception_transformer
|
203
|
+
)
|
204
|
+
end
|
205
|
+
|
206
|
+
# Service calls
|
207
|
+
|
208
|
+
# Exports assets with time and resource types to a given Cloud Storage
|
209
|
+
# location. The output format is newline-delimited JSON.
|
210
|
+
# This API implements the {Google::Longrunning::Operation} API allowing you
|
211
|
+
# to keep track of the export.
|
212
|
+
#
|
213
|
+
# @param parent [String]
|
214
|
+
# Required. The relative name of the root asset. This can only be an
|
215
|
+
# organization number (such as "organizations/123"), a project ID (such as
|
216
|
+
# "projects/my-project-id"), or a project number (such as "projects/12345"),
|
217
|
+
# or a folder number (such as "folders/123").
|
218
|
+
# @param output_config [Google::Cloud::Asset::V1::OutputConfig | Hash]
|
219
|
+
# Required. Output configuration indicating where the results will be output
|
220
|
+
# to. All results will be in newline delimited JSON format.
|
221
|
+
# A hash of the same form as `Google::Cloud::Asset::V1::OutputConfig`
|
222
|
+
# can also be provided.
|
223
|
+
# @param read_time [Google::Protobuf::Timestamp | Hash]
|
224
|
+
# Timestamp to take an asset snapshot. This can only be set to a timestamp
|
225
|
+
# between 2018-10-02 UTC (inclusive) and the current time. If not specified,
|
226
|
+
# the current time will be used. Due to delays in resource data collection
|
227
|
+
# and indexing, there is a volatile window during which running the same
|
228
|
+
# query may get different results.
|
229
|
+
# A hash of the same form as `Google::Protobuf::Timestamp`
|
230
|
+
# can also be provided.
|
231
|
+
# @param asset_types [Array<String>]
|
232
|
+
# A list of asset types of which to take a snapshot for. For example:
|
233
|
+
# "compute.googleapis.com/Disk". If specified, only matching assets will be returned.
|
234
|
+
# See [Introduction to Cloud Asset
|
235
|
+
# Inventory](https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview)
|
236
|
+
# for all supported asset types.
|
237
|
+
# @param content_type [Google::Cloud::Asset::V1::ContentType]
|
238
|
+
# Asset content type. If not specified, no content but the asset name will be
|
239
|
+
# returned.
|
240
|
+
# @param options [Google::Gax::CallOptions]
|
241
|
+
# Overrides the default settings for this call, e.g, timeout,
|
242
|
+
# retries, etc.
|
243
|
+
# @return [Google::Gax::Operation]
|
244
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
245
|
+
# @example
|
246
|
+
# require "google/cloud/asset"
|
247
|
+
#
|
248
|
+
# asset_client = Google::Cloud::Asset.new(version: :v1)
|
249
|
+
#
|
250
|
+
# # TODO: Initialize `parent`:
|
251
|
+
# parent = ''
|
252
|
+
#
|
253
|
+
# # TODO: Initialize `output_config`:
|
254
|
+
# output_config = {}
|
255
|
+
#
|
256
|
+
# # Register a callback during the method call.
|
257
|
+
# operation = asset_client.export_assets(parent, output_config) do |op|
|
258
|
+
# raise op.results.message if op.error?
|
259
|
+
# op_results = op.results
|
260
|
+
# # Process the results.
|
261
|
+
#
|
262
|
+
# metadata = op.metadata
|
263
|
+
# # Process the metadata.
|
264
|
+
# end
|
265
|
+
#
|
266
|
+
# # Or use the return value to register a callback.
|
267
|
+
# operation.on_done do |op|
|
268
|
+
# raise op.results.message if op.error?
|
269
|
+
# op_results = op.results
|
270
|
+
# # Process the results.
|
271
|
+
#
|
272
|
+
# metadata = op.metadata
|
273
|
+
# # Process the metadata.
|
274
|
+
# end
|
275
|
+
#
|
276
|
+
# # Manually reload the operation.
|
277
|
+
# operation.reload!
|
278
|
+
#
|
279
|
+
# # Or block until the operation completes, triggering callbacks on
|
280
|
+
# # completion.
|
281
|
+
# operation.wait_until_done!
|
282
|
+
|
283
|
+
def export_assets \
|
284
|
+
parent,
|
285
|
+
output_config,
|
286
|
+
read_time: nil,
|
287
|
+
asset_types: nil,
|
288
|
+
content_type: nil,
|
289
|
+
options: nil
|
290
|
+
req = {
|
291
|
+
parent: parent,
|
292
|
+
output_config: output_config,
|
293
|
+
read_time: read_time,
|
294
|
+
asset_types: asset_types,
|
295
|
+
content_type: content_type
|
296
|
+
}.delete_if { |_, v| v.nil? }
|
297
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Asset::V1::ExportAssetsRequest)
|
298
|
+
operation = Google::Gax::Operation.new(
|
299
|
+
@export_assets.call(req, options),
|
300
|
+
@operations_client,
|
301
|
+
Google::Cloud::Asset::V1::ExportAssetsResponse,
|
302
|
+
Google::Cloud::Asset::V1::ExportAssetsRequest,
|
303
|
+
call_options: options
|
304
|
+
)
|
305
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
306
|
+
operation
|
307
|
+
end
|
308
|
+
|
309
|
+
# Batch gets the update history of assets that overlap a time window.
|
310
|
+
# For RESOURCE content, this API outputs history with asset in both
|
311
|
+
# non-delete or deleted status.
|
312
|
+
# For IAM_POLICY content, this API outputs history when the asset and its
|
313
|
+
# attached IAM POLICY both exist. This can create gaps in the output history.
|
314
|
+
# If a specified asset does not exist, this API returns an INVALID_ARGUMENT
|
315
|
+
# error.
|
316
|
+
#
|
317
|
+
# @param parent [String]
|
318
|
+
# Required. The relative name of the root asset. It can only be an
|
319
|
+
# organization number (such as "organizations/123"), a project ID (such as
|
320
|
+
# "projects/my-project-id")", or a project number (such as "projects/12345").
|
321
|
+
# @param content_type [Google::Cloud::Asset::V1::ContentType]
|
322
|
+
# Required. The content type.
|
323
|
+
# @param read_time_window [Google::Cloud::Asset::V1::TimeWindow | Hash]
|
324
|
+
# Optional. The time window for the asset history. Both start_time and
|
325
|
+
# end_time are optional and if set, it must be after 2018-10-02 UTC. If
|
326
|
+
# end_time is not set, it is default to current timestamp. If start_time is
|
327
|
+
# not set, the snapshot of the assets at end_time will be returned. The
|
328
|
+
# returned results contain all temporal assets whose time window overlap with
|
329
|
+
# read_time_window.
|
330
|
+
# A hash of the same form as `Google::Cloud::Asset::V1::TimeWindow`
|
331
|
+
# can also be provided.
|
332
|
+
# @param asset_names [Array<String>]
|
333
|
+
# A list of the full names of the assets. For example:
|
334
|
+
# `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`.
|
335
|
+
# See [Resource
|
336
|
+
# Names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
|
337
|
+
# and [Resource Name Format](https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/resource-name-format)
|
338
|
+
# for more info.
|
339
|
+
#
|
340
|
+
# The request becomes a no-op if the asset name list is empty, and the max
|
341
|
+
# size of the asset name list is 100 in one request.
|
342
|
+
# @param options [Google::Gax::CallOptions]
|
343
|
+
# Overrides the default settings for this call, e.g, timeout,
|
344
|
+
# retries, etc.
|
345
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
346
|
+
# @yieldparam result [Google::Cloud::Asset::V1::BatchGetAssetsHistoryResponse]
|
347
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
348
|
+
# @return [Google::Cloud::Asset::V1::BatchGetAssetsHistoryResponse]
|
349
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
350
|
+
# @example
|
351
|
+
# require "google/cloud/asset"
|
352
|
+
#
|
353
|
+
# asset_client = Google::Cloud::Asset.new(version: :v1)
|
354
|
+
#
|
355
|
+
# # TODO: Initialize `parent`:
|
356
|
+
# parent = ''
|
357
|
+
#
|
358
|
+
# # TODO: Initialize `content_type`:
|
359
|
+
# content_type = :CONTENT_TYPE_UNSPECIFIED
|
360
|
+
#
|
361
|
+
# # TODO: Initialize `read_time_window`:
|
362
|
+
# read_time_window = {}
|
363
|
+
# response = asset_client.batch_get_assets_history(parent, content_type, read_time_window)
|
364
|
+
|
365
|
+
def batch_get_assets_history \
|
366
|
+
parent,
|
367
|
+
content_type,
|
368
|
+
read_time_window,
|
369
|
+
asset_names: nil,
|
370
|
+
options: nil,
|
371
|
+
&block
|
372
|
+
req = {
|
373
|
+
parent: parent,
|
374
|
+
content_type: content_type,
|
375
|
+
read_time_window: read_time_window,
|
376
|
+
asset_names: asset_names
|
377
|
+
}.delete_if { |_, v| v.nil? }
|
378
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Asset::V1::BatchGetAssetsHistoryRequest)
|
379
|
+
@batch_get_assets_history.call(req, options, &block)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|