Debian Codegraph @

asset/apiv1/auxiliary.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 "context"
21 "time"
22
23 assetpb "cloud.google.com/go/asset/apiv1/assetpb"
24 "cloud.google.com/go/longrunning"
25 gax "github.com/googleapis/gax-go/v2"
26 "google.golang.org/api/iterator"
27 )
28
29 // AnalyzeIamPolicyLongrunningOperation manages a long-running operation from AnalyzeIamPolicyLongrunning.
30 type AnalyzeIamPolicyLongrunningOperation struct {
31 lro *longrunning.Operation
32 pollPath string
33 }
34
35 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
36 //
37 // See documentation of Poll for error-handling information.
38 func (op *AnalyzeIamPolicyLongrunningOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*assetpb.AnalyzeIamPolicyLongrunningResponse, error) {
39 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
40 var resp assetpb.AnalyzeIamPolicyLongrunningResponse
41 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
42 return nil, err
43 }
44 return &resp, nil
45 }
46
47 // Poll fetches the latest state of the long-running operation.
48 //
49 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
50 //
51 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
52 // the operation has completed with failure, the error is returned and op.Done will return true.
53 // If Poll succeeds and the operation has completed successfully,
54 // op.Done will return true, and the response of the operation is returned.
55 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
56 func (op *AnalyzeIamPolicyLongrunningOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*assetpb.AnalyzeIamPolicyLongrunningResponse, error) {
57 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
58 var resp assetpb.AnalyzeIamPolicyLongrunningResponse
59 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
60 return nil, err
61 }
62 if !op.Done() {
63 return nil, nil
64 }
65 return &resp, nil
66 }
67
68 // Metadata returns metadata associated with the long-running operation.
69 // Metadata itself does not contact the server, but Poll does.
70 // To get the latest metadata, call this method after a successful call to Poll.
71 // If the metadata is not available, the returned metadata and error are both nil.
72 func (op *AnalyzeIamPolicyLongrunningOperation) Metadata() (*assetpb.AnalyzeIamPolicyLongrunningMetadata, error) {
73 var meta assetpb.AnalyzeIamPolicyLongrunningMetadata
74 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
75 return nil, nil
76 } else if err != nil {
77 return nil, err
78 }
79 return &meta, nil
80 }
81
82 // Done reports whether the long-running operation has completed.
83 func (op *AnalyzeIamPolicyLongrunningOperation) Done() bool {
84 return op.lro.Done()
85 }
86
87 // Name returns the name of the long-running operation.
88 // The name is assigned by the server and is unique within the service from which the operation is created.
89 func (op *AnalyzeIamPolicyLongrunningOperation) Name() string {
90 return op.lro.Name()
91 }
92
93 // ExportAssetsOperation manages a long-running operation from ExportAssets.
94 type ExportAssetsOperation struct {
95 lro *longrunning.Operation
96 pollPath string
97 }
98
99 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
100 //
101 // See documentation of Poll for error-handling information.
102 func (op *ExportAssetsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*assetpb.ExportAssetsResponse, error) {
103 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
104 var resp assetpb.ExportAssetsResponse
105 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
106 return nil, err
107 }
108 return &resp, nil
109 }
110
111 // Poll fetches the latest state of the long-running operation.
112 //
113 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
114 //
115 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
116 // the operation has completed with failure, the error is returned and op.Done will return true.
117 // If Poll succeeds and the operation has completed successfully,
118 // op.Done will return true, and the response of the operation is returned.
119 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
120 func (op *ExportAssetsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*assetpb.ExportAssetsResponse, error) {
121 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
122 var resp assetpb.ExportAssetsResponse
123 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
124 return nil, err
125 }
126 if !op.Done() {
127 return nil, nil
128 }
129 return &resp, nil
130 }
131
132 // Metadata returns metadata associated with the long-running operation.
133 // Metadata itself does not contact the server, but Poll does.
134 // To get the latest metadata, call this method after a successful call to Poll.
135 // If the metadata is not available, the returned metadata and error are both nil.
136 func (op *ExportAssetsOperation) Metadata() (*assetpb.ExportAssetsRequest, error) {
137 var meta assetpb.ExportAssetsRequest
138 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
139 return nil, nil
140 } else if err != nil {
141 return nil, err
142 }
143 return &meta, nil
144 }
145
146 // Done reports whether the long-running operation has completed.
147 func (op *ExportAssetsOperation) Done() bool {
148 return op.lro.Done()
149 }
150
151 // Name returns the name of the long-running operation.
152 // The name is assigned by the server and is unique within the service from which the operation is created.
153 func (op *ExportAssetsOperation) Name() string {
154 return op.lro.Name()
155 }
156
157 // AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator manages a stream of *assetpb.AnalyzeOrgPoliciesResponse_OrgPolicyResult.
158 type AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator struct {
159 items []*assetpb.AnalyzeOrgPoliciesResponse_OrgPolicyResult
160 pageInfo *iterator.PageInfo
161 nextFunc func() error
162
163 // Response is the raw response for the current page.
164 // It must be cast to the RPC response type.
165 // Calling Next() or InternalFetch() updates this value.
166 Response interface{}
167
168 // InternalFetch is for use by the Google Cloud Libraries only.
169 // It is not part of the stable interface of this package.
170 //
171 // InternalFetch returns results from a single call to the underlying RPC.
172 // The number of results is no greater than pageSize.
173 // If there are no more results, nextPageToken is empty and err is nil.
174 InternalFetch func(pageSize int, pageToken string) (results []*assetpb.AnalyzeOrgPoliciesResponse_OrgPolicyResult, nextPageToken string, err error)
175 }
176
177 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
178 func (it *AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator) PageInfo() *iterator.PageInfo {
179 return it.pageInfo
180 }
181
182 // Next returns the next result. Its second return value is iterator.Done if there are no more
183 // results. Once Next returns Done, all subsequent calls will return Done.
184 func (it *AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator) Next() (*assetpb.AnalyzeOrgPoliciesResponse_OrgPolicyResult, error) {
185 var item *assetpb.AnalyzeOrgPoliciesResponse_OrgPolicyResult
186 if err := it.nextFunc(); err != nil {
187 return item, err
188 }
189 item = it.items[0]
190 it.items = it.items[1:]
191 return item, nil
192 }
193
194 func (it *AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator) bufLen() int {
195 return len(it.items)
196 }
197
198 func (it *AnalyzeOrgPoliciesResponse_OrgPolicyResultIterator) takeBuf() interface{} {
199 b := it.items
200 it.items = nil
201 return b
202 }
203
204 // AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator manages a stream of *assetpb.AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAsset.
205 type AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator struct {
206 items []*assetpb.AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAsset
207 pageInfo *iterator.PageInfo
208 nextFunc func() error
209
210 // Response is the raw response for the current page.
211 // It must be cast to the RPC response type.
212 // Calling Next() or InternalFetch() updates this value.
213 Response interface{}
214
215 // InternalFetch is for use by the Google Cloud Libraries only.
216 // It is not part of the stable interface of this package.
217 //
218 // InternalFetch returns results from a single call to the underlying RPC.
219 // The number of results is no greater than pageSize.
220 // If there are no more results, nextPageToken is empty and err is nil.
221 InternalFetch func(pageSize int, pageToken string) (results []*assetpb.AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAsset, nextPageToken string, err error)
222 }
223
224 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
225 func (it *AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator) PageInfo() *iterator.PageInfo {
226 return it.pageInfo
227 }
228
229 // Next returns the next result. Its second return value is iterator.Done if there are no more
230 // results. Once Next returns Done, all subsequent calls will return Done.
231 func (it *AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator) Next() (*assetpb.AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAsset, error) {
232 var item *assetpb.AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAsset
233 if err := it.nextFunc(); err != nil {
234 return item, err
235 }
236 item = it.items[0]
237 it.items = it.items[1:]
238 return item, nil
239 }
240
241 func (it *AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator) bufLen() int {
242 return len(it.items)
243 }
244
245 func (it *AnalyzeOrgPolicyGovernedAssetsResponse_GovernedAssetIterator) takeBuf() interface{} {
246 b := it.items
247 it.items = nil
248 return b
249 }
250
251 // AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator manages a stream of *assetpb.AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainer.
252 type AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator struct {
253 items []*assetpb.AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainer
254 pageInfo *iterator.PageInfo
255 nextFunc func() error
256
257 // Response is the raw response for the current page.
258 // It must be cast to the RPC response type.
259 // Calling Next() or InternalFetch() updates this value.
260 Response interface{}
261
262 // InternalFetch is for use by the Google Cloud Libraries only.
263 // It is not part of the stable interface of this package.
264 //
265 // InternalFetch returns results from a single call to the underlying RPC.
266 // The number of results is no greater than pageSize.
267 // If there are no more results, nextPageToken is empty and err is nil.
268 InternalFetch func(pageSize int, pageToken string) (results []*assetpb.AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainer, nextPageToken string, err error)
269 }
270
271 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
272 func (it *AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator) PageInfo() *iterator.PageInfo {
273 return it.pageInfo
274 }
275
276 // Next returns the next result. Its second return value is iterator.Done if there are no more
277 // results. Once Next returns Done, all subsequent calls will return Done.
278 func (it *AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator) Next() (*assetpb.AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainer, error) {
279 var item *assetpb.AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainer
280 if err := it.nextFunc(); err != nil {
281 return item, err
282 }
283 item = it.items[0]
284 it.items = it.items[1:]
285 return item, nil
286 }
287
288 func (it *AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator) bufLen() int {
289 return len(it.items)
290 }
291
292 func (it *AnalyzeOrgPolicyGovernedContainersResponse_GovernedContainerIterator) takeBuf() interface{} {
293 b := it.items
294 it.items = nil
295 return b
296 }
297
298 // AssetIterator manages a stream of *assetpb.Asset.
299 type AssetIterator struct {
300 items []*assetpb.Asset
301 pageInfo *iterator.PageInfo
302 nextFunc func() error
303
304 // Response is the raw response for the current page.
305 // It must be cast to the RPC response type.
306 // Calling Next() or InternalFetch() updates this value.
307 Response interface{}
308
309 // InternalFetch is for use by the Google Cloud Libraries only.
310 // It is not part of the stable interface of this package.
311 //
312 // InternalFetch returns results from a single call to the underlying RPC.
313 // The number of results is no greater than pageSize.
314 // If there are no more results, nextPageToken is empty and err is nil.
315 InternalFetch func(pageSize int, pageToken string) (results []*assetpb.Asset, nextPageToken string, err error)
316 }
317
318 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
319 func (it *AssetIterator) PageInfo() *iterator.PageInfo {
320 return it.pageInfo
321 }
322
323 // Next returns the next result. Its second return value is iterator.Done if there are no more
324 // results. Once Next returns Done, all subsequent calls will return Done.
325 func (it *AssetIterator) Next() (*assetpb.Asset, error) {
326 var item *assetpb.Asset
327 if err := it.nextFunc(); err != nil {
328 return item, err
329 }
330 item = it.items[0]
331 it.items = it.items[1:]
332 return item, nil
333 }
334
335 func (it *AssetIterator) bufLen() int {
336 return len(it.items)
337 }
338
339 func (it *AssetIterator) takeBuf() interface{} {
340 b := it.items
341 it.items = nil
342 return b
343 }
344
345 // IamPolicySearchResultIterator manages a stream of *assetpb.IamPolicySearchResult.
346 type IamPolicySearchResultIterator struct {
347 items []*assetpb.IamPolicySearchResult
348 pageInfo *iterator.PageInfo
349 nextFunc func() error
350
351 // Response is the raw response for the current page.
352 // It must be cast to the RPC response type.
353 // Calling Next() or InternalFetch() updates this value.
354 Response interface{}
355
356 // InternalFetch is for use by the Google Cloud Libraries only.
357 // It is not part of the stable interface of this package.
358 //
359 // InternalFetch returns results from a single call to the underlying RPC.
360 // The number of results is no greater than pageSize.
361 // If there are no more results, nextPageToken is empty and err is nil.
362 InternalFetch func(pageSize int, pageToken string) (results []*assetpb.IamPolicySearchResult, nextPageToken string, err error)
363 }
364
365 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
366 func (it *IamPolicySearchResultIterator) PageInfo() *iterator.PageInfo {
367 return it.pageInfo
368 }
369
370 // Next returns the next result. Its second return value is iterator.Done if there are no more
371 // results. Once Next returns Done, all subsequent calls will return Done.
372 func (it *IamPolicySearchResultIterator) Next() (*assetpb.IamPolicySearchResult, error) {
373 var item *assetpb.IamPolicySearchResult
374 if err := it.nextFunc(); err != nil {
375 return item, err
376 }
377 item = it.items[0]
378 it.items = it.items[1:]
379 return item, nil
380 }
381
382 func (it *IamPolicySearchResultIterator) bufLen() int {
383 return len(it.items)
384 }
385
386 func (it *IamPolicySearchResultIterator) takeBuf() interface{} {
387 b := it.items
388 it.items = nil
389 return b
390 }
391
392 // ResourceSearchResultIterator manages a stream of *assetpb.ResourceSearchResult.
393 type ResourceSearchResultIterator struct {
394 items []*assetpb.ResourceSearchResult
395 pageInfo *iterator.PageInfo
396 nextFunc func() error
397
398 // Response is the raw response for the current page.
399 // It must be cast to the RPC response type.
400 // Calling Next() or InternalFetch() updates this value.
401 Response interface{}
402
403 // InternalFetch is for use by the Google Cloud Libraries only.
404 // It is not part of the stable interface of this package.
405 //
406 // InternalFetch returns results from a single call to the underlying RPC.
407 // The number of results is no greater than pageSize.
408 // If there are no more results, nextPageToken is empty and err is nil.
409 InternalFetch func(pageSize int, pageToken string) (results []*assetpb.ResourceSearchResult, nextPageToken string, err error)
410 }
411
412 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
413 func (it *ResourceSearchResultIterator) PageInfo() *iterator.PageInfo {
414 return it.pageInfo
415 }
416
417 // Next returns the next result. Its second return value is iterator.Done if there are no more
418 // results. Once Next returns Done, all subsequent calls will return Done.
419 func (it *ResourceSearchResultIterator) Next() (*assetpb.ResourceSearchResult, error) {
420 var item *assetpb.ResourceSearchResult
421 if err := it.nextFunc(); err != nil {
422 return item, err
423 }
424 item = it.items[0]
425 it.items = it.items[1:]
426 return item, nil
427 }
428
429 func (it *ResourceSearchResultIterator) bufLen() int {
430 return len(it.items)
431 }
432
433 func (it *ResourceSearchResultIterator) takeBuf() interface{} {
434 b := it.items
435 it.items = nil
436 return b
437 }
438
439 // SavedQueryIterator manages a stream of *assetpb.SavedQuery.
440 type SavedQueryIterator struct {
441 items []*assetpb.SavedQuery
442 pageInfo *iterator.PageInfo
443 nextFunc func() error
444
445 // Response is the raw response for the current page.
446 // It must be cast to the RPC response type.
447 // Calling Next() or InternalFetch() updates this value.
448 Response interface{}
449
450 // InternalFetch is for use by the Google Cloud Libraries only.
451 // It is not part of the stable interface of this package.
452 //
453 // InternalFetch returns results from a single call to the underlying RPC.
454 // The number of results is no greater than pageSize.
455 // If there are no more results, nextPageToken is empty and err is nil.
456 InternalFetch func(pageSize int, pageToken string) (results []*assetpb.SavedQuery, nextPageToken string, err error)
457 }
458
459 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
460 func (it *SavedQueryIterator) PageInfo() *iterator.PageInfo {
461 return it.pageInfo
462 }
463
464 // Next returns the next result. Its second return value is iterator.Done if there are no more
465 // results. Once Next returns Done, all subsequent calls will return Done.
466 func (it *SavedQueryIterator) Next() (*assetpb.SavedQuery, error) {
467 var item *assetpb.SavedQuery
468 if err := it.nextFunc(); err != nil {
469 return item, err
470 }
471 item = it.items[0]
472 it.items = it.items[1:]
473 return item, nil
474 }
475
476 func (it *SavedQueryIterator) bufLen() int {
477 return len(it.items)
478 }
479
480 func (it *SavedQueryIterator) takeBuf() interface{} {
481 b := it.items
482 it.items = nil
483 return b
484 }