Debian Codegraph @

asset/apiv1/asset_client.go

raw
1 // Copyright 2025 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 // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17 package asset
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 assetpb "cloud.google.com/go/asset/apiv1/assetpb"
30 "cloud.google.com/go/longrunning"
31 lroauto "cloud.google.com/go/longrunning/autogen"
32 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
33 gax "github.com/googleapis/gax-go/v2"
34 "google.golang.org/api/iterator"
35 "google.golang.org/api/option"
36 "google.golang.org/api/option/internaloption"
37 gtransport "google.golang.org/api/transport/grpc"
38 httptransport "google.golang.org/api/transport/http"
39 "google.golang.org/grpc"
40 "google.golang.org/grpc/codes"
41 "google.golang.org/protobuf/encoding/protojson"
42 "google.golang.org/protobuf/proto"
43 )
44
45 var newClientHook clientHook
46
47 // CallOptions contains the retry settings for each method of Client.
48 type CallOptions struct {
49 ExportAssets []gax.CallOption
50 ListAssets []gax.CallOption
51 BatchGetAssetsHistory []gax.CallOption
52 CreateFeed []gax.CallOption
53 GetFeed []gax.CallOption
54 ListFeeds []gax.CallOption
55 UpdateFeed []gax.CallOption
56 DeleteFeed []gax.CallOption
57 SearchAllResources []gax.CallOption
58 SearchAllIamPolicies []gax.CallOption
59 AnalyzeIamPolicy []gax.CallOption
60 AnalyzeIamPolicyLongrunning []gax.CallOption
61 AnalyzeMove []gax.CallOption
62 QueryAssets []gax.CallOption
63 CreateSavedQuery []gax.CallOption
64 GetSavedQuery []gax.CallOption
65 ListSavedQueries []gax.CallOption
66 UpdateSavedQuery []gax.CallOption
67 DeleteSavedQuery []gax.CallOption
68 BatchGetEffectiveIamPolicies []gax.CallOption
69 AnalyzeOrgPolicies []gax.CallOption
70 AnalyzeOrgPolicyGovernedContainers []gax.CallOption
71 AnalyzeOrgPolicyGovernedAssets []gax.CallOption
72 GetOperation []gax.CallOption
73 }
74
75 func defaultGRPCClientOptions() []option.ClientOption {
76 return []option.ClientOption{
77 internaloption.WithDefaultEndpoint("cloudasset.googleapis.com:443"),
78 internaloption.WithDefaultEndpointTemplate("cloudasset.UNIVERSE_DOMAIN:443"),
79 internaloption.WithDefaultMTLSEndpoint("cloudasset.mtls.googleapis.com:443"),
80 internaloption.WithDefaultUniverseDomain("googleapis.com"),
81 internaloption.WithDefaultAudience("https://cloudasset.googleapis.com/"),
82 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
83 internaloption.EnableJwtWithScope(),
84 internaloption.EnableNewAuthLibrary(),
85 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
86 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
87 }
88 }
89
90 func defaultCallOptions() *CallOptions {
91 return &CallOptions{
92 ExportAssets: []gax.CallOption{
93 gax.WithTimeout(60000 * time.Millisecond),
94 },
95 ListAssets: []gax.CallOption{
96 gax.WithTimeout(60000 * time.Millisecond),
97 gax.WithRetry(func() gax.Retryer {
98 return gax.OnCodes([]codes.Code{
99 codes.DeadlineExceeded,
100 codes.Unavailable,
101 }, gax.Backoff{
102 Initial: 100 * time.Millisecond,
103 Max: 60000 * time.Millisecond,
104 Multiplier: 1.30,
105 })
106 }),
107 },
108 BatchGetAssetsHistory: []gax.CallOption{
109 gax.WithTimeout(60000 * time.Millisecond),
110 gax.WithRetry(func() gax.Retryer {
111 return gax.OnCodes([]codes.Code{
112 codes.DeadlineExceeded,
113 codes.Unavailable,
114 }, gax.Backoff{
115 Initial: 100 * time.Millisecond,
116 Max: 60000 * time.Millisecond,
117 Multiplier: 1.30,
118 })
119 }),
120 },
121 CreateFeed: []gax.CallOption{
122 gax.WithTimeout(60000 * time.Millisecond),
123 },
124 GetFeed: []gax.CallOption{
125 gax.WithTimeout(60000 * time.Millisecond),
126 gax.WithRetry(func() gax.Retryer {
127 return gax.OnCodes([]codes.Code{
128 codes.DeadlineExceeded,
129 codes.Unavailable,
130 }, gax.Backoff{
131 Initial: 100 * time.Millisecond,
132 Max: 60000 * time.Millisecond,
133 Multiplier: 1.30,
134 })
135 }),
136 },
137 ListFeeds: []gax.CallOption{
138 gax.WithTimeout(60000 * time.Millisecond),
139 gax.WithRetry(func() gax.Retryer {
140 return gax.OnCodes([]codes.Code{
141 codes.DeadlineExceeded,
142 codes.Unavailable,
143 }, gax.Backoff{
144 Initial: 100 * time.Millisecond,
145 Max: 60000 * time.Millisecond,
146 Multiplier: 1.30,
147 })
148 }),
149 },
150 UpdateFeed: []gax.CallOption{
151 gax.WithTimeout(60000 * time.Millisecond),
152 },
153 DeleteFeed: []gax.CallOption{
154 gax.WithTimeout(60000 * time.Millisecond),
155 gax.WithRetry(func() gax.Retryer {
156 return gax.OnCodes([]codes.Code{
157 codes.DeadlineExceeded,
158 codes.Unavailable,
159 }, gax.Backoff{
160 Initial: 100 * time.Millisecond,
161 Max: 60000 * time.Millisecond,
162 Multiplier: 1.30,
163 })
164 }),
165 },
166 SearchAllResources: []gax.CallOption{
167 gax.WithTimeout(30000 * time.Millisecond),
168 gax.WithRetry(func() gax.Retryer {
169 return gax.OnCodes([]codes.Code{
170 codes.Unavailable,
171 }, gax.Backoff{
172 Initial: 100 * time.Millisecond,
173 Max: 60000 * time.Millisecond,
174 Multiplier: 1.30,
175 })
176 }),
177 },
178 SearchAllIamPolicies: []gax.CallOption{
179 gax.WithTimeout(30000 * time.Millisecond),
180 gax.WithRetry(func() gax.Retryer {
181 return gax.OnCodes([]codes.Code{
182 codes.Unavailable,
183 }, gax.Backoff{
184 Initial: 100 * time.Millisecond,
185 Max: 60000 * time.Millisecond,
186 Multiplier: 1.30,
187 })
188 }),
189 },
190 AnalyzeIamPolicy: []gax.CallOption{
191 gax.WithTimeout(300000 * time.Millisecond),
192 gax.WithRetry(func() gax.Retryer {
193 return gax.OnCodes([]codes.Code{
194 codes.Unavailable,
195 }, gax.Backoff{
196 Initial: 100 * time.Millisecond,
197 Max: 60000 * time.Millisecond,
198 Multiplier: 1.30,
199 })
200 }),
201 },
202 AnalyzeIamPolicyLongrunning: []gax.CallOption{
203 gax.WithTimeout(60000 * time.Millisecond),
204 },
205 AnalyzeMove: []gax.CallOption{},
206 QueryAssets: []gax.CallOption{
207 gax.WithTimeout(200000 * time.Millisecond),
208 gax.WithRetry(func() gax.Retryer {
209 return gax.OnCodes([]codes.Code{
210 codes.Unavailable,
211 }, gax.Backoff{
212 Initial: 100 * time.Millisecond,
213 Max: 60000 * time.Millisecond,
214 Multiplier: 1.30,
215 })
216 }),
217 },
218 CreateSavedQuery: []gax.CallOption{
219 gax.WithTimeout(60000 * time.Millisecond),
220 },
221 GetSavedQuery: []gax.CallOption{
222 gax.WithTimeout(60000 * time.Millisecond),
223 gax.WithRetry(func() gax.Retryer {
224 return gax.OnCodes([]codes.Code{
225 codes.DeadlineExceeded,
226 codes.Unavailable,
227 }, gax.Backoff{
228 Initial: 100 * time.Millisecond,
229 Max: 60000 * time.Millisecond,
230 Multiplier: 1.30,
231 })
232 }),
233 },
234 ListSavedQueries: []gax.CallOption{
235 gax.WithTimeout(60000 * time.Millisecond),
236 gax.WithRetry(func() gax.Retryer {
237 return gax.OnCodes([]codes.Code{
238 codes.DeadlineExceeded,
239 codes.Unavailable,
240 }, gax.Backoff{
241 Initial: 100 * time.Millisecond,
242 Max: 60000 * time.Millisecond,
243 Multiplier: 1.30,
244 })
245 }),
246 },
247 UpdateSavedQuery: []gax.CallOption{
248 gax.WithTimeout(60000 * time.Millisecond),
249 },
250 DeleteSavedQuery: []gax.CallOption{
251 gax.WithTimeout(60000 * time.Millisecond),
252 gax.WithRetry(func() gax.Retryer {
253 return gax.OnCodes([]codes.Code{
254 codes.DeadlineExceeded,
255 codes.Unavailable,
256 }, gax.Backoff{
257 Initial: 100 * time.Millisecond,
258 Max: 60000 * time.Millisecond,
259 Multiplier: 1.30,
260 })
261 }),
262 },
263 BatchGetEffectiveIamPolicies: []gax.CallOption{
264 gax.WithTimeout(300000 * time.Millisecond),
265 gax.WithRetry(func() gax.Retryer {
266 return gax.OnCodes([]codes.Code{
267 codes.Unavailable,
268 }, gax.Backoff{
269 Initial: 100 * time.Millisecond,
270 Max: 60000 * time.Millisecond,
271 Multiplier: 1.30,
272 })
273 }),
274 },
275 AnalyzeOrgPolicies: []gax.CallOption{
276 gax.WithTimeout(60000 * time.Millisecond),
277 gax.WithRetry(func() gax.Retryer {
278 return gax.OnCodes([]codes.Code{
279 codes.DeadlineExceeded,
280 codes.Unavailable,
281 }, gax.Backoff{
282 Initial: 100 * time.Millisecond,
283 Max: 60000 * time.Millisecond,
284 Multiplier: 1.30,
285 })
286 }),
287 },
288 AnalyzeOrgPolicyGovernedContainers: []gax.CallOption{
289 gax.WithTimeout(60000 * time.Millisecond),
290 gax.WithRetry(func() gax.Retryer {
291 return gax.OnCodes([]codes.Code{
292 codes.DeadlineExceeded,
293 codes.Unavailable,
294 }, gax.Backoff{
295 Initial: 100 * time.Millisecond,
296 Max: 60000 * time.Millisecond,
297 Multiplier: 1.30,
298 })
299 }),
300 },
301 AnalyzeOrgPolicyGovernedAssets: []gax.CallOption{
302 gax.WithTimeout(60000 * time.Millisecond),
303 gax.WithRetry(func() gax.Retryer {
304 return gax.OnCodes([]codes.Code{
305 codes.DeadlineExceeded,
306 codes.Unavailable,
307 }, gax.Backoff{
308 Initial: 100 * time.Millisecond,
309 Max: 60000 * time.Millisecond,
310 Multiplier: 1.30,
311 })
312 }),
313 },
314 GetOperation: []gax.CallOption{},
315 }
316 }
317
318 func defaultRESTCallOptions() *CallOptions {
319 return &CallOptions{
320 ExportAssets: []gax.CallOption{
321 gax.WithTimeout(60000 * time.Millisecond),
322 },
323 ListAssets: []gax.CallOption{
324 gax.WithTimeout(60000 * time.Millisecond),
325 gax.WithRetry(func() gax.Retryer {
326 return gax.OnHTTPCodes(gax.Backoff{
327 Initial: 100 * time.Millisecond,
328 Max: 60000 * time.Millisecond,
329 Multiplier: 1.30,
330 },
331 http.StatusGatewayTimeout,
332 http.StatusServiceUnavailable)
333 }),
334 },
335 BatchGetAssetsHistory: []gax.CallOption{
336 gax.WithTimeout(60000 * time.Millisecond),
337 gax.WithRetry(func() gax.Retryer {
338 return gax.OnHTTPCodes(gax.Backoff{
339 Initial: 100 * time.Millisecond,
340 Max: 60000 * time.Millisecond,
341 Multiplier: 1.30,
342 },
343 http.StatusGatewayTimeout,
344 http.StatusServiceUnavailable)
345 }),
346 },
347 CreateFeed: []gax.CallOption{
348 gax.WithTimeout(60000 * time.Millisecond),
349 },
350 GetFeed: []gax.CallOption{
351 gax.WithTimeout(60000 * time.Millisecond),
352 gax.WithRetry(func() gax.Retryer {
353 return gax.OnHTTPCodes(gax.Backoff{
354 Initial: 100 * time.Millisecond,
355 Max: 60000 * time.Millisecond,
356 Multiplier: 1.30,
357 },
358 http.StatusGatewayTimeout,
359 http.StatusServiceUnavailable)
360 }),
361 },
362 ListFeeds: []gax.CallOption{
363 gax.WithTimeout(60000 * time.Millisecond),
364 gax.WithRetry(func() gax.Retryer {
365 return gax.OnHTTPCodes(gax.Backoff{
366 Initial: 100 * time.Millisecond,
367 Max: 60000 * time.Millisecond,
368 Multiplier: 1.30,
369 },
370 http.StatusGatewayTimeout,
371 http.StatusServiceUnavailable)
372 }),
373 },
374 UpdateFeed: []gax.CallOption{
375 gax.WithTimeout(60000 * time.Millisecond),
376 },
377 DeleteFeed: []gax.CallOption{
378 gax.WithTimeout(60000 * time.Millisecond),
379 gax.WithRetry(func() gax.Retryer {
380 return gax.OnHTTPCodes(gax.Backoff{
381 Initial: 100 * time.Millisecond,
382 Max: 60000 * time.Millisecond,
383 Multiplier: 1.30,
384 },
385 http.StatusGatewayTimeout,
386 http.StatusServiceUnavailable)
387 }),
388 },
389 SearchAllResources: []gax.CallOption{
390 gax.WithTimeout(30000 * time.Millisecond),
391 gax.WithRetry(func() gax.Retryer {
392 return gax.OnHTTPCodes(gax.Backoff{
393 Initial: 100 * time.Millisecond,
394 Max: 60000 * time.Millisecond,
395 Multiplier: 1.30,
396 },
397 http.StatusServiceUnavailable)
398 }),
399 },
400 SearchAllIamPolicies: []gax.CallOption{
401 gax.WithTimeout(30000 * time.Millisecond),
402 gax.WithRetry(func() gax.Retryer {
403 return gax.OnHTTPCodes(gax.Backoff{
404 Initial: 100 * time.Millisecond,
405 Max: 60000 * time.Millisecond,
406 Multiplier: 1.30,
407 },
408 http.StatusServiceUnavailable)
409 }),
410 },
411 AnalyzeIamPolicy: []gax.CallOption{
412 gax.WithTimeout(300000 * time.Millisecond),
413 gax.WithRetry(func() gax.Retryer {
414 return gax.OnHTTPCodes(gax.Backoff{
415 Initial: 100 * time.Millisecond,
416 Max: 60000 * time.Millisecond,
417 Multiplier: 1.30,
418 },
419 http.StatusServiceUnavailable)
420 }),
421 },
422 AnalyzeIamPolicyLongrunning: []gax.CallOption{
423 gax.WithTimeout(60000 * time.Millisecond),
424 },
425 AnalyzeMove: []gax.CallOption{},
426 QueryAssets: []gax.CallOption{
427 gax.WithTimeout(200000 * time.Millisecond),
428 gax.WithRetry(func() gax.Retryer {
429 return gax.OnHTTPCodes(gax.Backoff{
430 Initial: 100 * time.Millisecond,
431 Max: 60000 * time.Millisecond,
432 Multiplier: 1.30,
433 },
434 http.StatusServiceUnavailable)
435 }),
436 },
437 CreateSavedQuery: []gax.CallOption{
438 gax.WithTimeout(60000 * time.Millisecond),
439 },
440 GetSavedQuery: []gax.CallOption{
441 gax.WithTimeout(60000 * time.Millisecond),
442 gax.WithRetry(func() gax.Retryer {
443 return gax.OnHTTPCodes(gax.Backoff{
444 Initial: 100 * time.Millisecond,
445 Max: 60000 * time.Millisecond,
446 Multiplier: 1.30,
447 },
448 http.StatusGatewayTimeout,
449 http.StatusServiceUnavailable)
450 }),
451 },
452 ListSavedQueries: []gax.CallOption{
453 gax.WithTimeout(60000 * time.Millisecond),
454 gax.WithRetry(func() gax.Retryer {
455 return gax.OnHTTPCodes(gax.Backoff{
456 Initial: 100 * time.Millisecond,
457 Max: 60000 * time.Millisecond,
458 Multiplier: 1.30,
459 },
460 http.StatusGatewayTimeout,
461 http.StatusServiceUnavailable)
462 }),
463 },
464 UpdateSavedQuery: []gax.CallOption{
465 gax.WithTimeout(60000 * time.Millisecond),
466 },
467 DeleteSavedQuery: []gax.CallOption{
468 gax.WithTimeout(60000 * time.Millisecond),
469 gax.WithRetry(func() gax.Retryer {
470 return gax.OnHTTPCodes(gax.Backoff{
471 Initial: 100 * time.Millisecond,
472 Max: 60000 * time.Millisecond,
473 Multiplier: 1.30,
474 },
475 http.StatusGatewayTimeout,
476 http.StatusServiceUnavailable)
477 }),
478 },
479 BatchGetEffectiveIamPolicies: []gax.CallOption{
480 gax.WithTimeout(300000 * time.Millisecond),
481 gax.WithRetry(func() gax.Retryer {
482 return gax.OnHTTPCodes(gax.Backoff{
483 Initial: 100 * time.Millisecond,
484 Max: 60000 * time.Millisecond,
485 Multiplier: 1.30,
486 },
487 http.StatusServiceUnavailable)
488 }),
489 },
490 AnalyzeOrgPolicies: []gax.CallOption{
491 gax.WithTimeout(60000 * time.Millisecond),
492 gax.WithRetry(func() gax.Retryer {
493 return gax.OnHTTPCodes(gax.Backoff{
494 Initial: 100 * time.Millisecond,
495 Max: 60000 * time.Millisecond,
496 Multiplier: 1.30,
497 },
498 http.StatusGatewayTimeout,
499 http.StatusServiceUnavailable)
500 }),
501 },
502 AnalyzeOrgPolicyGovernedContainers: []gax.CallOption{
503 gax.WithTimeout(60000 * time.Millisecond),
504 gax.WithRetry(func() gax.Retryer {
505 return gax.OnHTTPCodes(gax.Backoff{
506 Initial: 100 * time.Millisecond,
507 Max: 60000 * time.Millisecond,
508 Multiplier: 1.30,
509 },
510 http.StatusGatewayTimeout,
511 http.StatusServiceUnavailable)
512 }),
513 },
514 AnalyzeOrgPolicyGovernedAssets: []gax.CallOption{
515 gax.WithTimeout(60000 * time.Millisecond),
516 gax.WithRetry(func() gax.Retryer {
517 return gax.OnHTTPCodes(gax.Backoff{
518 Initial: 100 * time.Millisecond,
519 Max: 60000 * time.Millisecond,
520 Multiplier: 1.30,
521 },
522 http.StatusGatewayTimeout,
523 http.StatusServiceUnavailable)
524 }),
525 },
526 GetOperation: []gax.CallOption{},
527 }
528 }
529
530 // internalClient is an interface that defines the methods available from Cloud Asset API.
531 type internalClient interface {
532 Close() error
533 setGoogleClientInfo(...string)
534 Connection() *grpc.ClientConn
535 ExportAssets(context.Context, *assetpb.ExportAssetsRequest, ...gax.CallOption) (*ExportAssetsOperation, error)
536 ExportAssetsOperation(name string) *ExportAssetsOperation
537 ListAssets(context.Context, *assetpb.ListAssetsRequest, ...gax.CallOption) *AssetIterator
538 BatchGetAssetsHistory(context.Context, *assetpb.BatchGetAssetsHistoryRequest, ...gax.CallOption) (*assetpb.BatchGetAssetsHistoryResponse, error)
539 CreateFeed(context.Context, *assetpb.CreateFeedRequest, ...gax.CallOption) (*assetpb.Feed, error)
540 GetFeed(context.Context, *assetpb.GetFeedRequest, ...gax.CallOption) (*assetpb.Feed, error)
541 ListFeeds(context.Context, *assetpb.ListFeedsRequest, ...gax.CallOption) (*assetpb.ListFeedsResponse, error)
542 UpdateFeed(context.Context, *assetpb.UpdateFeedRequest, ...gax.CallOption) (*assetpb.Feed, error)
543 DeleteFeed(context.Context, *assetpb.DeleteFeedRequest, ...gax.CallOption) error
544 SearchAllResources(context.Context, *assetpb.SearchAllResourcesRequest, ...gax.CallOption) *ResourceSearchResultIterator
545 SearchAllIamPolicies(context.Context, *assetpb.SearchAllIamPoliciesRequest, ...gax.CallOption) *IamPolicySearchResultIterator
546 AnalyzeIamPolicy(context.Context, *assetpb.AnalyzeIamPolicyRequest, ...gax.CallOption) (*assetpb.AnalyzeIamPolicyResponse, error)
547 AnalyzeIamPolicyLongrunning(context.Context, *assetpb.AnalyzeIamPolicyLongrunningRequest, ...gax.CallOption) (*AnalyzeIamPolicyLongrunningOperation, error)
548 AnalyzeIamPolicyLongrunningOperation(name string) *AnalyzeIamPolicyLongrunningOperation
549 AnalyzeMove(context.Context, *assetpb.AnalyzeMoveRequest, ...gax.CallOption) (*assetpb.AnalyzeMoveResponse, error)
550 QueryAssets(context.Context, *assetpb.QueryAssetsRequest, ...gax.CallOption) (*assetpb.QueryAssetsResponse, error)
551 CreateSavedQuery(context.Context, *assetpb.CreateSavedQueryRequest, ...gax.CallOption) (*assetpb.SavedQuery, error)
552 GetSavedQuery(context.Context, *assetpb.GetSavedQueryRequest, ...gax.CallOption) (*assetpb.SavedQuery, error)
553 ListSavedQueries(context.Context, *assetpb.ListSavedQueriesRequest, ...gax.CallOption) *SavedQueryIterator
554 UpdateSavedQuery(context.Context, *assetpb.UpdateSavedQueryRequest, ...gax.CallOption) (*assetpb.SavedQuery, error)
555 DeleteSavedQuery(context.Context, *assetpb.DeleteSavedQueryRequest, ...gax.CallOption) error
556 BatchGetEffectiveIamPolicies(context.Context, *assetpb.BatchGetEffectiveIamPoliciesRequest, ...gax.CallOption) (*assetpb.BatchGetEffectiveIamPoliciesResponse, error)
557 AnalyzeOrgPolicies(context.Context, *assetpb.AnalyzeOrgPoliciesRequest, ...gax.CallOption) *AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator
558 AnalyzeOrgPolicyGovernedContainers(context.Context, *assetpb.AnalyzeOrgPolicyGovernedContainersRequest, ...gax.CallOption) *AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator
559 AnalyzeOrgPolicyGovernedAssets(context.Context, *assetpb.AnalyzeOrgPolicyGovernedAssetsRequest, ...gax.CallOption) *AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator
560 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
561 }
562
563 // Client is a client for interacting with Cloud Asset API.
564 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
565 //
566 // Asset service definition.
567 type Client struct {
568 // The internal transport-dependent client.
569 internalClient internalClient
570
571 // The call options for this service.
572 CallOptions *CallOptions
573
574 // LROClient is used internally to handle long-running operations.
575 // It is exposed so that its CallOptions can be modified if required.
576 // Users should not Close this client.
577 LROClient *lroauto.OperationsClient
578 }
579
580 // Wrapper methods routed to the internal client.
581
582 // Close closes the connection to the API service. The user should invoke this when
583 // the client is no longer required.
584 func (c *Client) Close() error {
585 return c.internalClient.Close()
586 }
587
588 // setGoogleClientInfo sets the name and version of the application in
589 // the `x-goog-api-client` header passed on each request. Intended for
590 // use by Google-written clients.
591 func (c *Client) setGoogleClientInfo(keyval ...string) {
592 c.internalClient.setGoogleClientInfo(keyval...)
593 }
594
595 // Connection returns a connection to the API service.
596 //
597 // Deprecated: Connections are now pooled so this method does not always
598 // return the same resource.
599 func (c *Client) Connection() *grpc.ClientConn {
600 return c.internalClient.Connection()
601 }
602
603 // ExportAssets exports assets with time and resource types to a given Cloud Storage
604 // location/BigQuery table. For Cloud Storage location destinations, the
605 // output format is newline-delimited JSON. Each line represents a
606 // google.cloud.asset.v1.Asset in the JSON
607 // format; for BigQuery table destinations, the output table stores the fields
608 // in asset Protobuf as columns. This API implements the
609 // google.longrunning.Operation API, which
610 // allows you to keep track of the export. We recommend intervals of at least
611 // 2 seconds with exponential retry to poll the export operation result. For
612 // regular-size resource parent, the export operation usually finishes within
613 // 5 minutes.
614 func (c *Client) ExportAssets(ctx context.Context, req *assetpb.ExportAssetsRequest, opts ...gax.CallOption) (*ExportAssetsOperation, error) {
615 return c.internalClient.ExportAssets(ctx, req, opts...)
616 }
617
618 // ExportAssetsOperation returns a new ExportAssetsOperation from a given name.
619 // The name must be that of a previously created ExportAssetsOperation, possibly from a different process.
620 func (c *Client) ExportAssetsOperation(name string) *ExportAssetsOperation {
621 return c.internalClient.ExportAssetsOperation(name)
622 }
623
624 // ListAssets lists assets with time and resource types and returns paged results in
625 // response.
626 func (c *Client) ListAssets(ctx context.Context, req *assetpb.ListAssetsRequest, opts ...gax.CallOption) *AssetIterator {
627 return c.internalClient.ListAssets(ctx, req, opts...)
628 }
629
630 // BatchGetAssetsHistory batch gets the update history of assets that overlap a time window.
631 // For IAM_POLICY content, this API outputs history when the asset and its
632 // attached IAM POLICY both exist. This can create gaps in the output history.
633 // Otherwise, this API outputs history with asset in both non-delete or
634 // deleted status.
635 // If a specified asset does not exist, this API returns an INVALID_ARGUMENT
636 // error.
637 func (c *Client) BatchGetAssetsHistory(ctx context.Context, req *assetpb.BatchGetAssetsHistoryRequest, opts ...gax.CallOption) (*assetpb.BatchGetAssetsHistoryResponse, error) {
638 return c.internalClient.BatchGetAssetsHistory(ctx, req, opts...)
639 }
640
641 // CreateFeed creates a feed in a parent project/folder/organization to listen to its
642 // asset updates.
643 func (c *Client) CreateFeed(ctx context.Context, req *assetpb.CreateFeedRequest, opts ...gax.CallOption) (*assetpb.Feed, error) {
644 return c.internalClient.CreateFeed(ctx, req, opts...)
645 }
646
647 // GetFeed gets details about an asset feed.
648 func (c *Client) GetFeed(ctx context.Context, req *assetpb.GetFeedRequest, opts ...gax.CallOption) (*assetpb.Feed, error) {
649 return c.internalClient.GetFeed(ctx, req, opts...)
650 }
651
652 // ListFeeds lists all asset feeds in a parent project/folder/organization.
653 func (c *Client) ListFeeds(ctx context.Context, req *assetpb.ListFeedsRequest, opts ...gax.CallOption) (*assetpb.ListFeedsResponse, error) {
654 return c.internalClient.ListFeeds(ctx, req, opts...)
655 }
656
657 // UpdateFeed updates an asset feed configuration.
658 func (c *Client) UpdateFeed(ctx context.Context, req *assetpb.UpdateFeedRequest, opts ...gax.CallOption) (*assetpb.Feed, error) {
659 return c.internalClient.UpdateFeed(ctx, req, opts...)
660 }
661
662 // DeleteFeed deletes an asset feed.
663 func (c *Client) DeleteFeed(ctx context.Context, req *assetpb.DeleteFeedRequest, opts ...gax.CallOption) error {
664 return c.internalClient.DeleteFeed(ctx, req, opts...)
665 }
666
667 // SearchAllResources searches all Google Cloud resources within the specified scope, such as a
668 // project, folder, or organization. The caller must be granted the
669 // cloudasset.assets.searchAllResources permission on the desired scope,
670 // otherwise the request will be rejected.
671 func (c *Client) SearchAllResources(ctx context.Context, req *assetpb.SearchAllResourcesRequest, opts ...gax.CallOption) *ResourceSearchResultIterator {
672 return c.internalClient.SearchAllResources(ctx, req, opts...)
673 }
674
675 // SearchAllIamPolicies searches all IAM policies within the specified scope, such as a project,
676 // folder, or organization. The caller must be granted the
677 // cloudasset.assets.searchAllIamPolicies permission on the desired scope,
678 // otherwise the request will be rejected.
679 func (c *Client) SearchAllIamPolicies(ctx context.Context, req *assetpb.SearchAllIamPoliciesRequest, opts ...gax.CallOption) *IamPolicySearchResultIterator {
680 return c.internalClient.SearchAllIamPolicies(ctx, req, opts...)
681 }
682
683 // AnalyzeIamPolicy analyzes IAM policies to answer which identities have what accesses on
684 // which resources.
685 func (c *Client) AnalyzeIamPolicy(ctx context.Context, req *assetpb.AnalyzeIamPolicyRequest, opts ...gax.CallOption) (*assetpb.AnalyzeIamPolicyResponse, error) {
686 return c.internalClient.AnalyzeIamPolicy(ctx, req, opts...)
687 }
688
689 // AnalyzeIamPolicyLongrunning analyzes IAM policies asynchronously to answer which identities have what
690 // accesses on which resources, and writes the analysis results to a Google
691 // Cloud Storage or a BigQuery destination. For Cloud Storage destination, the
692 // output format is the JSON format that represents a
693 // AnalyzeIamPolicyResponse.
694 // This method implements the
695 // google.longrunning.Operation, which allows
696 // you to track the operation status. We recommend intervals of at least 2
697 // seconds with exponential backoff retry to poll the operation result. The
698 // metadata contains the metadata for the long-running operation.
699 func (c *Client) AnalyzeIamPolicyLongrunning(ctx context.Context, req *assetpb.AnalyzeIamPolicyLongrunningRequest, opts ...gax.CallOption) (*AnalyzeIamPolicyLongrunningOperation, error) {
700 return c.internalClient.AnalyzeIamPolicyLongrunning(ctx, req, opts...)
701 }
702
703 // AnalyzeIamPolicyLongrunningOperation returns a new AnalyzeIamPolicyLongrunningOperation from a given name.
704 // The name must be that of a previously created AnalyzeIamPolicyLongrunningOperation, possibly from a different process.
705 func (c *Client) AnalyzeIamPolicyLongrunningOperation(name string) *AnalyzeIamPolicyLongrunningOperation {
706 return c.internalClient.AnalyzeIamPolicyLongrunningOperation(name)
707 }
708
709 // AnalyzeMove analyze moving a resource to a specified destination without kicking off
710 // the actual move. The analysis is best effort depending on the user’s
711 // permissions of viewing different hierarchical policies and configurations.
712 // The policies and configuration are subject to change before the actual
713 // resource migration takes place.
714 func (c *Client) AnalyzeMove(ctx context.Context, req *assetpb.AnalyzeMoveRequest, opts ...gax.CallOption) (*assetpb.AnalyzeMoveResponse, error) {
715 return c.internalClient.AnalyzeMove(ctx, req, opts...)
716 }
717
718 // QueryAssets issue a job that queries assets using a SQL statement compatible with
719 // BigQuery SQL (at https://cloud.google.com/bigquery/docs/introduction-sql).
720 //
721 // If the query execution finishes within timeout and there’s no pagination,
722 // the full query results will be returned in the QueryAssetsResponse.
723 //
724 // Otherwise, full query results can be obtained by issuing extra requests
725 // with the job_reference from the a previous QueryAssets call.
726 //
727 // Note, the query result has approximately 10 GB limitation enforced by
728 // BigQuery (at https://cloud.google.com/bigquery/docs/best-practices-performance-output).
729 // Queries return larger results will result in errors.
730 func (c *Client) QueryAssets(ctx context.Context, req *assetpb.QueryAssetsRequest, opts ...gax.CallOption) (*assetpb.QueryAssetsResponse, error) {
731 return c.internalClient.QueryAssets(ctx, req, opts...)
732 }
733
734 // CreateSavedQuery creates a saved query in a parent project/folder/organization.
735 func (c *Client) CreateSavedQuery(ctx context.Context, req *assetpb.CreateSavedQueryRequest, opts ...gax.CallOption) (*assetpb.SavedQuery, error) {
736 return c.internalClient.CreateSavedQuery(ctx, req, opts...)
737 }
738
739 // GetSavedQuery gets details about a saved query.
740 func (c *Client) GetSavedQuery(ctx context.Context, req *assetpb.GetSavedQueryRequest, opts ...gax.CallOption) (*assetpb.SavedQuery, error) {
741 return c.internalClient.GetSavedQuery(ctx, req, opts...)
742 }
743
744 // ListSavedQueries lists all saved queries in a parent project/folder/organization.
745 func (c *Client) ListSavedQueries(ctx context.Context, req *assetpb.ListSavedQueriesRequest, opts ...gax.CallOption) *SavedQueryIterator {
746 return c.internalClient.ListSavedQueries(ctx, req, opts...)
747 }
748
749 // UpdateSavedQuery updates a saved query.
750 func (c *Client) UpdateSavedQuery(ctx context.Context, req *assetpb.UpdateSavedQueryRequest, opts ...gax.CallOption) (*assetpb.SavedQuery, error) {
751 return c.internalClient.UpdateSavedQuery(ctx, req, opts...)
752 }
753
754 // DeleteSavedQuery deletes a saved query.
755 func (c *Client) DeleteSavedQuery(ctx context.Context, req *assetpb.DeleteSavedQueryRequest, opts ...gax.CallOption) error {
756 return c.internalClient.DeleteSavedQuery(ctx, req, opts...)
757 }
758
759 // BatchGetEffectiveIamPolicies gets effective IAM policies for a batch of resources.
760 func (c *Client) BatchGetEffectiveIamPolicies(ctx context.Context, req *assetpb.BatchGetEffectiveIamPoliciesRequest, opts ...gax.CallOption) (*assetpb.BatchGetEffectiveIamPoliciesResponse, error) {
761 return c.internalClient.BatchGetEffectiveIamPolicies(ctx, req, opts...)
762 }
763
764 // AnalyzeOrgPolicies analyzes organization policies under a scope.
765 func (c *Client) AnalyzeOrgPolicies(ctx context.Context, req *assetpb.AnalyzeOrgPoliciesRequest, opts ...gax.CallOption) *AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator {
766 return c.internalClient.AnalyzeOrgPolicies(ctx, req, opts...)
767 }
768
769 // AnalyzeOrgPolicyGovernedContainers analyzes organization policies governed containers (projects, folders or
770 // organization) under a scope.
771 func (c *Client) AnalyzeOrgPolicyGovernedContainers(ctx context.Context, req *assetpb.AnalyzeOrgPolicyGovernedContainersRequest, opts ...gax.CallOption) *AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator {
772 return c.internalClient.AnalyzeOrgPolicyGovernedContainers(ctx, req, opts...)
773 }
774
775 // AnalyzeOrgPolicyGovernedAssets analyzes organization policies governed assets (Google Cloud resources or
776 // policies) under a scope. This RPC supports custom constraints and the
777 // following canned constraints:
778 //
779 // constraints/ainotebooks.accessMode
780 //
781 // constraints/ainotebooks.disableFileDownloads
782 //
783 // constraints/ainotebooks.disableRootAccess
784 //
785 // constraints/ainotebooks.disableTerminal
786 //
787 // constraints/ainotebooks.environmentOptions
788 //
789 // constraints/ainotebooks.requireAutoUpgradeSchedule
790 //
791 // constraints/ainotebooks.restrictVpcNetworks
792 //
793 // constraints/compute.disableGuestAttributesAccess
794 //
795 // constraints/compute.disableInstanceDataAccessApis
796 //
797 // constraints/compute.disableNestedVirtualization
798 //
799 // constraints/compute.disableSerialPortAccess
800 //
801 // constraints/compute.disableSerialPortLogging
802 //
803 // constraints/compute.disableVpcExternalIpv6
804 //
805 // constraints/compute.requireOsLogin
806 //
807 // constraints/compute.requireShieldedVm
808 //
809 // constraints/compute.restrictLoadBalancerCreationForTypes
810 //
811 // constraints/compute.restrictProtocolForwardingCreationForTypes
812 //
813 // constraints/compute.restrictXpnProjectLienRemoval
814 //
815 // constraints/compute.setNewProjectDefaultToZonalDNSOnly
816 //
817 // constraints/compute.skipDefaultNetworkCreation
818 //
819 // constraints/compute.trustedImageProjects
820 //
821 // constraints/compute.vmCanIpForward
822 //
823 // constraints/compute.vmExternalIpAccess
824 //
825 // constraints/gcp.detailedAuditLoggingMode
826 //
827 // constraints/gcp.resourceLocations
828 //
829 // constraints/iam.allowedPolicyMemberDomains
830 //
831 // constraints/iam.automaticIamGrantsForDefaultServiceAccounts
832 //
833 // constraints/iam.disableServiceAccountCreation
834 //
835 // constraints/iam.disableServiceAccountKeyCreation
836 //
837 // constraints/iam.disableServiceAccountKeyUpload
838 //
839 // constraints/iam.restrictCrossProjectServiceAccountLienRemoval
840 //
841 // constraints/iam.serviceAccountKeyExpiryHours
842 //
843 // constraints/resourcemanager.accessBoundaries
844 //
845 // constraints/resourcemanager.allowedExportDestinations
846 //
847 // constraints/sql.restrictAuthorizedNetworks
848 //
849 // constraints/sql.restrictNoncompliantDiagnosticDataAccess
850 //
851 // constraints/sql.restrictNoncompliantResourceCreation
852 //
853 // constraints/sql.restrictPublicIp
854 //
855 // constraints/storage.publicAccessPrevention
856 //
857 // constraints/storage.restrictAuthTypes
858 //
859 // constraints/storage.uniformBucketLevelAccess
860 //
861 // This RPC only returns either resources of types supported by search
862 // APIs (at https://cloud.google.com/asset-inventory/docs/supported-asset-types)
863 // or IAM policies.
864 func (c *Client) AnalyzeOrgPolicyGovernedAssets(ctx context.Context, req *assetpb.AnalyzeOrgPolicyGovernedAssetsRequest, opts ...gax.CallOption) *AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator {
865 return c.internalClient.AnalyzeOrgPolicyGovernedAssets(ctx, req, opts...)
866 }
867
868 // GetOperation is a utility method from google.longrunning.Operations.
869 func (c *Client) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
870 return c.internalClient.GetOperation(ctx, req, opts...)
871 }
872
873 // gRPCClient is a client for interacting with Cloud Asset API over gRPC transport.
874 //
875 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
876 type gRPCClient struct {
877 // Connection pool of gRPC connections to the service.
878 connPool gtransport.ConnPool
879
880 // Points back to the CallOptions field of the containing Client
881 CallOptions **CallOptions
882
883 // The gRPC API client.
884 client assetpb.AssetServiceClient
885
886 // LROClient is used internally to handle long-running operations.
887 // It is exposed so that its CallOptions can be modified if required.
888 // Users should not Close this client.
889 LROClient **lroauto.OperationsClient
890
891 operationsClient longrunningpb.OperationsClient
892
893 // The x-goog-* metadata to be sent with each request.
894 xGoogHeaders []string
895
896 logger *slog.Logger
897 }
898
899 // NewClient creates a new asset service client based on gRPC.
900 // The returned client must be Closed when it is done being used to clean up its underlying connections.
901 //
902 // Asset service definition.
903 func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
904 clientOpts := defaultGRPCClientOptions()
905 if newClientHook != nil {
906 hookOpts, err := newClientHook(ctx, clientHookParams{})
907 if err != nil {
908 return nil, err
909 }
910 clientOpts = append(clientOpts, hookOpts...)
911 }
912
913 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
914 if err != nil {
915 return nil, err
916 }
917 client := Client{CallOptions: defaultCallOptions()}
918
919 c := &gRPCClient{
920 connPool: connPool,
921 client: assetpb.NewAssetServiceClient(connPool),
922 CallOptions: &client.CallOptions,
923 logger: internaloption.GetLogger(opts),
924 operationsClient: longrunningpb.NewOperationsClient(connPool),
925 }
926 c.setGoogleClientInfo()
927
928 client.internalClient = c
929
930 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
931 if err != nil {
932 // This error "should not happen", since we are just reusing old connection pool
933 // and never actually need to dial.
934 // If this does happen, we could leak connp. However, we cannot close conn:
935 // If the user invoked the constructor with option.WithGRPCConn,
936 // we would close a connection that's still in use.
937 // TODO: investigate error conditions.
938 return nil, err
939 }
940 c.LROClient = &client.LROClient
941 return &client, nil
942 }
943
944 // Connection returns a connection to the API service.
945 //
946 // Deprecated: Connections are now pooled so this method does not always
947 // return the same resource.
948 func (c *gRPCClient) Connection() *grpc.ClientConn {
949 return c.connPool.Conn()
950 }
951
952 // setGoogleClientInfo sets the name and version of the application in
953 // the `x-goog-api-client` header passed on each request. Intended for
954 // use by Google-written clients.
955 func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
956 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
957 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
958 c.xGoogHeaders = []string{
959 "x-goog-api-client", gax.XGoogHeader(kv...),
960 }
961 }
962
963 // Close closes the connection to the API service. The user should invoke this when
964 // the client is no longer required.
965 func (c *gRPCClient) Close() error {
966 return c.connPool.Close()
967 }
968
969 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
970 type restClient struct {
971 // The http endpoint to connect to.
972 endpoint string
973
974 // The http client.
975 httpClient *http.Client
976
977 // LROClient is used internally to handle long-running operations.
978 // It is exposed so that its CallOptions can be modified if required.
979 // Users should not Close this client.
980 LROClient **lroauto.OperationsClient
981
982 // The x-goog-* headers to be sent with each request.
983 xGoogHeaders []string
984
985 // Points back to the CallOptions field of the containing Client
986 CallOptions **CallOptions
987
988 logger *slog.Logger
989 }
990
991 // NewRESTClient creates a new asset service rest client.
992 //
993 // Asset service definition.
994 func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
995 clientOpts := append(defaultRESTClientOptions(), opts...)
996 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
997 if err != nil {
998 return nil, err
999 }
1000
1001 callOpts := defaultRESTCallOptions()
1002 c := &restClient{
1003 endpoint: endpoint,
1004 httpClient: httpClient,
1005 CallOptions: &callOpts,
1006 logger: internaloption.GetLogger(opts),
1007 }
1008 c.setGoogleClientInfo()
1009
1010 lroOpts := []option.ClientOption{
1011 option.WithHTTPClient(httpClient),
1012 option.WithEndpoint(endpoint),
1013 }
1014 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
1015 if err != nil {
1016 return nil, err
1017 }
1018 c.LROClient = &opClient
1019
1020 return &Client{internalClient: c, CallOptions: callOpts}, nil
1021 }
1022
1023 func defaultRESTClientOptions() []option.ClientOption {
1024 return []option.ClientOption{
1025 internaloption.WithDefaultEndpoint("https://cloudasset.googleapis.com"),
1026 internaloption.WithDefaultEndpointTemplate("https://cloudasset.UNIVERSE_DOMAIN"),
1027 internaloption.WithDefaultMTLSEndpoint("https://cloudasset.mtls.googleapis.com"),
1028 internaloption.WithDefaultUniverseDomain("googleapis.com"),
1029 internaloption.WithDefaultAudience("https://cloudasset.googleapis.com/"),
1030 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
1031 internaloption.EnableNewAuthLibrary(),
1032 }
1033 }
1034
1035 // setGoogleClientInfo sets the name and version of the application in
1036 // the `x-goog-api-client` header passed on each request. Intended for
1037 // use by Google-written clients.
1038 func (c *restClient) setGoogleClientInfo(keyval ...string) {
1039 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
1040 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
1041 c.xGoogHeaders = []string{
1042 "x-goog-api-client", gax.XGoogHeader(kv...),
1043 }
1044 }
1045
1046 // Close closes the connection to the API service. The user should invoke this when
1047 // the client is no longer required.
1048 func (c *restClient) Close() error {
1049 // Replace httpClient with nil to force cleanup.
1050 c.httpClient = nil
1051 return nil
1052 }
1053
1054 // Connection returns a connection to the API service.
1055 //
1056 // Deprecated: This method always returns nil.
1057 func (c *restClient) Connection() *grpc.ClientConn {
1058 return nil
1059 }
1060 func (c *gRPCClient) ExportAssets(ctx context.Context, req *assetpb.ExportAssetsRequest, opts ...gax.CallOption) (*ExportAssetsOperation, error) {
1061 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1062
1063 hds = append(c.xGoogHeaders, hds...)
1064 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1065 opts = append((*c.CallOptions).ExportAssets[0:len((*c.CallOptions).ExportAssets):len((*c.CallOptions).ExportAssets)], opts...)
1066 var resp *longrunningpb.Operation
1067 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1068 var err error
1069 resp, err = executeRPC(ctx, c.client.ExportAssets, req, settings.GRPC, c.logger, "ExportAssets")
1070 return err
1071 }, opts...)
1072 if err != nil {
1073 return nil, err
1074 }
1075 return &ExportAssetsOperation{
1076 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1077 }, nil
1078 }
1079
1080 func (c *gRPCClient) ListAssets(ctx context.Context, req *assetpb.ListAssetsRequest, opts ...gax.CallOption) *AssetIterator {
1081 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1082
1083 hds = append(c.xGoogHeaders, hds...)
1084 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1085 opts = append((*c.CallOptions).ListAssets[0:len((*c.CallOptions).ListAssets):len((*c.CallOptions).ListAssets)], opts...)
1086 it := &AssetIterator{}
1087 req = proto.Clone(req).(*assetpb.ListAssetsRequest)
1088 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.Asset, string, error) {
1089 resp := &assetpb.ListAssetsResponse{}
1090 if pageToken != "" {
1091 req.PageToken = pageToken
1092 }
1093 if pageSize > math.MaxInt32 {
1094 req.PageSize = math.MaxInt32
1095 } else if pageSize != 0 {
1096 req.PageSize = int32(pageSize)
1097 }
1098 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1099 var err error
1100 resp, err = executeRPC(ctx, c.client.ListAssets, req, settings.GRPC, c.logger, "ListAssets")
1101 return err
1102 }, opts...)
1103 if err != nil {
1104 return nil, "", err
1105 }
1106
1107 it.Response = resp
1108 return resp.GetAssets(), resp.GetNextPageToken(), nil
1109 }
1110 fetch := func(pageSize int, pageToken string) (string, error) {
1111 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1112 if err != nil {
1113 return "", err
1114 }
1115 it.items = append(it.items, items...)
1116 return nextPageToken, nil
1117 }
1118
1119 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1120 it.pageInfo.MaxSize = int(req.GetPageSize())
1121 it.pageInfo.Token = req.GetPageToken()
1122
1123 return it
1124 }
1125
1126 func (c *gRPCClient) BatchGetAssetsHistory(ctx context.Context, req *assetpb.BatchGetAssetsHistoryRequest, opts ...gax.CallOption) (*assetpb.BatchGetAssetsHistoryResponse, error) {
1127 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1128
1129 hds = append(c.xGoogHeaders, hds...)
1130 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1131 opts = append((*c.CallOptions).BatchGetAssetsHistory[0:len((*c.CallOptions).BatchGetAssetsHistory):len((*c.CallOptions).BatchGetAssetsHistory)], opts...)
1132 var resp *assetpb.BatchGetAssetsHistoryResponse
1133 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1134 var err error
1135 resp, err = executeRPC(ctx, c.client.BatchGetAssetsHistory, req, settings.GRPC, c.logger, "BatchGetAssetsHistory")
1136 return err
1137 }, opts...)
1138 if err != nil {
1139 return nil, err
1140 }
1141 return resp, nil
1142 }
1143
1144 func (c *gRPCClient) CreateFeed(ctx context.Context, req *assetpb.CreateFeedRequest, opts ...gax.CallOption) (*assetpb.Feed, error) {
1145 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1146
1147 hds = append(c.xGoogHeaders, hds...)
1148 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1149 opts = append((*c.CallOptions).CreateFeed[0:len((*c.CallOptions).CreateFeed):len((*c.CallOptions).CreateFeed)], opts...)
1150 var resp *assetpb.Feed
1151 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1152 var err error
1153 resp, err = executeRPC(ctx, c.client.CreateFeed, req, settings.GRPC, c.logger, "CreateFeed")
1154 return err
1155 }, opts...)
1156 if err != nil {
1157 return nil, err
1158 }
1159 return resp, nil
1160 }
1161
1162 func (c *gRPCClient) GetFeed(ctx context.Context, req *assetpb.GetFeedRequest, opts ...gax.CallOption) (*assetpb.Feed, error) {
1163 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1164
1165 hds = append(c.xGoogHeaders, hds...)
1166 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1167 opts = append((*c.CallOptions).GetFeed[0:len((*c.CallOptions).GetFeed):len((*c.CallOptions).GetFeed)], opts...)
1168 var resp *assetpb.Feed
1169 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1170 var err error
1171 resp, err = executeRPC(ctx, c.client.GetFeed, req, settings.GRPC, c.logger, "GetFeed")
1172 return err
1173 }, opts...)
1174 if err != nil {
1175 return nil, err
1176 }
1177 return resp, nil
1178 }
1179
1180 func (c *gRPCClient) ListFeeds(ctx context.Context, req *assetpb.ListFeedsRequest, opts ...gax.CallOption) (*assetpb.ListFeedsResponse, error) {
1181 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1182
1183 hds = append(c.xGoogHeaders, hds...)
1184 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1185 opts = append((*c.CallOptions).ListFeeds[0:len((*c.CallOptions).ListFeeds):len((*c.CallOptions).ListFeeds)], opts...)
1186 var resp *assetpb.ListFeedsResponse
1187 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1188 var err error
1189 resp, err = executeRPC(ctx, c.client.ListFeeds, req, settings.GRPC, c.logger, "ListFeeds")
1190 return err
1191 }, opts...)
1192 if err != nil {
1193 return nil, err
1194 }
1195 return resp, nil
1196 }
1197
1198 func (c *gRPCClient) UpdateFeed(ctx context.Context, req *assetpb.UpdateFeedRequest, opts ...gax.CallOption) (*assetpb.Feed, error) {
1199 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feed.name", url.QueryEscape(req.GetFeed().GetName()))}
1200
1201 hds = append(c.xGoogHeaders, hds...)
1202 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1203 opts = append((*c.CallOptions).UpdateFeed[0:len((*c.CallOptions).UpdateFeed):len((*c.CallOptions).UpdateFeed)], opts...)
1204 var resp *assetpb.Feed
1205 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1206 var err error
1207 resp, err = executeRPC(ctx, c.client.UpdateFeed, req, settings.GRPC, c.logger, "UpdateFeed")
1208 return err
1209 }, opts...)
1210 if err != nil {
1211 return nil, err
1212 }
1213 return resp, nil
1214 }
1215
1216 func (c *gRPCClient) DeleteFeed(ctx context.Context, req *assetpb.DeleteFeedRequest, opts ...gax.CallOption) error {
1217 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1218
1219 hds = append(c.xGoogHeaders, hds...)
1220 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1221 opts = append((*c.CallOptions).DeleteFeed[0:len((*c.CallOptions).DeleteFeed):len((*c.CallOptions).DeleteFeed)], opts...)
1222 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1223 var err error
1224 _, err = executeRPC(ctx, c.client.DeleteFeed, req, settings.GRPC, c.logger, "DeleteFeed")
1225 return err
1226 }, opts...)
1227 return err
1228 }
1229
1230 func (c *gRPCClient) SearchAllResources(ctx context.Context, req *assetpb.SearchAllResourcesRequest, opts ...gax.CallOption) *ResourceSearchResultIterator {
1231 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "scope", url.QueryEscape(req.GetScope()))}
1232
1233 hds = append(c.xGoogHeaders, hds...)
1234 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1235 opts = append((*c.CallOptions).SearchAllResources[0:len((*c.CallOptions).SearchAllResources):len((*c.CallOptions).SearchAllResources)], opts...)
1236 it := &ResourceSearchResultIterator{}
1237 req = proto.Clone(req).(*assetpb.SearchAllResourcesRequest)
1238 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.ResourceSearchResult, string, error) {
1239 resp := &assetpb.SearchAllResourcesResponse{}
1240 if pageToken != "" {
1241 req.PageToken = pageToken
1242 }
1243 if pageSize > math.MaxInt32 {
1244 req.PageSize = math.MaxInt32
1245 } else if pageSize != 0 {
1246 req.PageSize = int32(pageSize)
1247 }
1248 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1249 var err error
1250 resp, err = executeRPC(ctx, c.client.SearchAllResources, req, settings.GRPC, c.logger, "SearchAllResources")
1251 return err
1252 }, opts...)
1253 if err != nil {
1254 return nil, "", err
1255 }
1256
1257 it.Response = resp
1258 return resp.GetResults(), resp.GetNextPageToken(), nil
1259 }
1260 fetch := func(pageSize int, pageToken string) (string, error) {
1261 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1262 if err != nil {
1263 return "", err
1264 }
1265 it.items = append(it.items, items...)
1266 return nextPageToken, nil
1267 }
1268
1269 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1270 it.pageInfo.MaxSize = int(req.GetPageSize())
1271 it.pageInfo.Token = req.GetPageToken()
1272
1273 return it
1274 }
1275
1276 func (c *gRPCClient) SearchAllIamPolicies(ctx context.Context, req *assetpb.SearchAllIamPoliciesRequest, opts ...gax.CallOption) *IamPolicySearchResultIterator {
1277 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "scope", url.QueryEscape(req.GetScope()))}
1278
1279 hds = append(c.xGoogHeaders, hds...)
1280 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1281 opts = append((*c.CallOptions).SearchAllIamPolicies[0:len((*c.CallOptions).SearchAllIamPolicies):len((*c.CallOptions).SearchAllIamPolicies)], opts...)
1282 it := &IamPolicySearchResultIterator{}
1283 req = proto.Clone(req).(*assetpb.SearchAllIamPoliciesRequest)
1284 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.IamPolicySearchResult, string, error) {
1285 resp := &assetpb.SearchAllIamPoliciesResponse{}
1286 if pageToken != "" {
1287 req.PageToken = pageToken
1288 }
1289 if pageSize > math.MaxInt32 {
1290 req.PageSize = math.MaxInt32
1291 } else if pageSize != 0 {
1292 req.PageSize = int32(pageSize)
1293 }
1294 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1295 var err error
1296 resp, err = executeRPC(ctx, c.client.SearchAllIamPolicies, req, settings.GRPC, c.logger, "SearchAllIamPolicies")
1297 return err
1298 }, opts...)
1299 if err != nil {
1300 return nil, "", err
1301 }
1302
1303 it.Response = resp
1304 return resp.GetResults(), resp.GetNextPageToken(), nil
1305 }
1306 fetch := func(pageSize int, pageToken string) (string, error) {
1307 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1308 if err != nil {
1309 return "", err
1310 }
1311 it.items = append(it.items, items...)
1312 return nextPageToken, nil
1313 }
1314
1315 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1316 it.pageInfo.MaxSize = int(req.GetPageSize())
1317 it.pageInfo.Token = req.GetPageToken()
1318
1319 return it
1320 }
1321
1322 func (c *gRPCClient) AnalyzeIamPolicy(ctx context.Context, req *assetpb.AnalyzeIamPolicyRequest, opts ...gax.CallOption) (*assetpb.AnalyzeIamPolicyResponse, error) {
1323 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "analysis_query.scope", url.QueryEscape(req.GetAnalysisQuery().GetScope()))}
1324
1325 hds = append(c.xGoogHeaders, hds...)
1326 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1327 opts = append((*c.CallOptions).AnalyzeIamPolicy[0:len((*c.CallOptions).AnalyzeIamPolicy):len((*c.CallOptions).AnalyzeIamPolicy)], opts...)
1328 var resp *assetpb.AnalyzeIamPolicyResponse
1329 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1330 var err error
1331 resp, err = executeRPC(ctx, c.client.AnalyzeIamPolicy, req, settings.GRPC, c.logger, "AnalyzeIamPolicy")
1332 return err
1333 }, opts...)
1334 if err != nil {
1335 return nil, err
1336 }
1337 return resp, nil
1338 }
1339
1340 func (c *gRPCClient) AnalyzeIamPolicyLongrunning(ctx context.Context, req *assetpb.AnalyzeIamPolicyLongrunningRequest, opts ...gax.CallOption) (*AnalyzeIamPolicyLongrunningOperation, error) {
1341 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "analysis_query.scope", url.QueryEscape(req.GetAnalysisQuery().GetScope()))}
1342
1343 hds = append(c.xGoogHeaders, hds...)
1344 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1345 opts = append((*c.CallOptions).AnalyzeIamPolicyLongrunning[0:len((*c.CallOptions).AnalyzeIamPolicyLongrunning):len((*c.CallOptions).AnalyzeIamPolicyLongrunning)], opts...)
1346 var resp *longrunningpb.Operation
1347 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1348 var err error
1349 resp, err = executeRPC(ctx, c.client.AnalyzeIamPolicyLongrunning, req, settings.GRPC, c.logger, "AnalyzeIamPolicyLongrunning")
1350 return err
1351 }, opts...)
1352 if err != nil {
1353 return nil, err
1354 }
1355 return &AnalyzeIamPolicyLongrunningOperation{
1356 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1357 }, nil
1358 }
1359
1360 func (c *gRPCClient) AnalyzeMove(ctx context.Context, req *assetpb.AnalyzeMoveRequest, opts ...gax.CallOption) (*assetpb.AnalyzeMoveResponse, error) {
1361 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1362
1363 hds = append(c.xGoogHeaders, hds...)
1364 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1365 opts = append((*c.CallOptions).AnalyzeMove[0:len((*c.CallOptions).AnalyzeMove):len((*c.CallOptions).AnalyzeMove)], opts...)
1366 var resp *assetpb.AnalyzeMoveResponse
1367 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1368 var err error
1369 resp, err = executeRPC(ctx, c.client.AnalyzeMove, req, settings.GRPC, c.logger, "AnalyzeMove")
1370 return err
1371 }, opts...)
1372 if err != nil {
1373 return nil, err
1374 }
1375 return resp, nil
1376 }
1377
1378 func (c *gRPCClient) QueryAssets(ctx context.Context, req *assetpb.QueryAssetsRequest, opts ...gax.CallOption) (*assetpb.QueryAssetsResponse, error) {
1379 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1380
1381 hds = append(c.xGoogHeaders, hds...)
1382 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1383 opts = append((*c.CallOptions).QueryAssets[0:len((*c.CallOptions).QueryAssets):len((*c.CallOptions).QueryAssets)], opts...)
1384 var resp *assetpb.QueryAssetsResponse
1385 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1386 var err error
1387 resp, err = executeRPC(ctx, c.client.QueryAssets, req, settings.GRPC, c.logger, "QueryAssets")
1388 return err
1389 }, opts...)
1390 if err != nil {
1391 return nil, err
1392 }
1393 return resp, nil
1394 }
1395
1396 func (c *gRPCClient) CreateSavedQuery(ctx context.Context, req *assetpb.CreateSavedQueryRequest, opts ...gax.CallOption) (*assetpb.SavedQuery, error) {
1397 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1398
1399 hds = append(c.xGoogHeaders, hds...)
1400 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1401 opts = append((*c.CallOptions).CreateSavedQuery[0:len((*c.CallOptions).CreateSavedQuery):len((*c.CallOptions).CreateSavedQuery)], opts...)
1402 var resp *assetpb.SavedQuery
1403 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1404 var err error
1405 resp, err = executeRPC(ctx, c.client.CreateSavedQuery, req, settings.GRPC, c.logger, "CreateSavedQuery")
1406 return err
1407 }, opts...)
1408 if err != nil {
1409 return nil, err
1410 }
1411 return resp, nil
1412 }
1413
1414 func (c *gRPCClient) GetSavedQuery(ctx context.Context, req *assetpb.GetSavedQueryRequest, opts ...gax.CallOption) (*assetpb.SavedQuery, error) {
1415 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1416
1417 hds = append(c.xGoogHeaders, hds...)
1418 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1419 opts = append((*c.CallOptions).GetSavedQuery[0:len((*c.CallOptions).GetSavedQuery):len((*c.CallOptions).GetSavedQuery)], opts...)
1420 var resp *assetpb.SavedQuery
1421 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1422 var err error
1423 resp, err = executeRPC(ctx, c.client.GetSavedQuery, req, settings.GRPC, c.logger, "GetSavedQuery")
1424 return err
1425 }, opts...)
1426 if err != nil {
1427 return nil, err
1428 }
1429 return resp, nil
1430 }
1431
1432 func (c *gRPCClient) ListSavedQueries(ctx context.Context, req *assetpb.ListSavedQueriesRequest, opts ...gax.CallOption) *SavedQueryIterator {
1433 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1434
1435 hds = append(c.xGoogHeaders, hds...)
1436 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1437 opts = append((*c.CallOptions).ListSavedQueries[0:len((*c.CallOptions).ListSavedQueries):len((*c.CallOptions).ListSavedQueries)], opts...)
1438 it := &SavedQueryIterator{}
1439 req = proto.Clone(req).(*assetpb.ListSavedQueriesRequest)
1440 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.SavedQuery, string, error) {
1441 resp := &assetpb.ListSavedQueriesResponse{}
1442 if pageToken != "" {
1443 req.PageToken = pageToken
1444 }
1445 if pageSize > math.MaxInt32 {
1446 req.PageSize = math.MaxInt32
1447 } else if pageSize != 0 {
1448 req.PageSize = int32(pageSize)
1449 }
1450 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1451 var err error
1452 resp, err = executeRPC(ctx, c.client.ListSavedQueries, req, settings.GRPC, c.logger, "ListSavedQueries")
1453 return err
1454 }, opts...)
1455 if err != nil {
1456 return nil, "", err
1457 }
1458
1459 it.Response = resp
1460 return resp.GetSavedQueries(), resp.GetNextPageToken(), nil
1461 }
1462 fetch := func(pageSize int, pageToken string) (string, error) {
1463 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1464 if err != nil {
1465 return "", err
1466 }
1467 it.items = append(it.items, items...)
1468 return nextPageToken, nil
1469 }
1470
1471 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1472 it.pageInfo.MaxSize = int(req.GetPageSize())
1473 it.pageInfo.Token = req.GetPageToken()
1474
1475 return it
1476 }
1477
1478 func (c *gRPCClient) UpdateSavedQuery(ctx context.Context, req *assetpb.UpdateSavedQueryRequest, opts ...gax.CallOption) (*assetpb.SavedQuery, error) {
1479 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "saved_query.name", url.QueryEscape(req.GetSavedQuery().GetName()))}
1480
1481 hds = append(c.xGoogHeaders, hds...)
1482 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1483 opts = append((*c.CallOptions).UpdateSavedQuery[0:len((*c.CallOptions).UpdateSavedQuery):len((*c.CallOptions).UpdateSavedQuery)], opts...)
1484 var resp *assetpb.SavedQuery
1485 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1486 var err error
1487 resp, err = executeRPC(ctx, c.client.UpdateSavedQuery, req, settings.GRPC, c.logger, "UpdateSavedQuery")
1488 return err
1489 }, opts...)
1490 if err != nil {
1491 return nil, err
1492 }
1493 return resp, nil
1494 }
1495
1496 func (c *gRPCClient) DeleteSavedQuery(ctx context.Context, req *assetpb.DeleteSavedQueryRequest, opts ...gax.CallOption) error {
1497 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1498
1499 hds = append(c.xGoogHeaders, hds...)
1500 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1501 opts = append((*c.CallOptions).DeleteSavedQuery[0:len((*c.CallOptions).DeleteSavedQuery):len((*c.CallOptions).DeleteSavedQuery)], opts...)
1502 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1503 var err error
1504 _, err = executeRPC(ctx, c.client.DeleteSavedQuery, req, settings.GRPC, c.logger, "DeleteSavedQuery")
1505 return err
1506 }, opts...)
1507 return err
1508 }
1509
1510 func (c *gRPCClient) BatchGetEffectiveIamPolicies(ctx context.Context, req *assetpb.BatchGetEffectiveIamPoliciesRequest, opts ...gax.CallOption) (*assetpb.BatchGetEffectiveIamPoliciesResponse, error) {
1511 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "scope", url.QueryEscape(req.GetScope()))}
1512
1513 hds = append(c.xGoogHeaders, hds...)
1514 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1515 opts = append((*c.CallOptions).BatchGetEffectiveIamPolicies[0:len((*c.CallOptions).BatchGetEffectiveIamPolicies):len((*c.CallOptions).BatchGetEffectiveIamPolicies)], opts...)
1516 var resp *assetpb.BatchGetEffectiveIamPoliciesResponse
1517 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1518 var err error
1519 resp, err = executeRPC(ctx, c.client.BatchGetEffectiveIamPolicies, req, settings.GRPC, c.logger, "BatchGetEffectiveIamPolicies")
1520 return err
1521 }, opts...)
1522 if err != nil {
1523 return nil, err
1524 }
1525 return resp, nil
1526 }
1527
1528 func (c *gRPCClient) AnalyzeOrgPolicies(ctx context.Context, req *assetpb.AnalyzeOrgPoliciesRequest, opts ...gax.CallOption) *AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator {
1529 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "scope", url.QueryEscape(req.GetScope()))}
1530
1531 hds = append(c.xGoogHeaders, hds...)
1532 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1533 opts = append((*c.CallOptions).AnalyzeOrgPolicies[0:len((*c.CallOptions).AnalyzeOrgPolicies):len((*c.CallOptions).AnalyzeOrgPolicies)], opts...)
1534 it := &AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator{}
1535 req = proto.Clone(req).(*assetpb.AnalyzeOrgPoliciesRequest)
1536 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.AnalyzeOrgPoliciesResponse_OrgPolicyResult, string, error) {
1537 resp := &assetpb.AnalyzeOrgPoliciesResponse{}
1538 if pageToken != "" {
1539 req.PageToken = pageToken
1540 }
1541 if pageSize > math.MaxInt32 {
1542 req.PageSize = proto.Int32(int32(math.MaxInt32))
1543 } else if pageSize != 0 {
1544 req.PageSize = proto.Int32(int32(pageSize))
1545 }
1546 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1547 var err error
1548 resp, err = executeRPC(ctx, c.client.AnalyzeOrgPolicies, req, settings.GRPC, c.logger, "AnalyzeOrgPolicies")
1549 return err
1550 }, opts...)
1551 if err != nil {
1552 return nil, "", err
1553 }
1554
1555 it.Response = resp
1556 return resp.GetOrgPolicyResults(), resp.GetNextPageToken(), nil
1557 }
1558 fetch := func(pageSize int, pageToken string) (string, error) {
1559 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1560 if err != nil {
1561 return "", err
1562 }
1563 it.items = append(it.items, items...)
1564 return nextPageToken, nil
1565 }
1566
1567 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1568 it.pageInfo.MaxSize = int(req.GetPageSize())
1569 it.pageInfo.Token = req.GetPageToken()
1570
1571 return it
1572 }
1573
1574 func (c *gRPCClient) AnalyzeOrgPolicyGovernedContainers(ctx context.Context, req *assetpb.AnalyzeOrgPolicyGovernedContainersRequest, opts ...gax.CallOption) *AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator {
1575 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "scope", url.QueryEscape(req.GetScope()))}
1576
1577 hds = append(c.xGoogHeaders, hds...)
1578 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1579 opts = append((*c.CallOptions).AnalyzeOrgPolicyGovernedContainers[0:len((*c.CallOptions).AnalyzeOrgPolicyGovernedContainers):len((*c.CallOptions).AnalyzeOrgPolicyGovernedContainers)], opts...)
1580 it := &AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator{}
1581 req = proto.Clone(req).(*assetpb.AnalyzeOrgPolicyGovernedContainersRequest)
1582 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainer, string, error) {
1583 resp := &assetpb.AnalyzeOrgPolicyGovernedContainersResponse{}
1584 if pageToken != "" {
1585 req.PageToken = pageToken
1586 }
1587 if pageSize > math.MaxInt32 {
1588 req.PageSize = proto.Int32(int32(math.MaxInt32))
1589 } else if pageSize != 0 {
1590 req.PageSize = proto.Int32(int32(pageSize))
1591 }
1592 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1593 var err error
1594 resp, err = executeRPC(ctx, c.client.AnalyzeOrgPolicyGovernedContainers, req, settings.GRPC, c.logger, "AnalyzeOrgPolicyGovernedContainers")
1595 return err
1596 }, opts...)
1597 if err != nil {
1598 return nil, "", err
1599 }
1600
1601 it.Response = resp
1602 return resp.GetGovernedContainers(), resp.GetNextPageToken(), nil
1603 }
1604 fetch := func(pageSize int, pageToken string) (string, error) {
1605 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1606 if err != nil {
1607 return "", err
1608 }
1609 it.items = append(it.items, items...)
1610 return nextPageToken, nil
1611 }
1612
1613 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1614 it.pageInfo.MaxSize = int(req.GetPageSize())
1615 it.pageInfo.Token = req.GetPageToken()
1616
1617 return it
1618 }
1619
1620 func (c *gRPCClient) AnalyzeOrgPolicyGovernedAssets(ctx context.Context, req *assetpb.AnalyzeOrgPolicyGovernedAssetsRequest, opts ...gax.CallOption) *AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator {
1621 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "scope", url.QueryEscape(req.GetScope()))}
1622
1623 hds = append(c.xGoogHeaders, hds...)
1624 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1625 opts = append((*c.CallOptions).AnalyzeOrgPolicyGovernedAssets[0:len((*c.CallOptions).AnalyzeOrgPolicyGovernedAssets):len((*c.CallOptions).AnalyzeOrgPolicyGovernedAssets)], opts...)
1626 it := &AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator{}
1627 req = proto.Clone(req).(*assetpb.AnalyzeOrgPolicyGovernedAssetsRequest)
1628 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAsset, string, error) {
1629 resp := &assetpb.AnalyzeOrgPolicyGovernedAssetsResponse{}
1630 if pageToken != "" {
1631 req.PageToken = pageToken
1632 }
1633 if pageSize > math.MaxInt32 {
1634 req.PageSize = proto.Int32(int32(math.MaxInt32))
1635 } else if pageSize != 0 {
1636 req.PageSize = proto.Int32(int32(pageSize))
1637 }
1638 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1639 var err error
1640 resp, err = executeRPC(ctx, c.client.AnalyzeOrgPolicyGovernedAssets, req, settings.GRPC, c.logger, "AnalyzeOrgPolicyGovernedAssets")
1641 return err
1642 }, opts...)
1643 if err != nil {
1644 return nil, "", err
1645 }
1646
1647 it.Response = resp
1648 return resp.GetGovernedAssets(), resp.GetNextPageToken(), nil
1649 }
1650 fetch := func(pageSize int, pageToken string) (string, error) {
1651 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1652 if err != nil {
1653 return "", err
1654 }
1655 it.items = append(it.items, items...)
1656 return nextPageToken, nil
1657 }
1658
1659 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1660 it.pageInfo.MaxSize = int(req.GetPageSize())
1661 it.pageInfo.Token = req.GetPageToken()
1662
1663 return it
1664 }
1665
1666 func (c *gRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1667 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1668
1669 hds = append(c.xGoogHeaders, hds...)
1670 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1671 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1672 var resp *longrunningpb.Operation
1673 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1674 var err error
1675 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
1676 return err
1677 }, opts...)
1678 if err != nil {
1679 return nil, err
1680 }
1681 return resp, nil
1682 }
1683
1684 // ExportAssets exports assets with time and resource types to a given Cloud Storage
1685 // location/BigQuery table. For Cloud Storage location destinations, the
1686 // output format is newline-delimited JSON. Each line represents a
1687 // google.cloud.asset.v1.Asset in the JSON
1688 // format; for BigQuery table destinations, the output table stores the fields
1689 // in asset Protobuf as columns. This API implements the
1690 // google.longrunning.Operation API, which
1691 // allows you to keep track of the export. We recommend intervals of at least
1692 // 2 seconds with exponential retry to poll the export operation result. For
1693 // regular-size resource parent, the export operation usually finishes within
1694 // 5 minutes.
1695 func (c *restClient) ExportAssets(ctx context.Context, req *assetpb.ExportAssetsRequest, opts ...gax.CallOption) (*ExportAssetsOperation, error) {
1696 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1697 jsonReq, err := m.Marshal(req)
1698 if err != nil {
1699 return nil, err
1700 }
1701
1702 baseUrl, err := url.Parse(c.endpoint)
1703 if err != nil {
1704 return nil, err
1705 }
1706 baseUrl.Path += fmt.Sprintf("/v1/%v:exportAssets", req.GetParent())
1707
1708 params := url.Values{}
1709 params.Add("$alt", "json;enum-encoding=int")
1710
1711 baseUrl.RawQuery = params.Encode()
1712
1713 // Build HTTP headers from client and context metadata.
1714 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1715
1716 hds = append(c.xGoogHeaders, hds...)
1717 hds = append(hds, "Content-Type", "application/json")
1718 headers := gax.BuildHeaders(ctx, hds...)
1719 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1720 resp := &longrunningpb.Operation{}
1721 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1722 if settings.Path != "" {
1723 baseUrl.Path = settings.Path
1724 }
1725 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1726 if err != nil {
1727 return err
1728 }
1729 httpReq = httpReq.WithContext(ctx)
1730 httpReq.Header = headers
1731
1732 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExportAssets")
1733 if err != nil {
1734 return err
1735 }
1736 if err := unm.Unmarshal(buf, resp); err != nil {
1737 return err
1738 }
1739
1740 return nil
1741 }, opts...)
1742 if e != nil {
1743 return nil, e
1744 }
1745
1746 override := fmt.Sprintf("/v1/%s", resp.GetName())
1747 return &ExportAssetsOperation{
1748 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1749 pollPath: override,
1750 }, nil
1751 }
1752
1753 // ListAssets lists assets with time and resource types and returns paged results in
1754 // response.
1755 func (c *restClient) ListAssets(ctx context.Context, req *assetpb.ListAssetsRequest, opts ...gax.CallOption) *AssetIterator {
1756 it := &AssetIterator{}
1757 req = proto.Clone(req).(*assetpb.ListAssetsRequest)
1758 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1759 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.Asset, string, error) {
1760 resp := &assetpb.ListAssetsResponse{}
1761 if pageToken != "" {
1762 req.PageToken = pageToken
1763 }
1764 if pageSize > math.MaxInt32 {
1765 req.PageSize = math.MaxInt32
1766 } else if pageSize != 0 {
1767 req.PageSize = int32(pageSize)
1768 }
1769 baseUrl, err := url.Parse(c.endpoint)
1770 if err != nil {
1771 return nil, "", err
1772 }
1773 baseUrl.Path += fmt.Sprintf("/v1/%v/assets", req.GetParent())
1774
1775 params := url.Values{}
1776 params.Add("$alt", "json;enum-encoding=int")
1777 if items := req.GetAssetTypes(); len(items) > 0 {
1778 for _, item := range items {
1779 params.Add("assetTypes", fmt.Sprintf("%v", item))
1780 }
1781 }
1782 if req.GetContentType() != 0 {
1783 params.Add("contentType", fmt.Sprintf("%v", req.GetContentType()))
1784 }
1785 if req.GetPageSize() != 0 {
1786 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1787 }
1788 if req.GetPageToken() != "" {
1789 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1790 }
1791 if req.GetReadTime() != nil {
1792 field, err := protojson.Marshal(req.GetReadTime())
1793 if err != nil {
1794 return nil, "", err
1795 }
1796 params.Add("readTime", string(field[1:len(field)-1]))
1797 }
1798 if items := req.GetRelationshipTypes(); len(items) > 0 {
1799 for _, item := range items {
1800 params.Add("relationshipTypes", fmt.Sprintf("%v", item))
1801 }
1802 }
1803
1804 baseUrl.RawQuery = params.Encode()
1805
1806 // Build HTTP headers from client and context metadata.
1807 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1808 headers := gax.BuildHeaders(ctx, hds...)
1809 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1810 if settings.Path != "" {
1811 baseUrl.Path = settings.Path
1812 }
1813 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1814 if err != nil {
1815 return err
1816 }
1817 httpReq.Header = headers
1818
1819 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListAssets")
1820 if err != nil {
1821 return err
1822 }
1823 if err := unm.Unmarshal(buf, resp); err != nil {
1824 return err
1825 }
1826
1827 return nil
1828 }, opts...)
1829 if e != nil {
1830 return nil, "", e
1831 }
1832 it.Response = resp
1833 return resp.GetAssets(), resp.GetNextPageToken(), nil
1834 }
1835
1836 fetch := func(pageSize int, pageToken string) (string, error) {
1837 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1838 if err != nil {
1839 return "", err
1840 }
1841 it.items = append(it.items, items...)
1842 return nextPageToken, nil
1843 }
1844
1845 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1846 it.pageInfo.MaxSize = int(req.GetPageSize())
1847 it.pageInfo.Token = req.GetPageToken()
1848
1849 return it
1850 }
1851
1852 // BatchGetAssetsHistory batch gets the update history of assets that overlap a time window.
1853 // For IAM_POLICY content, this API outputs history when the asset and its
1854 // attached IAM POLICY both exist. This can create gaps in the output history.
1855 // Otherwise, this API outputs history with asset in both non-delete or
1856 // deleted status.
1857 // If a specified asset does not exist, this API returns an INVALID_ARGUMENT
1858 // error.
1859 func (c *restClient) BatchGetAssetsHistory(ctx context.Context, req *assetpb.BatchGetAssetsHistoryRequest, opts ...gax.CallOption) (*assetpb.BatchGetAssetsHistoryResponse, error) {
1860 baseUrl, err := url.Parse(c.endpoint)
1861 if err != nil {
1862 return nil, err
1863 }
1864 baseUrl.Path += fmt.Sprintf("/v1/%v:batchGetAssetsHistory", req.GetParent())
1865
1866 params := url.Values{}
1867 params.Add("$alt", "json;enum-encoding=int")
1868 if items := req.GetAssetNames(); len(items) > 0 {
1869 for _, item := range items {
1870 params.Add("assetNames", fmt.Sprintf("%v", item))
1871 }
1872 }
1873 if req.GetContentType() != 0 {
1874 params.Add("contentType", fmt.Sprintf("%v", req.GetContentType()))
1875 }
1876 if req.GetReadTimeWindow().GetEndTime() != nil {
1877 field, err := protojson.Marshal(req.GetReadTimeWindow().GetEndTime())
1878 if err != nil {
1879 return nil, err
1880 }
1881 params.Add("readTimeWindow.endTime", string(field[1:len(field)-1]))
1882 }
1883 if req.GetReadTimeWindow().GetStartTime() != nil {
1884 field, err := protojson.Marshal(req.GetReadTimeWindow().GetStartTime())
1885 if err != nil {
1886 return nil, err
1887 }
1888 params.Add("readTimeWindow.startTime", string(field[1:len(field)-1]))
1889 }
1890 if items := req.GetRelationshipTypes(); len(items) > 0 {
1891 for _, item := range items {
1892 params.Add("relationshipTypes", fmt.Sprintf("%v", item))
1893 }
1894 }
1895
1896 baseUrl.RawQuery = params.Encode()
1897
1898 // Build HTTP headers from client and context metadata.
1899 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1900
1901 hds = append(c.xGoogHeaders, hds...)
1902 hds = append(hds, "Content-Type", "application/json")
1903 headers := gax.BuildHeaders(ctx, hds...)
1904 opts = append((*c.CallOptions).BatchGetAssetsHistory[0:len((*c.CallOptions).BatchGetAssetsHistory):len((*c.CallOptions).BatchGetAssetsHistory)], opts...)
1905 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1906 resp := &assetpb.BatchGetAssetsHistoryResponse{}
1907 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1908 if settings.Path != "" {
1909 baseUrl.Path = settings.Path
1910 }
1911 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1912 if err != nil {
1913 return err
1914 }
1915 httpReq = httpReq.WithContext(ctx)
1916 httpReq.Header = headers
1917
1918 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "BatchGetAssetsHistory")
1919 if err != nil {
1920 return err
1921 }
1922
1923 if err := unm.Unmarshal(buf, resp); err != nil {
1924 return err
1925 }
1926
1927 return nil
1928 }, opts...)
1929 if e != nil {
1930 return nil, e
1931 }
1932 return resp, nil
1933 }
1934
1935 // CreateFeed creates a feed in a parent project/folder/organization to listen to its
1936 // asset updates.
1937 func (c *restClient) CreateFeed(ctx context.Context, req *assetpb.CreateFeedRequest, opts ...gax.CallOption) (*assetpb.Feed, error) {
1938 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1939 jsonReq, err := m.Marshal(req)
1940 if err != nil {
1941 return nil, err
1942 }
1943
1944 baseUrl, err := url.Parse(c.endpoint)
1945 if err != nil {
1946 return nil, err
1947 }
1948 baseUrl.Path += fmt.Sprintf("/v1/%v/feeds", req.GetParent())
1949
1950 params := url.Values{}
1951 params.Add("$alt", "json;enum-encoding=int")
1952
1953 baseUrl.RawQuery = params.Encode()
1954
1955 // Build HTTP headers from client and context metadata.
1956 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1957
1958 hds = append(c.xGoogHeaders, hds...)
1959 hds = append(hds, "Content-Type", "application/json")
1960 headers := gax.BuildHeaders(ctx, hds...)
1961 opts = append((*c.CallOptions).CreateFeed[0:len((*c.CallOptions).CreateFeed):len((*c.CallOptions).CreateFeed)], opts...)
1962 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1963 resp := &assetpb.Feed{}
1964 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1965 if settings.Path != "" {
1966 baseUrl.Path = settings.Path
1967 }
1968 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1969 if err != nil {
1970 return err
1971 }
1972 httpReq = httpReq.WithContext(ctx)
1973 httpReq.Header = headers
1974
1975 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateFeed")
1976 if err != nil {
1977 return err
1978 }
1979
1980 if err := unm.Unmarshal(buf, resp); err != nil {
1981 return err
1982 }
1983
1984 return nil
1985 }, opts...)
1986 if e != nil {
1987 return nil, e
1988 }
1989 return resp, nil
1990 }
1991
1992 // GetFeed gets details about an asset feed.
1993 func (c *restClient) GetFeed(ctx context.Context, req *assetpb.GetFeedRequest, opts ...gax.CallOption) (*assetpb.Feed, error) {
1994 baseUrl, err := url.Parse(c.endpoint)
1995 if err != nil {
1996 return nil, err
1997 }
1998 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1999
2000 params := url.Values{}
2001 params.Add("$alt", "json;enum-encoding=int")
2002
2003 baseUrl.RawQuery = params.Encode()
2004
2005 // Build HTTP headers from client and context metadata.
2006 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2007
2008 hds = append(c.xGoogHeaders, hds...)
2009 hds = append(hds, "Content-Type", "application/json")
2010 headers := gax.BuildHeaders(ctx, hds...)
2011 opts = append((*c.CallOptions).GetFeed[0:len((*c.CallOptions).GetFeed):len((*c.CallOptions).GetFeed)], opts...)
2012 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2013 resp := &assetpb.Feed{}
2014 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2015 if settings.Path != "" {
2016 baseUrl.Path = settings.Path
2017 }
2018 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2019 if err != nil {
2020 return err
2021 }
2022 httpReq = httpReq.WithContext(ctx)
2023 httpReq.Header = headers
2024
2025 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetFeed")
2026 if err != nil {
2027 return err
2028 }
2029
2030 if err := unm.Unmarshal(buf, resp); err != nil {
2031 return err
2032 }
2033
2034 return nil
2035 }, opts...)
2036 if e != nil {
2037 return nil, e
2038 }
2039 return resp, nil
2040 }
2041
2042 // ListFeeds lists all asset feeds in a parent project/folder/organization.
2043 func (c *restClient) ListFeeds(ctx context.Context, req *assetpb.ListFeedsRequest, opts ...gax.CallOption) (*assetpb.ListFeedsResponse, error) {
2044 baseUrl, err := url.Parse(c.endpoint)
2045 if err != nil {
2046 return nil, err
2047 }
2048 baseUrl.Path += fmt.Sprintf("/v1/%v/feeds", req.GetParent())
2049
2050 params := url.Values{}
2051 params.Add("$alt", "json;enum-encoding=int")
2052
2053 baseUrl.RawQuery = params.Encode()
2054
2055 // Build HTTP headers from client and context metadata.
2056 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2057
2058 hds = append(c.xGoogHeaders, hds...)
2059 hds = append(hds, "Content-Type", "application/json")
2060 headers := gax.BuildHeaders(ctx, hds...)
2061 opts = append((*c.CallOptions).ListFeeds[0:len((*c.CallOptions).ListFeeds):len((*c.CallOptions).ListFeeds)], opts...)
2062 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2063 resp := &assetpb.ListFeedsResponse{}
2064 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2065 if settings.Path != "" {
2066 baseUrl.Path = settings.Path
2067 }
2068 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2069 if err != nil {
2070 return err
2071 }
2072 httpReq = httpReq.WithContext(ctx)
2073 httpReq.Header = headers
2074
2075 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListFeeds")
2076 if err != nil {
2077 return err
2078 }
2079
2080 if err := unm.Unmarshal(buf, resp); err != nil {
2081 return err
2082 }
2083
2084 return nil
2085 }, opts...)
2086 if e != nil {
2087 return nil, e
2088 }
2089 return resp, nil
2090 }
2091
2092 // UpdateFeed updates an asset feed configuration.
2093 func (c *restClient) UpdateFeed(ctx context.Context, req *assetpb.UpdateFeedRequest, opts ...gax.CallOption) (*assetpb.Feed, error) {
2094 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2095 jsonReq, err := m.Marshal(req)
2096 if err != nil {
2097 return nil, err
2098 }
2099
2100 baseUrl, err := url.Parse(c.endpoint)
2101 if err != nil {
2102 return nil, err
2103 }
2104 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetFeed().GetName())
2105
2106 params := url.Values{}
2107 params.Add("$alt", "json;enum-encoding=int")
2108
2109 baseUrl.RawQuery = params.Encode()
2110
2111 // Build HTTP headers from client and context metadata.
2112 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feed.name", url.QueryEscape(req.GetFeed().GetName()))}
2113
2114 hds = append(c.xGoogHeaders, hds...)
2115 hds = append(hds, "Content-Type", "application/json")
2116 headers := gax.BuildHeaders(ctx, hds...)
2117 opts = append((*c.CallOptions).UpdateFeed[0:len((*c.CallOptions).UpdateFeed):len((*c.CallOptions).UpdateFeed)], opts...)
2118 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2119 resp := &assetpb.Feed{}
2120 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2121 if settings.Path != "" {
2122 baseUrl.Path = settings.Path
2123 }
2124 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2125 if err != nil {
2126 return err
2127 }
2128 httpReq = httpReq.WithContext(ctx)
2129 httpReq.Header = headers
2130
2131 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateFeed")
2132 if err != nil {
2133 return err
2134 }
2135
2136 if err := unm.Unmarshal(buf, resp); err != nil {
2137 return err
2138 }
2139
2140 return nil
2141 }, opts...)
2142 if e != nil {
2143 return nil, e
2144 }
2145 return resp, nil
2146 }
2147
2148 // DeleteFeed deletes an asset feed.
2149 func (c *restClient) DeleteFeed(ctx context.Context, req *assetpb.DeleteFeedRequest, opts ...gax.CallOption) error {
2150 baseUrl, err := url.Parse(c.endpoint)
2151 if err != nil {
2152 return err
2153 }
2154 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2155
2156 params := url.Values{}
2157 params.Add("$alt", "json;enum-encoding=int")
2158
2159 baseUrl.RawQuery = params.Encode()
2160
2161 // Build HTTP headers from client and context metadata.
2162 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2163
2164 hds = append(c.xGoogHeaders, hds...)
2165 hds = append(hds, "Content-Type", "application/json")
2166 headers := gax.BuildHeaders(ctx, hds...)
2167 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2168 if settings.Path != "" {
2169 baseUrl.Path = settings.Path
2170 }
2171 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2172 if err != nil {
2173 return err
2174 }
2175 httpReq = httpReq.WithContext(ctx)
2176 httpReq.Header = headers
2177
2178 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteFeed")
2179 return err
2180 }, opts...)
2181 }
2182
2183 // SearchAllResources searches all Google Cloud resources within the specified scope, such as a
2184 // project, folder, or organization. The caller must be granted the
2185 // cloudasset.assets.searchAllResources permission on the desired scope,
2186 // otherwise the request will be rejected.
2187 func (c *restClient) SearchAllResources(ctx context.Context, req *assetpb.SearchAllResourcesRequest, opts ...gax.CallOption) *ResourceSearchResultIterator {
2188 it := &ResourceSearchResultIterator{}
2189 req = proto.Clone(req).(*assetpb.SearchAllResourcesRequest)
2190 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2191 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.ResourceSearchResult, string, error) {
2192 resp := &assetpb.SearchAllResourcesResponse{}
2193 if pageToken != "" {
2194 req.PageToken = pageToken
2195 }
2196 if pageSize > math.MaxInt32 {
2197 req.PageSize = math.MaxInt32
2198 } else if pageSize != 0 {
2199 req.PageSize = int32(pageSize)
2200 }
2201 baseUrl, err := url.Parse(c.endpoint)
2202 if err != nil {
2203 return nil, "", err
2204 }
2205 baseUrl.Path += fmt.Sprintf("/v1/%v:searchAllResources", req.GetScope())
2206
2207 params := url.Values{}
2208 params.Add("$alt", "json;enum-encoding=int")
2209 if items := req.GetAssetTypes(); len(items) > 0 {
2210 for _, item := range items {
2211 params.Add("assetTypes", fmt.Sprintf("%v", item))
2212 }
2213 }
2214 if req.GetOrderBy() != "" {
2215 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2216 }
2217 if req.GetPageSize() != 0 {
2218 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2219 }
2220 if req.GetPageToken() != "" {
2221 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2222 }
2223 if req.GetQuery() != "" {
2224 params.Add("query", fmt.Sprintf("%v", req.GetQuery()))
2225 }
2226 if req.GetReadMask() != nil {
2227 field, err := protojson.Marshal(req.GetReadMask())
2228 if err != nil {
2229 return nil, "", err
2230 }
2231 params.Add("readMask", string(field[1:len(field)-1]))
2232 }
2233
2234 baseUrl.RawQuery = params.Encode()
2235
2236 // Build HTTP headers from client and context metadata.
2237 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2238 headers := gax.BuildHeaders(ctx, hds...)
2239 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2240 if settings.Path != "" {
2241 baseUrl.Path = settings.Path
2242 }
2243 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2244 if err != nil {
2245 return err
2246 }
2247 httpReq.Header = headers
2248
2249 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "SearchAllResources")
2250 if err != nil {
2251 return err
2252 }
2253 if err := unm.Unmarshal(buf, resp); err != nil {
2254 return err
2255 }
2256
2257 return nil
2258 }, opts...)
2259 if e != nil {
2260 return nil, "", e
2261 }
2262 it.Response = resp
2263 return resp.GetResults(), resp.GetNextPageToken(), nil
2264 }
2265
2266 fetch := func(pageSize int, pageToken string) (string, error) {
2267 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2268 if err != nil {
2269 return "", err
2270 }
2271 it.items = append(it.items, items...)
2272 return nextPageToken, nil
2273 }
2274
2275 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2276 it.pageInfo.MaxSize = int(req.GetPageSize())
2277 it.pageInfo.Token = req.GetPageToken()
2278
2279 return it
2280 }
2281
2282 // SearchAllIamPolicies searches all IAM policies within the specified scope, such as a project,
2283 // folder, or organization. The caller must be granted the
2284 // cloudasset.assets.searchAllIamPolicies permission on the desired scope,
2285 // otherwise the request will be rejected.
2286 func (c *restClient) SearchAllIamPolicies(ctx context.Context, req *assetpb.SearchAllIamPoliciesRequest, opts ...gax.CallOption) *IamPolicySearchResultIterator {
2287 it := &IamPolicySearchResultIterator{}
2288 req = proto.Clone(req).(*assetpb.SearchAllIamPoliciesRequest)
2289 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2290 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.IamPolicySearchResult, string, error) {
2291 resp := &assetpb.SearchAllIamPoliciesResponse{}
2292 if pageToken != "" {
2293 req.PageToken = pageToken
2294 }
2295 if pageSize > math.MaxInt32 {
2296 req.PageSize = math.MaxInt32
2297 } else if pageSize != 0 {
2298 req.PageSize = int32(pageSize)
2299 }
2300 baseUrl, err := url.Parse(c.endpoint)
2301 if err != nil {
2302 return nil, "", err
2303 }
2304 baseUrl.Path += fmt.Sprintf("/v1/%v:searchAllIamPolicies", req.GetScope())
2305
2306 params := url.Values{}
2307 params.Add("$alt", "json;enum-encoding=int")
2308 if items := req.GetAssetTypes(); len(items) > 0 {
2309 for _, item := range items {
2310 params.Add("assetTypes", fmt.Sprintf("%v", item))
2311 }
2312 }
2313 if req.GetOrderBy() != "" {
2314 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2315 }
2316 if req.GetPageSize() != 0 {
2317 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2318 }
2319 if req.GetPageToken() != "" {
2320 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2321 }
2322 if req.GetQuery() != "" {
2323 params.Add("query", fmt.Sprintf("%v", req.GetQuery()))
2324 }
2325
2326 baseUrl.RawQuery = params.Encode()
2327
2328 // Build HTTP headers from client and context metadata.
2329 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2330 headers := gax.BuildHeaders(ctx, hds...)
2331 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2332 if settings.Path != "" {
2333 baseUrl.Path = settings.Path
2334 }
2335 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2336 if err != nil {
2337 return err
2338 }
2339 httpReq.Header = headers
2340
2341 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "SearchAllIamPolicies")
2342 if err != nil {
2343 return err
2344 }
2345 if err := unm.Unmarshal(buf, resp); err != nil {
2346 return err
2347 }
2348
2349 return nil
2350 }, opts...)
2351 if e != nil {
2352 return nil, "", e
2353 }
2354 it.Response = resp
2355 return resp.GetResults(), resp.GetNextPageToken(), nil
2356 }
2357
2358 fetch := func(pageSize int, pageToken string) (string, error) {
2359 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2360 if err != nil {
2361 return "", err
2362 }
2363 it.items = append(it.items, items...)
2364 return nextPageToken, nil
2365 }
2366
2367 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2368 it.pageInfo.MaxSize = int(req.GetPageSize())
2369 it.pageInfo.Token = req.GetPageToken()
2370
2371 return it
2372 }
2373
2374 // AnalyzeIamPolicy analyzes IAM policies to answer which identities have what accesses on
2375 // which resources.
2376 func (c *restClient) AnalyzeIamPolicy(ctx context.Context, req *assetpb.AnalyzeIamPolicyRequest, opts ...gax.CallOption) (*assetpb.AnalyzeIamPolicyResponse, error) {
2377 baseUrl, err := url.Parse(c.endpoint)
2378 if err != nil {
2379 return nil, err
2380 }
2381 baseUrl.Path += fmt.Sprintf("/v1/%v:analyzeIamPolicy", req.GetAnalysisQuery().GetScope())
2382
2383 params := url.Values{}
2384 params.Add("$alt", "json;enum-encoding=int")
2385 if items := req.GetAnalysisQuery().GetAccessSelector().GetPermissions(); len(items) > 0 {
2386 for _, item := range items {
2387 params.Add("analysisQuery.accessSelector.permissions", fmt.Sprintf("%v", item))
2388 }
2389 }
2390 if items := req.GetAnalysisQuery().GetAccessSelector().GetRoles(); len(items) > 0 {
2391 for _, item := range items {
2392 params.Add("analysisQuery.accessSelector.roles", fmt.Sprintf("%v", item))
2393 }
2394 }
2395 if req.GetAnalysisQuery().GetConditionContext().GetAccessTime() != nil {
2396 field, err := protojson.Marshal(req.GetAnalysisQuery().GetConditionContext().GetAccessTime())
2397 if err != nil {
2398 return nil, err
2399 }
2400 params.Add("analysisQuery.conditionContext.accessTime", string(field[1:len(field)-1]))
2401 }
2402 params.Add("analysisQuery.identitySelector.identity", fmt.Sprintf("%v", req.GetAnalysisQuery().GetIdentitySelector().GetIdentity()))
2403 if req.GetAnalysisQuery().GetOptions().GetAnalyzeServiceAccountImpersonation() {
2404 params.Add("analysisQuery.options.analyzeServiceAccountImpersonation", fmt.Sprintf("%v", req.GetAnalysisQuery().GetOptions().GetAnalyzeServiceAccountImpersonation()))
2405 }
2406 if req.GetAnalysisQuery().GetOptions().GetExpandGroups() {
2407 params.Add("analysisQuery.options.expandGroups", fmt.Sprintf("%v", req.GetAnalysisQuery().GetOptions().GetExpandGroups()))
2408 }
2409 if req.GetAnalysisQuery().GetOptions().GetExpandResources() {
2410 params.Add("analysisQuery.options.expandResources", fmt.Sprintf("%v", req.GetAnalysisQuery().GetOptions().GetExpandResources()))
2411 }
2412 if req.GetAnalysisQuery().GetOptions().GetExpandRoles() {
2413 params.Add("analysisQuery.options.expandRoles", fmt.Sprintf("%v", req.GetAnalysisQuery().GetOptions().GetExpandRoles()))
2414 }
2415 if req.GetAnalysisQuery().GetOptions().GetOutputGroupEdges() {
2416 params.Add("analysisQuery.options.outputGroupEdges", fmt.Sprintf("%v", req.GetAnalysisQuery().GetOptions().GetOutputGroupEdges()))
2417 }
2418 if req.GetAnalysisQuery().GetOptions().GetOutputResourceEdges() {
2419 params.Add("analysisQuery.options.outputResourceEdges", fmt.Sprintf("%v", req.GetAnalysisQuery().GetOptions().GetOutputResourceEdges()))
2420 }
2421 params.Add("analysisQuery.resourceSelector.fullResourceName", fmt.Sprintf("%v", req.GetAnalysisQuery().GetResourceSelector().GetFullResourceName()))
2422 if req.GetExecutionTimeout() != nil {
2423 field, err := protojson.Marshal(req.GetExecutionTimeout())
2424 if err != nil {
2425 return nil, err
2426 }
2427 params.Add("executionTimeout", string(field[1:len(field)-1]))
2428 }
2429 if req.GetSavedAnalysisQuery() != "" {
2430 params.Add("savedAnalysisQuery", fmt.Sprintf("%v", req.GetSavedAnalysisQuery()))
2431 }
2432
2433 baseUrl.RawQuery = params.Encode()
2434
2435 // Build HTTP headers from client and context metadata.
2436 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "analysis_query.scope", url.QueryEscape(req.GetAnalysisQuery().GetScope()))}
2437
2438 hds = append(c.xGoogHeaders, hds...)
2439 hds = append(hds, "Content-Type", "application/json")
2440 headers := gax.BuildHeaders(ctx, hds...)
2441 opts = append((*c.CallOptions).AnalyzeIamPolicy[0:len((*c.CallOptions).AnalyzeIamPolicy):len((*c.CallOptions).AnalyzeIamPolicy)], opts...)
2442 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2443 resp := &assetpb.AnalyzeIamPolicyResponse{}
2444 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2445 if settings.Path != "" {
2446 baseUrl.Path = settings.Path
2447 }
2448 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2449 if err != nil {
2450 return err
2451 }
2452 httpReq = httpReq.WithContext(ctx)
2453 httpReq.Header = headers
2454
2455 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "AnalyzeIamPolicy")
2456 if err != nil {
2457 return err
2458 }
2459
2460 if err := unm.Unmarshal(buf, resp); err != nil {
2461 return err
2462 }
2463
2464 return nil
2465 }, opts...)
2466 if e != nil {
2467 return nil, e
2468 }
2469 return resp, nil
2470 }
2471
2472 // AnalyzeIamPolicyLongrunning analyzes IAM policies asynchronously to answer which identities have what
2473 // accesses on which resources, and writes the analysis results to a Google
2474 // Cloud Storage or a BigQuery destination. For Cloud Storage destination, the
2475 // output format is the JSON format that represents a
2476 // AnalyzeIamPolicyResponse.
2477 // This method implements the
2478 // google.longrunning.Operation, which allows
2479 // you to track the operation status. We recommend intervals of at least 2
2480 // seconds with exponential backoff retry to poll the operation result. The
2481 // metadata contains the metadata for the long-running operation.
2482 func (c *restClient) AnalyzeIamPolicyLongrunning(ctx context.Context, req *assetpb.AnalyzeIamPolicyLongrunningRequest, opts ...gax.CallOption) (*AnalyzeIamPolicyLongrunningOperation, error) {
2483 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2484 jsonReq, err := m.Marshal(req)
2485 if err != nil {
2486 return nil, err
2487 }
2488
2489 baseUrl, err := url.Parse(c.endpoint)
2490 if err != nil {
2491 return nil, err
2492 }
2493 baseUrl.Path += fmt.Sprintf("/v1/%v:analyzeIamPolicyLongrunning", req.GetAnalysisQuery().GetScope())
2494
2495 params := url.Values{}
2496 params.Add("$alt", "json;enum-encoding=int")
2497
2498 baseUrl.RawQuery = params.Encode()
2499
2500 // Build HTTP headers from client and context metadata.
2501 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "analysis_query.scope", url.QueryEscape(req.GetAnalysisQuery().GetScope()))}
2502
2503 hds = append(c.xGoogHeaders, hds...)
2504 hds = append(hds, "Content-Type", "application/json")
2505 headers := gax.BuildHeaders(ctx, hds...)
2506 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2507 resp := &longrunningpb.Operation{}
2508 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2509 if settings.Path != "" {
2510 baseUrl.Path = settings.Path
2511 }
2512 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2513 if err != nil {
2514 return err
2515 }
2516 httpReq = httpReq.WithContext(ctx)
2517 httpReq.Header = headers
2518
2519 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AnalyzeIamPolicyLongrunning")
2520 if err != nil {
2521 return err
2522 }
2523 if err := unm.Unmarshal(buf, resp); err != nil {
2524 return err
2525 }
2526
2527 return nil
2528 }, opts...)
2529 if e != nil {
2530 return nil, e
2531 }
2532
2533 override := fmt.Sprintf("/v1/%s", resp.GetName())
2534 return &AnalyzeIamPolicyLongrunningOperation{
2535 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2536 pollPath: override,
2537 }, nil
2538 }
2539
2540 // AnalyzeMove analyze moving a resource to a specified destination without kicking off
2541 // the actual move. The analysis is best effort depending on the user’s
2542 // permissions of viewing different hierarchical policies and configurations.
2543 // The policies and configuration are subject to change before the actual
2544 // resource migration takes place.
2545 func (c *restClient) AnalyzeMove(ctx context.Context, req *assetpb.AnalyzeMoveRequest, opts ...gax.CallOption) (*assetpb.AnalyzeMoveResponse, error) {
2546 baseUrl, err := url.Parse(c.endpoint)
2547 if err != nil {
2548 return nil, err
2549 }
2550 baseUrl.Path += fmt.Sprintf("/v1/%v:analyzeMove", req.GetResource())
2551
2552 params := url.Values{}
2553 params.Add("$alt", "json;enum-encoding=int")
2554 params.Add("destinationParent", fmt.Sprintf("%v", req.GetDestinationParent()))
2555 if req.GetView() != 0 {
2556 params.Add("view", fmt.Sprintf("%v", req.GetView()))
2557 }
2558
2559 baseUrl.RawQuery = params.Encode()
2560
2561 // Build HTTP headers from client and context metadata.
2562 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
2563
2564 hds = append(c.xGoogHeaders, hds...)
2565 hds = append(hds, "Content-Type", "application/json")
2566 headers := gax.BuildHeaders(ctx, hds...)
2567 opts = append((*c.CallOptions).AnalyzeMove[0:len((*c.CallOptions).AnalyzeMove):len((*c.CallOptions).AnalyzeMove)], opts...)
2568 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2569 resp := &assetpb.AnalyzeMoveResponse{}
2570 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2571 if settings.Path != "" {
2572 baseUrl.Path = settings.Path
2573 }
2574 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2575 if err != nil {
2576 return err
2577 }
2578 httpReq = httpReq.WithContext(ctx)
2579 httpReq.Header = headers
2580
2581 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "AnalyzeMove")
2582 if err != nil {
2583 return err
2584 }
2585
2586 if err := unm.Unmarshal(buf, resp); err != nil {
2587 return err
2588 }
2589
2590 return nil
2591 }, opts...)
2592 if e != nil {
2593 return nil, e
2594 }
2595 return resp, nil
2596 }
2597
2598 // QueryAssets issue a job that queries assets using a SQL statement compatible with
2599 // BigQuery SQL (at https://cloud.google.com/bigquery/docs/introduction-sql).
2600 //
2601 // If the query execution finishes within timeout and there’s no pagination,
2602 // the full query results will be returned in the QueryAssetsResponse.
2603 //
2604 // Otherwise, full query results can be obtained by issuing extra requests
2605 // with the job_reference from the a previous QueryAssets call.
2606 //
2607 // Note, the query result has approximately 10 GB limitation enforced by
2608 // BigQuery (at https://cloud.google.com/bigquery/docs/best-practices-performance-output).
2609 // Queries return larger results will result in errors.
2610 func (c *restClient) QueryAssets(ctx context.Context, req *assetpb.QueryAssetsRequest, opts ...gax.CallOption) (*assetpb.QueryAssetsResponse, error) {
2611 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2612 jsonReq, err := m.Marshal(req)
2613 if err != nil {
2614 return nil, err
2615 }
2616
2617 baseUrl, err := url.Parse(c.endpoint)
2618 if err != nil {
2619 return nil, err
2620 }
2621 baseUrl.Path += fmt.Sprintf("/v1/%v:queryAssets", req.GetParent())
2622
2623 params := url.Values{}
2624 params.Add("$alt", "json;enum-encoding=int")
2625
2626 baseUrl.RawQuery = params.Encode()
2627
2628 // Build HTTP headers from client and context metadata.
2629 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2630
2631 hds = append(c.xGoogHeaders, hds...)
2632 hds = append(hds, "Content-Type", "application/json")
2633 headers := gax.BuildHeaders(ctx, hds...)
2634 opts = append((*c.CallOptions).QueryAssets[0:len((*c.CallOptions).QueryAssets):len((*c.CallOptions).QueryAssets)], opts...)
2635 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2636 resp := &assetpb.QueryAssetsResponse{}
2637 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2638 if settings.Path != "" {
2639 baseUrl.Path = settings.Path
2640 }
2641 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2642 if err != nil {
2643 return err
2644 }
2645 httpReq = httpReq.WithContext(ctx)
2646 httpReq.Header = headers
2647
2648 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "QueryAssets")
2649 if err != nil {
2650 return err
2651 }
2652
2653 if err := unm.Unmarshal(buf, resp); err != nil {
2654 return err
2655 }
2656
2657 return nil
2658 }, opts...)
2659 if e != nil {
2660 return nil, e
2661 }
2662 return resp, nil
2663 }
2664
2665 // CreateSavedQuery creates a saved query in a parent project/folder/organization.
2666 func (c *restClient) CreateSavedQuery(ctx context.Context, req *assetpb.CreateSavedQueryRequest, opts ...gax.CallOption) (*assetpb.SavedQuery, error) {
2667 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2668 body := req.GetSavedQuery()
2669 jsonReq, err := m.Marshal(body)
2670 if err != nil {
2671 return nil, err
2672 }
2673
2674 baseUrl, err := url.Parse(c.endpoint)
2675 if err != nil {
2676 return nil, err
2677 }
2678 baseUrl.Path += fmt.Sprintf("/v1/%v/savedQueries", req.GetParent())
2679
2680 params := url.Values{}
2681 params.Add("$alt", "json;enum-encoding=int")
2682 params.Add("savedQueryId", fmt.Sprintf("%v", req.GetSavedQueryId()))
2683
2684 baseUrl.RawQuery = params.Encode()
2685
2686 // Build HTTP headers from client and context metadata.
2687 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2688
2689 hds = append(c.xGoogHeaders, hds...)
2690 hds = append(hds, "Content-Type", "application/json")
2691 headers := gax.BuildHeaders(ctx, hds...)
2692 opts = append((*c.CallOptions).CreateSavedQuery[0:len((*c.CallOptions).CreateSavedQuery):len((*c.CallOptions).CreateSavedQuery)], opts...)
2693 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2694 resp := &assetpb.SavedQuery{}
2695 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2696 if settings.Path != "" {
2697 baseUrl.Path = settings.Path
2698 }
2699 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2700 if err != nil {
2701 return err
2702 }
2703 httpReq = httpReq.WithContext(ctx)
2704 httpReq.Header = headers
2705
2706 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateSavedQuery")
2707 if err != nil {
2708 return err
2709 }
2710
2711 if err := unm.Unmarshal(buf, resp); err != nil {
2712 return err
2713 }
2714
2715 return nil
2716 }, opts...)
2717 if e != nil {
2718 return nil, e
2719 }
2720 return resp, nil
2721 }
2722
2723 // GetSavedQuery gets details about a saved query.
2724 func (c *restClient) GetSavedQuery(ctx context.Context, req *assetpb.GetSavedQueryRequest, opts ...gax.CallOption) (*assetpb.SavedQuery, error) {
2725 baseUrl, err := url.Parse(c.endpoint)
2726 if err != nil {
2727 return nil, err
2728 }
2729 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2730
2731 params := url.Values{}
2732 params.Add("$alt", "json;enum-encoding=int")
2733
2734 baseUrl.RawQuery = params.Encode()
2735
2736 // Build HTTP headers from client and context metadata.
2737 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2738
2739 hds = append(c.xGoogHeaders, hds...)
2740 hds = append(hds, "Content-Type", "application/json")
2741 headers := gax.BuildHeaders(ctx, hds...)
2742 opts = append((*c.CallOptions).GetSavedQuery[0:len((*c.CallOptions).GetSavedQuery):len((*c.CallOptions).GetSavedQuery)], opts...)
2743 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2744 resp := &assetpb.SavedQuery{}
2745 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2746 if settings.Path != "" {
2747 baseUrl.Path = settings.Path
2748 }
2749 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2750 if err != nil {
2751 return err
2752 }
2753 httpReq = httpReq.WithContext(ctx)
2754 httpReq.Header = headers
2755
2756 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetSavedQuery")
2757 if err != nil {
2758 return err
2759 }
2760
2761 if err := unm.Unmarshal(buf, resp); err != nil {
2762 return err
2763 }
2764
2765 return nil
2766 }, opts...)
2767 if e != nil {
2768 return nil, e
2769 }
2770 return resp, nil
2771 }
2772
2773 // ListSavedQueries lists all saved queries in a parent project/folder/organization.
2774 func (c *restClient) ListSavedQueries(ctx context.Context, req *assetpb.ListSavedQueriesRequest, opts ...gax.CallOption) *SavedQueryIterator {
2775 it := &SavedQueryIterator{}
2776 req = proto.Clone(req).(*assetpb.ListSavedQueriesRequest)
2777 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2778 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.SavedQuery, string, error) {
2779 resp := &assetpb.ListSavedQueriesResponse{}
2780 if pageToken != "" {
2781 req.PageToken = pageToken
2782 }
2783 if pageSize > math.MaxInt32 {
2784 req.PageSize = math.MaxInt32
2785 } else if pageSize != 0 {
2786 req.PageSize = int32(pageSize)
2787 }
2788 baseUrl, err := url.Parse(c.endpoint)
2789 if err != nil {
2790 return nil, "", err
2791 }
2792 baseUrl.Path += fmt.Sprintf("/v1/%v/savedQueries", req.GetParent())
2793
2794 params := url.Values{}
2795 params.Add("$alt", "json;enum-encoding=int")
2796 if req.GetFilter() != "" {
2797 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2798 }
2799 if req.GetPageSize() != 0 {
2800 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2801 }
2802 if req.GetPageToken() != "" {
2803 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2804 }
2805
2806 baseUrl.RawQuery = params.Encode()
2807
2808 // Build HTTP headers from client and context metadata.
2809 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2810 headers := gax.BuildHeaders(ctx, hds...)
2811 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2812 if settings.Path != "" {
2813 baseUrl.Path = settings.Path
2814 }
2815 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2816 if err != nil {
2817 return err
2818 }
2819 httpReq.Header = headers
2820
2821 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListSavedQueries")
2822 if err != nil {
2823 return err
2824 }
2825 if err := unm.Unmarshal(buf, resp); err != nil {
2826 return err
2827 }
2828
2829 return nil
2830 }, opts...)
2831 if e != nil {
2832 return nil, "", e
2833 }
2834 it.Response = resp
2835 return resp.GetSavedQueries(), resp.GetNextPageToken(), nil
2836 }
2837
2838 fetch := func(pageSize int, pageToken string) (string, error) {
2839 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2840 if err != nil {
2841 return "", err
2842 }
2843 it.items = append(it.items, items...)
2844 return nextPageToken, nil
2845 }
2846
2847 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2848 it.pageInfo.MaxSize = int(req.GetPageSize())
2849 it.pageInfo.Token = req.GetPageToken()
2850
2851 return it
2852 }
2853
2854 // UpdateSavedQuery updates a saved query.
2855 func (c *restClient) UpdateSavedQuery(ctx context.Context, req *assetpb.UpdateSavedQueryRequest, opts ...gax.CallOption) (*assetpb.SavedQuery, error) {
2856 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2857 body := req.GetSavedQuery()
2858 jsonReq, err := m.Marshal(body)
2859 if err != nil {
2860 return nil, err
2861 }
2862
2863 baseUrl, err := url.Parse(c.endpoint)
2864 if err != nil {
2865 return nil, err
2866 }
2867 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetSavedQuery().GetName())
2868
2869 params := url.Values{}
2870 params.Add("$alt", "json;enum-encoding=int")
2871 if req.GetUpdateMask() != nil {
2872 field, err := protojson.Marshal(req.GetUpdateMask())
2873 if err != nil {
2874 return nil, err
2875 }
2876 params.Add("updateMask", string(field[1:len(field)-1]))
2877 }
2878
2879 baseUrl.RawQuery = params.Encode()
2880
2881 // Build HTTP headers from client and context metadata.
2882 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "saved_query.name", url.QueryEscape(req.GetSavedQuery().GetName()))}
2883
2884 hds = append(c.xGoogHeaders, hds...)
2885 hds = append(hds, "Content-Type", "application/json")
2886 headers := gax.BuildHeaders(ctx, hds...)
2887 opts = append((*c.CallOptions).UpdateSavedQuery[0:len((*c.CallOptions).UpdateSavedQuery):len((*c.CallOptions).UpdateSavedQuery)], opts...)
2888 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2889 resp := &assetpb.SavedQuery{}
2890 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2891 if settings.Path != "" {
2892 baseUrl.Path = settings.Path
2893 }
2894 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2895 if err != nil {
2896 return err
2897 }
2898 httpReq = httpReq.WithContext(ctx)
2899 httpReq.Header = headers
2900
2901 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateSavedQuery")
2902 if err != nil {
2903 return err
2904 }
2905
2906 if err := unm.Unmarshal(buf, resp); err != nil {
2907 return err
2908 }
2909
2910 return nil
2911 }, opts...)
2912 if e != nil {
2913 return nil, e
2914 }
2915 return resp, nil
2916 }
2917
2918 // DeleteSavedQuery deletes a saved query.
2919 func (c *restClient) DeleteSavedQuery(ctx context.Context, req *assetpb.DeleteSavedQueryRequest, opts ...gax.CallOption) error {
2920 baseUrl, err := url.Parse(c.endpoint)
2921 if err != nil {
2922 return err
2923 }
2924 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2925
2926 params := url.Values{}
2927 params.Add("$alt", "json;enum-encoding=int")
2928
2929 baseUrl.RawQuery = params.Encode()
2930
2931 // Build HTTP headers from client and context metadata.
2932 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2933
2934 hds = append(c.xGoogHeaders, hds...)
2935 hds = append(hds, "Content-Type", "application/json")
2936 headers := gax.BuildHeaders(ctx, hds...)
2937 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2938 if settings.Path != "" {
2939 baseUrl.Path = settings.Path
2940 }
2941 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2942 if err != nil {
2943 return err
2944 }
2945 httpReq = httpReq.WithContext(ctx)
2946 httpReq.Header = headers
2947
2948 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSavedQuery")
2949 return err
2950 }, opts...)
2951 }
2952
2953 // BatchGetEffectiveIamPolicies gets effective IAM policies for a batch of resources.
2954 func (c *restClient) BatchGetEffectiveIamPolicies(ctx context.Context, req *assetpb.BatchGetEffectiveIamPoliciesRequest, opts ...gax.CallOption) (*assetpb.BatchGetEffectiveIamPoliciesResponse, error) {
2955 baseUrl, err := url.Parse(c.endpoint)
2956 if err != nil {
2957 return nil, err
2958 }
2959 baseUrl.Path += fmt.Sprintf("/v1/%v/effectiveIamPolicies:batchGet", req.GetScope())
2960
2961 params := url.Values{}
2962 params.Add("$alt", "json;enum-encoding=int")
2963 if items := req.GetNames(); len(items) > 0 {
2964 for _, item := range items {
2965 params.Add("names", fmt.Sprintf("%v", item))
2966 }
2967 }
2968
2969 baseUrl.RawQuery = params.Encode()
2970
2971 // Build HTTP headers from client and context metadata.
2972 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "scope", url.QueryEscape(req.GetScope()))}
2973
2974 hds = append(c.xGoogHeaders, hds...)
2975 hds = append(hds, "Content-Type", "application/json")
2976 headers := gax.BuildHeaders(ctx, hds...)
2977 opts = append((*c.CallOptions).BatchGetEffectiveIamPolicies[0:len((*c.CallOptions).BatchGetEffectiveIamPolicies):len((*c.CallOptions).BatchGetEffectiveIamPolicies)], opts...)
2978 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2979 resp := &assetpb.BatchGetEffectiveIamPoliciesResponse{}
2980 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2981 if settings.Path != "" {
2982 baseUrl.Path = settings.Path
2983 }
2984 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2985 if err != nil {
2986 return err
2987 }
2988 httpReq = httpReq.WithContext(ctx)
2989 httpReq.Header = headers
2990
2991 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "BatchGetEffectiveIamPolicies")
2992 if err != nil {
2993 return err
2994 }
2995
2996 if err := unm.Unmarshal(buf, resp); err != nil {
2997 return err
2998 }
2999
3000 return nil
3001 }, opts...)
3002 if e != nil {
3003 return nil, e
3004 }
3005 return resp, nil
3006 }
3007
3008 // AnalyzeOrgPolicies analyzes organization policies under a scope.
3009 func (c *restClient) AnalyzeOrgPolicies(ctx context.Context, req *assetpb.AnalyzeOrgPoliciesRequest, opts ...gax.CallOption) *AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator {
3010 it := &AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator{}
3011 req = proto.Clone(req).(*assetpb.AnalyzeOrgPoliciesRequest)
3012 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3013 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.AnalyzeOrgPoliciesResponse_OrgPolicyResult, string, error) {
3014 resp := &assetpb.AnalyzeOrgPoliciesResponse{}
3015 if pageToken != "" {
3016 req.PageToken = pageToken
3017 }
3018 if pageSize > math.MaxInt32 {
3019 req.PageSize = proto.Int32(int32(math.MaxInt32))
3020 } else if pageSize != 0 {
3021 req.PageSize = proto.Int32(int32(pageSize))
3022 }
3023 baseUrl, err := url.Parse(c.endpoint)
3024 if err != nil {
3025 return nil, "", err
3026 }
3027 baseUrl.Path += fmt.Sprintf("/v1/%v:analyzeOrgPolicies", req.GetScope())
3028
3029 params := url.Values{}
3030 params.Add("$alt", "json;enum-encoding=int")
3031 params.Add("constraint", fmt.Sprintf("%v", req.GetConstraint()))
3032 if req.GetFilter() != "" {
3033 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3034 }
3035 if req != nil && req.PageSize != nil {
3036 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3037 }
3038 if req.GetPageToken() != "" {
3039 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3040 }
3041
3042 baseUrl.RawQuery = params.Encode()
3043
3044 // Build HTTP headers from client and context metadata.
3045 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3046 headers := gax.BuildHeaders(ctx, hds...)
3047 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3048 if settings.Path != "" {
3049 baseUrl.Path = settings.Path
3050 }
3051 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3052 if err != nil {
3053 return err
3054 }
3055 httpReq.Header = headers
3056
3057 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "AnalyzeOrgPolicies")
3058 if err != nil {
3059 return err
3060 }
3061 if err := unm.Unmarshal(buf, resp); err != nil {
3062 return err
3063 }
3064
3065 return nil
3066 }, opts...)
3067 if e != nil {
3068 return nil, "", e
3069 }
3070 it.Response = resp
3071 return resp.GetOrgPolicyResults(), resp.GetNextPageToken(), nil
3072 }
3073
3074 fetch := func(pageSize int, pageToken string) (string, error) {
3075 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3076 if err != nil {
3077 return "", err
3078 }
3079 it.items = append(it.items, items...)
3080 return nextPageToken, nil
3081 }
3082
3083 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3084 it.pageInfo.MaxSize = int(req.GetPageSize())
3085 it.pageInfo.Token = req.GetPageToken()
3086
3087 return it
3088 }
3089
3090 // AnalyzeOrgPolicyGovernedContainers analyzes organization policies governed containers (projects, folders or
3091 // organization) under a scope.
3092 func (c *restClient) AnalyzeOrgPolicyGovernedContainers(ctx context.Context, req *assetpb.AnalyzeOrgPolicyGovernedContainersRequest, opts ...gax.CallOption) *AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator {
3093 it := &AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator{}
3094 req = proto.Clone(req).(*assetpb.AnalyzeOrgPolicyGovernedContainersRequest)
3095 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3096 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainer, string, error) {
3097 resp := &assetpb.AnalyzeOrgPolicyGovernedContainersResponse{}
3098 if pageToken != "" {
3099 req.PageToken = pageToken
3100 }
3101 if pageSize > math.MaxInt32 {
3102 req.PageSize = proto.Int32(int32(math.MaxInt32))
3103 } else if pageSize != 0 {
3104 req.PageSize = proto.Int32(int32(pageSize))
3105 }
3106 baseUrl, err := url.Parse(c.endpoint)
3107 if err != nil {
3108 return nil, "", err
3109 }
3110 baseUrl.Path += fmt.Sprintf("/v1/%v:analyzeOrgPolicyGovernedContainers", req.GetScope())
3111
3112 params := url.Values{}
3113 params.Add("$alt", "json;enum-encoding=int")
3114 params.Add("constraint", fmt.Sprintf("%v", req.GetConstraint()))
3115 if req.GetFilter() != "" {
3116 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3117 }
3118 if req != nil && req.PageSize != nil {
3119 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3120 }
3121 if req.GetPageToken() != "" {
3122 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3123 }
3124
3125 baseUrl.RawQuery = params.Encode()
3126
3127 // Build HTTP headers from client and context metadata.
3128 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3129 headers := gax.BuildHeaders(ctx, hds...)
3130 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3131 if settings.Path != "" {
3132 baseUrl.Path = settings.Path
3133 }
3134 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3135 if err != nil {
3136 return err
3137 }
3138 httpReq.Header = headers
3139
3140 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "AnalyzeOrgPolicyGovernedContainers")
3141 if err != nil {
3142 return err
3143 }
3144 if err := unm.Unmarshal(buf, resp); err != nil {
3145 return err
3146 }
3147
3148 return nil
3149 }, opts...)
3150 if e != nil {
3151 return nil, "", e
3152 }
3153 it.Response = resp
3154 return resp.GetGovernedContainers(), resp.GetNextPageToken(), nil
3155 }
3156
3157 fetch := func(pageSize int, pageToken string) (string, error) {
3158 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3159 if err != nil {
3160 return "", err
3161 }
3162 it.items = append(it.items, items...)
3163 return nextPageToken, nil
3164 }
3165
3166 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3167 it.pageInfo.MaxSize = int(req.GetPageSize())
3168 it.pageInfo.Token = req.GetPageToken()
3169
3170 return it
3171 }
3172
3173 // AnalyzeOrgPolicyGovernedAssets analyzes organization policies governed assets (Google Cloud resources or
3174 // policies) under a scope. This RPC supports custom constraints and the
3175 // following canned constraints:
3176 //
3177 // constraints/ainotebooks.accessMode
3178 //
3179 // constraints/ainotebooks.disableFileDownloads
3180 //
3181 // constraints/ainotebooks.disableRootAccess
3182 //
3183 // constraints/ainotebooks.disableTerminal
3184 //
3185 // constraints/ainotebooks.environmentOptions
3186 //
3187 // constraints/ainotebooks.requireAutoUpgradeSchedule
3188 //
3189 // constraints/ainotebooks.restrictVpcNetworks
3190 //
3191 // constraints/compute.disableGuestAttributesAccess
3192 //
3193 // constraints/compute.disableInstanceDataAccessApis
3194 //
3195 // constraints/compute.disableNestedVirtualization
3196 //
3197 // constraints/compute.disableSerialPortAccess
3198 //
3199 // constraints/compute.disableSerialPortLogging
3200 //
3201 // constraints/compute.disableVpcExternalIpv6
3202 //
3203 // constraints/compute.requireOsLogin
3204 //
3205 // constraints/compute.requireShieldedVm
3206 //
3207 // constraints/compute.restrictLoadBalancerCreationForTypes
3208 //
3209 // constraints/compute.restrictProtocolForwardingCreationForTypes
3210 //
3211 // constraints/compute.restrictXpnProjectLienRemoval
3212 //
3213 // constraints/compute.setNewProjectDefaultToZonalDNSOnly
3214 //
3215 // constraints/compute.skipDefaultNetworkCreation
3216 //
3217 // constraints/compute.trustedImageProjects
3218 //
3219 // constraints/compute.vmCanIpForward
3220 //
3221 // constraints/compute.vmExternalIpAccess
3222 //
3223 // constraints/gcp.detailedAuditLoggingMode
3224 //
3225 // constraints/gcp.resourceLocations
3226 //
3227 // constraints/iam.allowedPolicyMemberDomains
3228 //
3229 // constraints/iam.automaticIamGrantsForDefaultServiceAccounts
3230 //
3231 // constraints/iam.disableServiceAccountCreation
3232 //
3233 // constraints/iam.disableServiceAccountKeyCreation
3234 //
3235 // constraints/iam.disableServiceAccountKeyUpload
3236 //
3237 // constraints/iam.restrictCrossProjectServiceAccountLienRemoval
3238 //
3239 // constraints/iam.serviceAccountKeyExpiryHours
3240 //
3241 // constraints/resourcemanager.accessBoundaries
3242 //
3243 // constraints/resourcemanager.allowedExportDestinations
3244 //
3245 // constraints/sql.restrictAuthorizedNetworks
3246 //
3247 // constraints/sql.restrictNoncompliantDiagnosticDataAccess
3248 //
3249 // constraints/sql.restrictNoncompliantResourceCreation
3250 //
3251 // constraints/sql.restrictPublicIp
3252 //
3253 // constraints/storage.publicAccessPrevention
3254 //
3255 // constraints/storage.restrictAuthTypes
3256 //
3257 // constraints/storage.uniformBucketLevelAccess
3258 //
3259 // This RPC only returns either resources of types supported by search
3260 // APIs (at https://cloud.google.com/asset-inventory/docs/supported-asset-types)
3261 // or IAM policies.
3262 func (c *restClient) AnalyzeOrgPolicyGovernedAssets(ctx context.Context, req *assetpb.AnalyzeOrgPolicyGovernedAssetsRequest, opts ...gax.CallOption) *AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator {
3263 it := &AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator{}
3264 req = proto.Clone(req).(*assetpb.AnalyzeOrgPolicyGovernedAssetsRequest)
3265 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3266 it.InternalFetch = func(pageSize int, pageToken string) ([]*assetpb.AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAsset, string, error) {
3267 resp := &assetpb.AnalyzeOrgPolicyGovernedAssetsResponse{}
3268 if pageToken != "" {
3269 req.PageToken = pageToken
3270 }
3271 if pageSize > math.MaxInt32 {
3272 req.PageSize = proto.Int32(int32(math.MaxInt32))
3273 } else if pageSize != 0 {
3274 req.PageSize = proto.Int32(int32(pageSize))
3275 }
3276 baseUrl, err := url.Parse(c.endpoint)
3277 if err != nil {
3278 return nil, "", err
3279 }
3280 baseUrl.Path += fmt.Sprintf("/v1/%v:analyzeOrgPolicyGovernedAssets", req.GetScope())
3281
3282 params := url.Values{}
3283 params.Add("$alt", "json;enum-encoding=int")
3284 params.Add("constraint", fmt.Sprintf("%v", req.GetConstraint()))
3285 if req.GetFilter() != "" {
3286 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3287 }
3288 if req != nil && req.PageSize != nil {
3289 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3290 }
3291 if req.GetPageToken() != "" {
3292 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3293 }
3294
3295 baseUrl.RawQuery = params.Encode()
3296
3297 // Build HTTP headers from client and context metadata.
3298 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3299 headers := gax.BuildHeaders(ctx, hds...)
3300 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3301 if settings.Path != "" {
3302 baseUrl.Path = settings.Path
3303 }
3304 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3305 if err != nil {
3306 return err
3307 }
3308 httpReq.Header = headers
3309
3310 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "AnalyzeOrgPolicyGovernedAssets")
3311 if err != nil {
3312 return err
3313 }
3314 if err := unm.Unmarshal(buf, resp); err != nil {
3315 return err
3316 }
3317
3318 return nil
3319 }, opts...)
3320 if e != nil {
3321 return nil, "", e
3322 }
3323 it.Response = resp
3324 return resp.GetGovernedAssets(), resp.GetNextPageToken(), nil
3325 }
3326
3327 fetch := func(pageSize int, pageToken string) (string, error) {
3328 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3329 if err != nil {
3330 return "", err
3331 }
3332 it.items = append(it.items, items...)
3333 return nextPageToken, nil
3334 }
3335
3336 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3337 it.pageInfo.MaxSize = int(req.GetPageSize())
3338 it.pageInfo.Token = req.GetPageToken()
3339
3340 return it
3341 }
3342
3343 // GetOperation is a utility method from google.longrunning.Operations.
3344 func (c *restClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
3345 baseUrl, err := url.Parse(c.endpoint)
3346 if err != nil {
3347 return nil, err
3348 }
3349 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
3350
3351 params := url.Values{}
3352 params.Add("$alt", "json;enum-encoding=int")
3353
3354 baseUrl.RawQuery = params.Encode()
3355
3356 // Build HTTP headers from client and context metadata.
3357 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3358
3359 hds = append(c.xGoogHeaders, hds...)
3360 hds = append(hds, "Content-Type", "application/json")
3361 headers := gax.BuildHeaders(ctx, hds...)
3362 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
3363 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3364 resp := &longrunningpb.Operation{}
3365 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3366 if settings.Path != "" {
3367 baseUrl.Path = settings.Path
3368 }
3369 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3370 if err != nil {
3371 return err
3372 }
3373 httpReq = httpReq.WithContext(ctx)
3374 httpReq.Header = headers
3375
3376 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
3377 if err != nil {
3378 return err
3379 }
3380
3381 if err := unm.Unmarshal(buf, resp); err != nil {
3382 return err
3383 }
3384
3385 return nil
3386 }, opts...)
3387 if e != nil {
3388 return nil, e
3389 }
3390 return resp, nil
3391 }
3392
3393 // AnalyzeIamPolicyLongrunningOperation returns a new AnalyzeIamPolicyLongrunningOperation from a given name.
3394 // The name must be that of a previously created AnalyzeIamPolicyLongrunningOperation, possibly from a different process.
3395 func (c *gRPCClient) AnalyzeIamPolicyLongrunningOperation(name string) *AnalyzeIamPolicyLongrunningOperation {
3396 return &AnalyzeIamPolicyLongrunningOperation{
3397 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3398 }
3399 }
3400
3401 // AnalyzeIamPolicyLongrunningOperation returns a new AnalyzeIamPolicyLongrunningOperation from a given name.
3402 // The name must be that of a previously created AnalyzeIamPolicyLongrunningOperation, possibly from a different process.
3403 func (c *restClient) AnalyzeIamPolicyLongrunningOperation(name string) *AnalyzeIamPolicyLongrunningOperation {
3404 override := fmt.Sprintf("/v1/%s", name)
3405 return &AnalyzeIamPolicyLongrunningOperation{
3406 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3407 pollPath: override,
3408 }
3409 }
3410
3411 // ExportAssetsOperation returns a new ExportAssetsOperation from a given name.
3412 // The name must be that of a previously created ExportAssetsOperation, possibly from a different process.
3413 func (c *gRPCClient) ExportAssetsOperation(name string) *ExportAssetsOperation {
3414 return &ExportAssetsOperation{
3415 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3416 }
3417 }
3418
3419 // ExportAssetsOperation returns a new ExportAssetsOperation from a given name.
3420 // The name must be that of a previously created ExportAssetsOperation, possibly from a different process.
3421 func (c *restClient) ExportAssetsOperation(name string) *ExportAssetsOperation {
3422 override := fmt.Sprintf("/v1/%s", name)
3423 return &ExportAssetsOperation{
3424 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3425 pollPath: override,
3426 }
3427 }