Debian Codegraph @

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