google-apis-cloudasset_v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,704 @@
1
+ # Copyright 2020 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
+ # http://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
+ require 'google/apis/core/base_service'
16
+ require 'google/apis/core/json_representation'
17
+ require 'google/apis/core/hashable'
18
+ require 'google/apis/errors'
19
+
20
+ module Google
21
+ module Apis
22
+ module CloudassetV1
23
+ # Cloud Asset API
24
+ #
25
+ # The cloud asset API manages the history and inventory of cloud resources.
26
+ #
27
+ # @example
28
+ # require 'google/apis/cloudasset_v1'
29
+ #
30
+ # Cloudasset = Google::Apis::CloudassetV1 # Alias the module
31
+ # service = Cloudasset::CloudAssetService.new
32
+ #
33
+ # @see https://cloud.google.com/asset-inventory/docs/quickstart
34
+ class CloudAssetService < Google::Apis::Core::BaseService
35
+ # @return [String]
36
+ # API key. Your API key identifies your project and provides you with API access,
37
+ # quota, and reports. Required unless you provide an OAuth 2.0 token.
38
+ attr_accessor :key
39
+
40
+ # @return [String]
41
+ # Available to use for quota purposes for server-side applications. Can be any
42
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
43
+ attr_accessor :quota_user
44
+
45
+ def initialize
46
+ super('https://cloudasset.googleapis.com/', '',
47
+ client_name: 'google-apis-cloudasset_v1',
48
+ client_version: Google::Apis::CloudassetV1::GEM_VERSION)
49
+ @batch_path = 'batch'
50
+ end
51
+
52
+ # Creates a feed in a parent project/folder/organization to listen to its asset
53
+ # updates.
54
+ # @param [String] parent
55
+ # Required. The name of the project/folder/organization where this feed should
56
+ # be created in. It can only be an organization number (such as "organizations/
57
+ # 123"), a folder number (such as "folders/123"), a project ID (such as "
58
+ # projects/my-project-id")", or a project number (such as "projects/12345").
59
+ # @param [Google::Apis::CloudassetV1::CreateFeedRequest] create_feed_request_object
60
+ # @param [String] fields
61
+ # Selector specifying which fields to include in a partial response.
62
+ # @param [String] quota_user
63
+ # Available to use for quota purposes for server-side applications. Can be any
64
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
65
+ # @param [Google::Apis::RequestOptions] options
66
+ # Request-specific options
67
+ #
68
+ # @yield [result, err] Result & error if block supplied
69
+ # @yieldparam result [Google::Apis::CloudassetV1::Feed] parsed result object
70
+ # @yieldparam err [StandardError] error object if request failed
71
+ #
72
+ # @return [Google::Apis::CloudassetV1::Feed]
73
+ #
74
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
75
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
76
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
77
+ def create_feed(parent, create_feed_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
78
+ command = make_simple_command(:post, 'v1/{+parent}/feeds', options)
79
+ command.request_representation = Google::Apis::CloudassetV1::CreateFeedRequest::Representation
80
+ command.request_object = create_feed_request_object
81
+ command.response_representation = Google::Apis::CloudassetV1::Feed::Representation
82
+ command.response_class = Google::Apis::CloudassetV1::Feed
83
+ command.params['parent'] = parent unless parent.nil?
84
+ command.query['fields'] = fields unless fields.nil?
85
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
86
+ execute_or_queue_command(command, &block)
87
+ end
88
+
89
+ # Deletes an asset feed.
90
+ # @param [String] name
91
+ # Required. The name of the feed and it must be in the format of: projects/
92
+ # project_number/feeds/feed_id folders/folder_number/feeds/feed_id organizations/
93
+ # organization_number/feeds/feed_id
94
+ # @param [String] fields
95
+ # Selector specifying which fields to include in a partial response.
96
+ # @param [String] quota_user
97
+ # Available to use for quota purposes for server-side applications. Can be any
98
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
99
+ # @param [Google::Apis::RequestOptions] options
100
+ # Request-specific options
101
+ #
102
+ # @yield [result, err] Result & error if block supplied
103
+ # @yieldparam result [Google::Apis::CloudassetV1::Empty] parsed result object
104
+ # @yieldparam err [StandardError] error object if request failed
105
+ #
106
+ # @return [Google::Apis::CloudassetV1::Empty]
107
+ #
108
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
109
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
110
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
111
+ def delete_feed(name, fields: nil, quota_user: nil, options: nil, &block)
112
+ command = make_simple_command(:delete, 'v1/{+name}', options)
113
+ command.response_representation = Google::Apis::CloudassetV1::Empty::Representation
114
+ command.response_class = Google::Apis::CloudassetV1::Empty
115
+ command.params['name'] = name unless name.nil?
116
+ command.query['fields'] = fields unless fields.nil?
117
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
118
+ execute_or_queue_command(command, &block)
119
+ end
120
+
121
+ # Gets details about an asset feed.
122
+ # @param [String] name
123
+ # Required. The name of the Feed and it must be in the format of: projects/
124
+ # project_number/feeds/feed_id folders/folder_number/feeds/feed_id organizations/
125
+ # organization_number/feeds/feed_id
126
+ # @param [String] fields
127
+ # Selector specifying which fields to include in a partial response.
128
+ # @param [String] quota_user
129
+ # Available to use for quota purposes for server-side applications. Can be any
130
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
131
+ # @param [Google::Apis::RequestOptions] options
132
+ # Request-specific options
133
+ #
134
+ # @yield [result, err] Result & error if block supplied
135
+ # @yieldparam result [Google::Apis::CloudassetV1::Feed] parsed result object
136
+ # @yieldparam err [StandardError] error object if request failed
137
+ #
138
+ # @return [Google::Apis::CloudassetV1::Feed]
139
+ #
140
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
141
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
142
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
143
+ def get_feed(name, fields: nil, quota_user: nil, options: nil, &block)
144
+ command = make_simple_command(:get, 'v1/{+name}', options)
145
+ command.response_representation = Google::Apis::CloudassetV1::Feed::Representation
146
+ command.response_class = Google::Apis::CloudassetV1::Feed
147
+ command.params['name'] = name unless name.nil?
148
+ command.query['fields'] = fields unless fields.nil?
149
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
150
+ execute_or_queue_command(command, &block)
151
+ end
152
+
153
+ # Lists all asset feeds in a parent project/folder/organization.
154
+ # @param [String] parent
155
+ # Required. The parent project/folder/organization whose feeds are to be listed.
156
+ # It can only be using project/folder/organization number (such as "folders/
157
+ # 12345")", or a project ID (such as "projects/my-project-id").
158
+ # @param [String] fields
159
+ # Selector specifying which fields to include in a partial response.
160
+ # @param [String] quota_user
161
+ # Available to use for quota purposes for server-side applications. Can be any
162
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
163
+ # @param [Google::Apis::RequestOptions] options
164
+ # Request-specific options
165
+ #
166
+ # @yield [result, err] Result & error if block supplied
167
+ # @yieldparam result [Google::Apis::CloudassetV1::ListFeedsResponse] parsed result object
168
+ # @yieldparam err [StandardError] error object if request failed
169
+ #
170
+ # @return [Google::Apis::CloudassetV1::ListFeedsResponse]
171
+ #
172
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
173
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
174
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
175
+ def list_feeds(parent, fields: nil, quota_user: nil, options: nil, &block)
176
+ command = make_simple_command(:get, 'v1/{+parent}/feeds', options)
177
+ command.response_representation = Google::Apis::CloudassetV1::ListFeedsResponse::Representation
178
+ command.response_class = Google::Apis::CloudassetV1::ListFeedsResponse
179
+ command.params['parent'] = parent unless parent.nil?
180
+ command.query['fields'] = fields unless fields.nil?
181
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
182
+ execute_or_queue_command(command, &block)
183
+ end
184
+
185
+ # Updates an asset feed configuration.
186
+ # @param [String] name
187
+ # Required. The format will be projects/`project_number`/feeds/`client-
188
+ # assigned_feed_identifier` or folders/`folder_number`/feeds/`client-
189
+ # assigned_feed_identifier` or organizations/`organization_number`/feeds/`client-
190
+ # assigned_feed_identifier` The client-assigned feed identifier must be unique
191
+ # within the parent project/folder/organization.
192
+ # @param [Google::Apis::CloudassetV1::UpdateFeedRequest] update_feed_request_object
193
+ # @param [String] fields
194
+ # Selector specifying which fields to include in a partial response.
195
+ # @param [String] quota_user
196
+ # Available to use for quota purposes for server-side applications. Can be any
197
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
198
+ # @param [Google::Apis::RequestOptions] options
199
+ # Request-specific options
200
+ #
201
+ # @yield [result, err] Result & error if block supplied
202
+ # @yieldparam result [Google::Apis::CloudassetV1::Feed] parsed result object
203
+ # @yieldparam err [StandardError] error object if request failed
204
+ #
205
+ # @return [Google::Apis::CloudassetV1::Feed]
206
+ #
207
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
208
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
209
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
210
+ def patch_feed(name, update_feed_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
211
+ command = make_simple_command(:patch, 'v1/{+name}', options)
212
+ command.request_representation = Google::Apis::CloudassetV1::UpdateFeedRequest::Representation
213
+ command.request_object = update_feed_request_object
214
+ command.response_representation = Google::Apis::CloudassetV1::Feed::Representation
215
+ command.response_class = Google::Apis::CloudassetV1::Feed
216
+ command.params['name'] = name unless name.nil?
217
+ command.query['fields'] = fields unless fields.nil?
218
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
219
+ execute_or_queue_command(command, &block)
220
+ end
221
+
222
+ # Gets the latest state of a long-running operation. Clients can use this method
223
+ # to poll the operation result at intervals as recommended by the API service.
224
+ # @param [String] name
225
+ # The name of the operation resource.
226
+ # @param [String] fields
227
+ # Selector specifying which fields to include in a partial response.
228
+ # @param [String] quota_user
229
+ # Available to use for quota purposes for server-side applications. Can be any
230
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
231
+ # @param [Google::Apis::RequestOptions] options
232
+ # Request-specific options
233
+ #
234
+ # @yield [result, err] Result & error if block supplied
235
+ # @yieldparam result [Google::Apis::CloudassetV1::Operation] parsed result object
236
+ # @yieldparam err [StandardError] error object if request failed
237
+ #
238
+ # @return [Google::Apis::CloudassetV1::Operation]
239
+ #
240
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
241
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
242
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
243
+ def get_operation(name, fields: nil, quota_user: nil, options: nil, &block)
244
+ command = make_simple_command(:get, 'v1/{+name}', options)
245
+ command.response_representation = Google::Apis::CloudassetV1::Operation::Representation
246
+ command.response_class = Google::Apis::CloudassetV1::Operation
247
+ command.params['name'] = name unless name.nil?
248
+ command.query['fields'] = fields unless fields.nil?
249
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
250
+ execute_or_queue_command(command, &block)
251
+ end
252
+
253
+ # Analyzes IAM policies to answer which identities have what accesses on which
254
+ # resources.
255
+ # @param [String] scope
256
+ # Required. The relative name of the root asset. Only resources and IAM policies
257
+ # within the scope will be analyzed. This can only be an organization number (
258
+ # such as "organizations/123"), a folder number (such as "folders/123"), a
259
+ # project ID (such as "projects/my-project-id"), or a project number (such as "
260
+ # projects/12345"). To know how to get organization id, visit [here ](https://
261
+ # cloud.google.com/resource-manager/docs/creating-managing-organization#
262
+ # retrieving_your_organization_id). To know how to get folder or project id,
263
+ # visit [here ](https://cloud.google.com/resource-manager/docs/creating-managing-
264
+ # folders#viewing_or_listing_folders_and_projects).
265
+ # @param [Array<String>, String] analysis_query_access_selector_permissions
266
+ # Optional. The permissions to appear in result.
267
+ # @param [Array<String>, String] analysis_query_access_selector_roles
268
+ # Optional. The roles to appear in result.
269
+ # @param [String] analysis_query_identity_selector_identity
270
+ # Required. The identity appear in the form of members in [IAM policy binding](
271
+ # https://cloud.google.com/iam/reference/rest/v1/Binding). The examples of
272
+ # supported forms are: "user:mike@example.com", "group:admins@example.com", "
273
+ # domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com".
274
+ # Notice that wildcard characters (such as * and ?) are not supported. You must
275
+ # give a specific identity.
276
+ # @param [Boolean] analysis_query_options_analyze_service_account_impersonation
277
+ # Optional. If true, the response will include access analysis from identities
278
+ # to resources via service account impersonation. This is a very expensive
279
+ # operation, because many derived queries will be executed. We highly recommend
280
+ # you use AssetService.AnalyzeIamPolicyLongrunning rpc instead. For example, if
281
+ # the request analyzes for which resources user A has permission P, and there's
282
+ # an IAM policy states user A has iam.serviceAccounts.getAccessToken permission
283
+ # to a service account SA, and there's another IAM policy states service account
284
+ # SA has permission P to a GCP folder F, then user A potentially has access to
285
+ # the GCP folder F. And those advanced analysis results will be included in
286
+ # AnalyzeIamPolicyResponse.service_account_impersonation_analysis. Another
287
+ # example, if the request analyzes for who has permission P to a GCP folder F,
288
+ # and there's an IAM policy states user A has iam.serviceAccounts.actAs
289
+ # permission to a service account SA, and there's another IAM policy states
290
+ # service account SA has permission P to the GCP folder F, then user A
291
+ # potentially has access to the GCP folder F. And those advanced analysis
292
+ # results will be included in AnalyzeIamPolicyResponse.
293
+ # service_account_impersonation_analysis. Default is false.
294
+ # @param [Boolean] analysis_query_options_expand_groups
295
+ # Optional. If true, the identities section of the result will expand any Google
296
+ # groups appearing in an IAM policy binding. If IamPolicyAnalysisQuery.
297
+ # identity_selector is specified, the identity in the result will be determined
298
+ # by the selector, and this flag is not allowed to set. Default is false.
299
+ # @param [Boolean] analysis_query_options_expand_resources
300
+ # Optional. If true and IamPolicyAnalysisQuery.resource_selector is not
301
+ # specified, the resource section of the result will expand any resource
302
+ # attached to an IAM policy to include resources lower in the resource hierarchy.
303
+ # For example, if the request analyzes for which resources user A has
304
+ # permission P, and the results include an IAM policy with P on a GCP folder,
305
+ # the results will also include resources in that folder with permission P. If
306
+ # true and IamPolicyAnalysisQuery.resource_selector is specified, the resource
307
+ # section of the result will expand the specified resource to include resources
308
+ # lower in the resource hierarchy. Only project or lower resources are supported.
309
+ # Folder and organization resource cannot be used together with this option.
310
+ # For example, if the request analyzes for which users have permission P on a
311
+ # GCP project with this option enabled, the results will include all users who
312
+ # have permission P on that project or any lower resource. Default is false.
313
+ # @param [Boolean] analysis_query_options_expand_roles
314
+ # Optional. If true, the access section of result will expand any roles
315
+ # appearing in IAM policy bindings to include their permissions. If
316
+ # IamPolicyAnalysisQuery.access_selector is specified, the access section of the
317
+ # result will be determined by the selector, and this flag is not allowed to set.
318
+ # Default is false.
319
+ # @param [Boolean] analysis_query_options_output_group_edges
320
+ # Optional. If true, the result will output group identity edges, starting from
321
+ # the binding's group members, to any expanded identities. Default is false.
322
+ # @param [Boolean] analysis_query_options_output_resource_edges
323
+ # Optional. If true, the result will output resource edges, starting from the
324
+ # policy attached resource, to any expanded resources. Default is false.
325
+ # @param [String] analysis_query_resource_selector_full_resource_name
326
+ # Required. The [full resource name] (https://cloud.google.com/asset-inventory/
327
+ # docs/resource-name-format) of a resource of [supported resource types](https://
328
+ # cloud.google.com/asset-inventory/docs/supported-asset-types#
329
+ # analyzable_asset_types).
330
+ # @param [String] execution_timeout
331
+ # Optional. Amount of time executable has to complete. See JSON representation
332
+ # of [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json).
333
+ # If this field is set with a value less than the RPC deadline, and the
334
+ # execution of your query hasn't finished in the specified execution timeout,
335
+ # you will get a response with partial result. Otherwise, your query's execution
336
+ # will continue until the RPC deadline. If it's not finished until then, you
337
+ # will get a DEADLINE_EXCEEDED error. Default is empty.
338
+ # @param [String] fields
339
+ # Selector specifying which fields to include in a partial response.
340
+ # @param [String] quota_user
341
+ # Available to use for quota purposes for server-side applications. Can be any
342
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
343
+ # @param [Google::Apis::RequestOptions] options
344
+ # Request-specific options
345
+ #
346
+ # @yield [result, err] Result & error if block supplied
347
+ # @yieldparam result [Google::Apis::CloudassetV1::AnalyzeIamPolicyResponse] parsed result object
348
+ # @yieldparam err [StandardError] error object if request failed
349
+ #
350
+ # @return [Google::Apis::CloudassetV1::AnalyzeIamPolicyResponse]
351
+ #
352
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
353
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
354
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
355
+ def analyze_iam_policy(scope, analysis_query_access_selector_permissions: nil, analysis_query_access_selector_roles: nil, analysis_query_identity_selector_identity: nil, analysis_query_options_analyze_service_account_impersonation: nil, analysis_query_options_expand_groups: nil, analysis_query_options_expand_resources: nil, analysis_query_options_expand_roles: nil, analysis_query_options_output_group_edges: nil, analysis_query_options_output_resource_edges: nil, analysis_query_resource_selector_full_resource_name: nil, execution_timeout: nil, fields: nil, quota_user: nil, options: nil, &block)
356
+ command = make_simple_command(:get, 'v1/{+scope}:analyzeIamPolicy', options)
357
+ command.response_representation = Google::Apis::CloudassetV1::AnalyzeIamPolicyResponse::Representation
358
+ command.response_class = Google::Apis::CloudassetV1::AnalyzeIamPolicyResponse
359
+ command.params['scope'] = scope unless scope.nil?
360
+ command.query['analysisQuery.accessSelector.permissions'] = analysis_query_access_selector_permissions unless analysis_query_access_selector_permissions.nil?
361
+ command.query['analysisQuery.accessSelector.roles'] = analysis_query_access_selector_roles unless analysis_query_access_selector_roles.nil?
362
+ command.query['analysisQuery.identitySelector.identity'] = analysis_query_identity_selector_identity unless analysis_query_identity_selector_identity.nil?
363
+ command.query['analysisQuery.options.analyzeServiceAccountImpersonation'] = analysis_query_options_analyze_service_account_impersonation unless analysis_query_options_analyze_service_account_impersonation.nil?
364
+ command.query['analysisQuery.options.expandGroups'] = analysis_query_options_expand_groups unless analysis_query_options_expand_groups.nil?
365
+ command.query['analysisQuery.options.expandResources'] = analysis_query_options_expand_resources unless analysis_query_options_expand_resources.nil?
366
+ command.query['analysisQuery.options.expandRoles'] = analysis_query_options_expand_roles unless analysis_query_options_expand_roles.nil?
367
+ command.query['analysisQuery.options.outputGroupEdges'] = analysis_query_options_output_group_edges unless analysis_query_options_output_group_edges.nil?
368
+ command.query['analysisQuery.options.outputResourceEdges'] = analysis_query_options_output_resource_edges unless analysis_query_options_output_resource_edges.nil?
369
+ command.query['analysisQuery.resourceSelector.fullResourceName'] = analysis_query_resource_selector_full_resource_name unless analysis_query_resource_selector_full_resource_name.nil?
370
+ command.query['executionTimeout'] = execution_timeout unless execution_timeout.nil?
371
+ command.query['fields'] = fields unless fields.nil?
372
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
373
+ execute_or_queue_command(command, &block)
374
+ end
375
+
376
+ # Analyzes IAM policies asynchronously to answer which identities have what
377
+ # accesses on which resources, and writes the analysis results to a Google Cloud
378
+ # Storage or a BigQuery destination. For Cloud Storage destination, the output
379
+ # format is the JSON format that represents a AnalyzeIamPolicyResponse. This
380
+ # method implements the google.longrunning.Operation, which allows you to track
381
+ # the operation status. We recommend intervals of at least 2 seconds with
382
+ # exponential backoff retry to poll the operation result. The metadata contains
383
+ # the request to help callers to map responses to requests.
384
+ # @param [String] scope
385
+ # Required. The relative name of the root asset. Only resources and IAM policies
386
+ # within the scope will be analyzed. This can only be an organization number (
387
+ # such as "organizations/123"), a folder number (such as "folders/123"), a
388
+ # project ID (such as "projects/my-project-id"), or a project number (such as "
389
+ # projects/12345"). To know how to get organization id, visit [here ](https://
390
+ # cloud.google.com/resource-manager/docs/creating-managing-organization#
391
+ # retrieving_your_organization_id). To know how to get folder or project id,
392
+ # visit [here ](https://cloud.google.com/resource-manager/docs/creating-managing-
393
+ # folders#viewing_or_listing_folders_and_projects).
394
+ # @param [Google::Apis::CloudassetV1::AnalyzeIamPolicyLongrunningRequest] analyze_iam_policy_longrunning_request_object
395
+ # @param [String] fields
396
+ # Selector specifying which fields to include in a partial response.
397
+ # @param [String] quota_user
398
+ # Available to use for quota purposes for server-side applications. Can be any
399
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
400
+ # @param [Google::Apis::RequestOptions] options
401
+ # Request-specific options
402
+ #
403
+ # @yield [result, err] Result & error if block supplied
404
+ # @yieldparam result [Google::Apis::CloudassetV1::Operation] parsed result object
405
+ # @yieldparam err [StandardError] error object if request failed
406
+ #
407
+ # @return [Google::Apis::CloudassetV1::Operation]
408
+ #
409
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
410
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
411
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
412
+ def analyze_iam_policy_longrunning(scope, analyze_iam_policy_longrunning_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
413
+ command = make_simple_command(:post, 'v1/{+scope}:analyzeIamPolicyLongrunning', options)
414
+ command.request_representation = Google::Apis::CloudassetV1::AnalyzeIamPolicyLongrunningRequest::Representation
415
+ command.request_object = analyze_iam_policy_longrunning_request_object
416
+ command.response_representation = Google::Apis::CloudassetV1::Operation::Representation
417
+ command.response_class = Google::Apis::CloudassetV1::Operation
418
+ command.params['scope'] = scope unless scope.nil?
419
+ command.query['fields'] = fields unless fields.nil?
420
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
421
+ execute_or_queue_command(command, &block)
422
+ end
423
+
424
+ # Batch gets the update history of assets that overlap a time window. For
425
+ # IAM_POLICY content, this API outputs history when the asset and its attached
426
+ # IAM POLICY both exist. This can create gaps in the output history. Otherwise,
427
+ # this API outputs history with asset in both non-delete or deleted status. If a
428
+ # specified asset does not exist, this API returns an INVALID_ARGUMENT error.
429
+ # @param [String] parent
430
+ # Required. The relative name of the root asset. It can only be an organization
431
+ # number (such as "organizations/123"), a project ID (such as "projects/my-
432
+ # project-id")", or a project number (such as "projects/12345").
433
+ # @param [Array<String>, String] asset_names
434
+ # A list of the full names of the assets. See: https://cloud.google.com/asset-
435
+ # inventory/docs/resource-name-format Example: `//compute.googleapis.com/
436
+ # projects/my_project_123/zones/zone1/instances/instance1`. The request becomes
437
+ # a no-op if the asset name list is empty, and the max size of the asset name
438
+ # list is 100 in one request.
439
+ # @param [String] content_type
440
+ # Optional. The content type.
441
+ # @param [String] read_time_window_end_time
442
+ # End time of the time window (inclusive). If not specified, the current
443
+ # timestamp is used instead.
444
+ # @param [String] read_time_window_start_time
445
+ # Start time of the time window (exclusive).
446
+ # @param [String] fields
447
+ # Selector specifying which fields to include in a partial response.
448
+ # @param [String] quota_user
449
+ # Available to use for quota purposes for server-side applications. Can be any
450
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
451
+ # @param [Google::Apis::RequestOptions] options
452
+ # Request-specific options
453
+ #
454
+ # @yield [result, err] Result & error if block supplied
455
+ # @yieldparam result [Google::Apis::CloudassetV1::BatchGetAssetsHistoryResponse] parsed result object
456
+ # @yieldparam err [StandardError] error object if request failed
457
+ #
458
+ # @return [Google::Apis::CloudassetV1::BatchGetAssetsHistoryResponse]
459
+ #
460
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
461
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
462
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
463
+ def batch_get_assets_history(parent, asset_names: nil, content_type: nil, read_time_window_end_time: nil, read_time_window_start_time: nil, fields: nil, quota_user: nil, options: nil, &block)
464
+ command = make_simple_command(:get, 'v1/{+parent}:batchGetAssetsHistory', options)
465
+ command.response_representation = Google::Apis::CloudassetV1::BatchGetAssetsHistoryResponse::Representation
466
+ command.response_class = Google::Apis::CloudassetV1::BatchGetAssetsHistoryResponse
467
+ command.params['parent'] = parent unless parent.nil?
468
+ command.query['assetNames'] = asset_names unless asset_names.nil?
469
+ command.query['contentType'] = content_type unless content_type.nil?
470
+ command.query['readTimeWindow.endTime'] = read_time_window_end_time unless read_time_window_end_time.nil?
471
+ command.query['readTimeWindow.startTime'] = read_time_window_start_time unless read_time_window_start_time.nil?
472
+ command.query['fields'] = fields unless fields.nil?
473
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
474
+ execute_or_queue_command(command, &block)
475
+ end
476
+
477
+ # Exports assets with time and resource types to a given Cloud Storage location/
478
+ # BigQuery table. For Cloud Storage location destinations, the output format is
479
+ # newline-delimited JSON. Each line represents a google.cloud.asset.v1.Asset in
480
+ # the JSON format; for BigQuery table destinations, the output table stores the
481
+ # fields in asset proto as columns. This API implements the google.longrunning.
482
+ # Operation API , which allows you to keep track of the export. We recommend
483
+ # intervals of at least 2 seconds with exponential retry to poll the export
484
+ # operation result. For regular-size resource parent, the export operation
485
+ # usually finishes within 5 minutes.
486
+ # @param [String] parent
487
+ # Required. The relative name of the root asset. This can only be an
488
+ # organization number (such as "organizations/123"), a project ID (such as "
489
+ # projects/my-project-id"), or a project number (such as "projects/12345"), or a
490
+ # folder number (such as "folders/123").
491
+ # @param [Google::Apis::CloudassetV1::ExportAssetsRequest] export_assets_request_object
492
+ # @param [String] fields
493
+ # Selector specifying which fields to include in a partial response.
494
+ # @param [String] quota_user
495
+ # Available to use for quota purposes for server-side applications. Can be any
496
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
497
+ # @param [Google::Apis::RequestOptions] options
498
+ # Request-specific options
499
+ #
500
+ # @yield [result, err] Result & error if block supplied
501
+ # @yieldparam result [Google::Apis::CloudassetV1::Operation] parsed result object
502
+ # @yieldparam err [StandardError] error object if request failed
503
+ #
504
+ # @return [Google::Apis::CloudassetV1::Operation]
505
+ #
506
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
507
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
508
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
509
+ def export_assets(parent, export_assets_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
510
+ command = make_simple_command(:post, 'v1/{+parent}:exportAssets', options)
511
+ command.request_representation = Google::Apis::CloudassetV1::ExportAssetsRequest::Representation
512
+ command.request_object = export_assets_request_object
513
+ command.response_representation = Google::Apis::CloudassetV1::Operation::Representation
514
+ command.response_class = Google::Apis::CloudassetV1::Operation
515
+ command.params['parent'] = parent unless parent.nil?
516
+ command.query['fields'] = fields unless fields.nil?
517
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
518
+ execute_or_queue_command(command, &block)
519
+ end
520
+
521
+ # Searches all IAM policies within the specified scope, such as a project,
522
+ # folder, or organization. The caller must be granted the `cloudasset.assets.
523
+ # searchAllIamPolicies` permission on the desired scope, otherwise the request
524
+ # will be rejected.
525
+ # @param [String] scope
526
+ # Required. A scope can be a project, a folder, or an organization. The search
527
+ # is limited to the IAM policies within the `scope`. The caller must be granted
528
+ # the [`cloudasset.assets.searchAllIamPolicies`](http://cloud.google.com/asset-
529
+ # inventory/docs/access-control#required_permissions) permission on the desired
530
+ # scope. The allowed values are: * projects/`PROJECT_ID` (e.g., "projects/foo-
531
+ # bar") * projects/`PROJECT_NUMBER` (e.g., "projects/12345678") * folders/`
532
+ # FOLDER_NUMBER` (e.g., "folders/1234567") * organizations/`ORGANIZATION_NUMBER`
533
+ # (e.g., "organizations/123456")
534
+ # @param [Fixnum] page_size
535
+ # Optional. The page size for search result pagination. Page size is capped at
536
+ # 500 even if a larger value is given. If set to zero, server will pick an
537
+ # appropriate default. Returned results may be fewer than requested. When this
538
+ # happens, there could be more results as long as `next_page_token` is returned.
539
+ # @param [String] page_token
540
+ # Optional. If present, retrieve the next batch of results from the preceding
541
+ # call to this method. `page_token` must be the value of `next_page_token` from
542
+ # the previous response. The values of all other method parameters must be
543
+ # identical to those in the previous call.
544
+ # @param [String] query
545
+ # Optional. The query statement. See [how to construct a query](https://cloud.
546
+ # google.com/asset-inventory/docs/searching-iam-policies#
547
+ # how_to_construct_a_query) for more information. If not specified or empty, it
548
+ # will search all the IAM policies within the specified `scope`. Note that the
549
+ # query string is compared against each Cloud IAM policy binding, including its
550
+ # members, roles, and Cloud IAM conditions. The returned Cloud IAM policies will
551
+ # only contain the bindings that match your query. To learn more about the IAM
552
+ # policy structure, see [IAM policy doc](https://cloud.google.com/iam/docs/
553
+ # policies#structure). Examples: * `policy:amy@gmail.com` to find IAM policy
554
+ # bindings that specify user "amy@gmail.com". * `policy:roles/compute.admin` to
555
+ # find IAM policy bindings that specify the Compute Admin role. * `policy.role.
556
+ # permissions:storage.buckets.update` to find IAM policy bindings that specify a
557
+ # role containing "storage.buckets.update" permission. Note that if callers don'
558
+ # t have `iam.roles.get` access to a role's included permissions, policy
559
+ # bindings that specify this role will be dropped from the search results. * `
560
+ # resource:organizations/123456` to find IAM policy bindings that are set on "
561
+ # organizations/123456". * `resource=//cloudresourcemanager.googleapis.com/
562
+ # projects/myproject` to find IAM policy bindings that are set on the project
563
+ # named "myproject". * `Important` to find IAM policy bindings that contain "
564
+ # Important" as a word in any of the searchable fields (except for the included
565
+ # permissions). * `*por*` to find IAM policy bindings that contain "por" as a
566
+ # substring in any of the searchable fields (except for the included permissions)
567
+ # . * `resource:(instance1 OR instance2) policy:amy` to find IAM policy bindings
568
+ # that are set on resources "instance1" or "instance2" and also specify user "
569
+ # amy".
570
+ # @param [String] fields
571
+ # Selector specifying which fields to include in a partial response.
572
+ # @param [String] quota_user
573
+ # Available to use for quota purposes for server-side applications. Can be any
574
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
575
+ # @param [Google::Apis::RequestOptions] options
576
+ # Request-specific options
577
+ #
578
+ # @yield [result, err] Result & error if block supplied
579
+ # @yieldparam result [Google::Apis::CloudassetV1::SearchAllIamPoliciesResponse] parsed result object
580
+ # @yieldparam err [StandardError] error object if request failed
581
+ #
582
+ # @return [Google::Apis::CloudassetV1::SearchAllIamPoliciesResponse]
583
+ #
584
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
585
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
586
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
587
+ def search_all_iam_policies(scope, page_size: nil, page_token: nil, query: nil, fields: nil, quota_user: nil, options: nil, &block)
588
+ command = make_simple_command(:get, 'v1/{+scope}:searchAllIamPolicies', options)
589
+ command.response_representation = Google::Apis::CloudassetV1::SearchAllIamPoliciesResponse::Representation
590
+ command.response_class = Google::Apis::CloudassetV1::SearchAllIamPoliciesResponse
591
+ command.params['scope'] = scope unless scope.nil?
592
+ command.query['pageSize'] = page_size unless page_size.nil?
593
+ command.query['pageToken'] = page_token unless page_token.nil?
594
+ command.query['query'] = query unless query.nil?
595
+ command.query['fields'] = fields unless fields.nil?
596
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
597
+ execute_or_queue_command(command, &block)
598
+ end
599
+
600
+ # Searches all Cloud resources within the specified scope, such as a project,
601
+ # folder, or organization. The caller must be granted the `cloudasset.assets.
602
+ # searchAllResources` permission on the desired scope, otherwise the request
603
+ # will be rejected.
604
+ # @param [String] scope
605
+ # Required. A scope can be a project, a folder, or an organization. The search
606
+ # is limited to the resources within the `scope`. The caller must be granted the
607
+ # [`cloudasset.assets.searchAllResources`](http://cloud.google.com/asset-
608
+ # inventory/docs/access-control#required_permissions) permission on the desired
609
+ # scope. The allowed values are: * projects/`PROJECT_ID` (e.g., "projects/foo-
610
+ # bar") * projects/`PROJECT_NUMBER` (e.g., "projects/12345678") * folders/`
611
+ # FOLDER_NUMBER` (e.g., "folders/1234567") * organizations/`ORGANIZATION_NUMBER`
612
+ # (e.g., "organizations/123456")
613
+ # @param [Array<String>, String] asset_types
614
+ # Optional. A list of asset types that this request searches for. If empty, it
615
+ # will search all the [searchable asset types](https://cloud.google.com/asset-
616
+ # inventory/docs/supported-asset-types#searchable_asset_types). Regular
617
+ # expressions are also supported. For example: * "compute.googleapis.com.*"
618
+ # snapshots resources whose asset type starts with "compute.googleapis.com". * ".
619
+ # *Instance" snapshots resources whose asset type ends with "Instance". * ".*
620
+ # Instance.*" snapshots resources whose asset type contains "Instance". See [RE2]
621
+ # (https://github.com/google/re2/wiki/Syntax) for all supported regular
622
+ # expression syntax. If the regular expression does not match any supported
623
+ # asset type, an INVALID_ARGUMENT error will be returned.
624
+ # @param [String] order_by
625
+ # Optional. A comma separated list of fields specifying the sorting order of the
626
+ # results. The default order is ascending. Add " DESC" after the field name to
627
+ # indicate descending order. Redundant space characters are ignored. Example: "
628
+ # location DESC, name". Only string fields in the response are sortable,
629
+ # including `name`, `displayName`, `description`, `location`. All the other
630
+ # fields such as repeated fields (e.g., `networkTags`), map fields (e.g., `
631
+ # labels`) and struct fields (e.g., `additionalAttributes`) are not supported.
632
+ # @param [Fixnum] page_size
633
+ # Optional. The page size for search result pagination. Page size is capped at
634
+ # 500 even if a larger value is given. If set to zero, server will pick an
635
+ # appropriate default. Returned results may be fewer than requested. When this
636
+ # happens, there could be more results as long as `next_page_token` is returned.
637
+ # @param [String] page_token
638
+ # Optional. If present, then retrieve the next batch of results from the
639
+ # preceding call to this method. `page_token` must be the value of `
640
+ # next_page_token` from the previous response. The values of all other method
641
+ # parameters, must be identical to those in the previous call.
642
+ # @param [String] query
643
+ # Optional. The query statement. See [how to construct a query](http://cloud.
644
+ # google.com/asset-inventory/docs/searching-resources#how_to_construct_a_query)
645
+ # for more information. If not specified or empty, it will search all the
646
+ # resources within the specified `scope`. Examples: * `name:Important` to find
647
+ # Cloud resources whose name contains "Important" as a word. * `name=Important`
648
+ # to find the Cloud resource whose name is exactly "Important". * `displayName:
649
+ # Impor*` to find Cloud resources whose display name contains "Impor" as a
650
+ # prefix. * `description:*por*` to find Cloud resources whose description
651
+ # contains "por" as a substring. * `location:us-west*` to find Cloud resources
652
+ # whose location is prefixed with "us-west". * `labels:prod` to find Cloud
653
+ # resources whose labels contain "prod" as a key or value. * `labels.env:prod`
654
+ # to find Cloud resources that have a label "env" and its value is "prod". * `
655
+ # labels.env:*` to find Cloud resources that have a label "env". * `Important`
656
+ # to find Cloud resources that contain "Important" as a word in any of the
657
+ # searchable fields. * `Impor*` to find Cloud resources that contain "Impor" as
658
+ # a prefix in any of the searchable fields. * `*por*` to find Cloud resources
659
+ # that contain "por" as a substring in any of the searchable fields. * `
660
+ # Important location:(us-west1 OR global)` to find Cloud resources that contain "
661
+ # Important" as a word in any of the searchable fields and are also located in
662
+ # the "us-west1" region or the "global" location.
663
+ # @param [String] fields
664
+ # Selector specifying which fields to include in a partial response.
665
+ # @param [String] quota_user
666
+ # Available to use for quota purposes for server-side applications. Can be any
667
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
668
+ # @param [Google::Apis::RequestOptions] options
669
+ # Request-specific options
670
+ #
671
+ # @yield [result, err] Result & error if block supplied
672
+ # @yieldparam result [Google::Apis::CloudassetV1::SearchAllResourcesResponse] parsed result object
673
+ # @yieldparam err [StandardError] error object if request failed
674
+ #
675
+ # @return [Google::Apis::CloudassetV1::SearchAllResourcesResponse]
676
+ #
677
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
678
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
679
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
680
+ def search_all_resources(scope, asset_types: nil, order_by: nil, page_size: nil, page_token: nil, query: nil, fields: nil, quota_user: nil, options: nil, &block)
681
+ command = make_simple_command(:get, 'v1/{+scope}:searchAllResources', options)
682
+ command.response_representation = Google::Apis::CloudassetV1::SearchAllResourcesResponse::Representation
683
+ command.response_class = Google::Apis::CloudassetV1::SearchAllResourcesResponse
684
+ command.params['scope'] = scope unless scope.nil?
685
+ command.query['assetTypes'] = asset_types unless asset_types.nil?
686
+ command.query['orderBy'] = order_by unless order_by.nil?
687
+ command.query['pageSize'] = page_size unless page_size.nil?
688
+ command.query['pageToken'] = page_token unless page_token.nil?
689
+ command.query['query'] = query unless query.nil?
690
+ command.query['fields'] = fields unless fields.nil?
691
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
692
+ execute_or_queue_command(command, &block)
693
+ end
694
+
695
+ protected
696
+
697
+ def apply_command_defaults(command)
698
+ command.query['key'] = key unless key.nil?
699
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
700
+ end
701
+ end
702
+ end
703
+ end
704
+ end