Debian Codegraph @

firestore/apiv1/admin/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 apiv1
18
19 import (
20 "context"
21 "time"
22
23 adminpb "cloud.google.com/go/firestore/apiv1/admin/adminpb"
24 "cloud.google.com/go/longrunning"
25 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
26 gax "github.com/googleapis/gax-go/v2"
27 "google.golang.org/api/iterator"
28 )
29
30 // BulkDeleteDocumentsOperation manages a long-running operation from BulkDeleteDocuments.
31 type BulkDeleteDocumentsOperation struct {
32 lro *longrunning.Operation
33 pollPath string
34 }
35
36 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
37 //
38 // See documentation of Poll for error-handling information.
39 func (op *BulkDeleteDocumentsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.BulkDeleteDocumentsResponse, error) {
40 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
41 var resp adminpb.BulkDeleteDocumentsResponse
42 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
43 return nil, err
44 }
45 return &resp, nil
46 }
47
48 // Poll fetches the latest state of the long-running operation.
49 //
50 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
51 //
52 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
53 // the operation has completed with failure, the error is returned and op.Done will return true.
54 // If Poll succeeds and the operation has completed successfully,
55 // op.Done will return true, and the response of the operation is returned.
56 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
57 func (op *BulkDeleteDocumentsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.BulkDeleteDocumentsResponse, error) {
58 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
59 var resp adminpb.BulkDeleteDocumentsResponse
60 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
61 return nil, err
62 }
63 if !op.Done() {
64 return nil, nil
65 }
66 return &resp, nil
67 }
68
69 // Metadata returns metadata associated with the long-running operation.
70 // Metadata itself does not contact the server, but Poll does.
71 // To get the latest metadata, call this method after a successful call to Poll.
72 // If the metadata is not available, the returned metadata and error are both nil.
73 func (op *BulkDeleteDocumentsOperation) Metadata() (*adminpb.BulkDeleteDocumentsMetadata, error) {
74 var meta adminpb.BulkDeleteDocumentsMetadata
75 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
76 return nil, nil
77 } else if err != nil {
78 return nil, err
79 }
80 return &meta, nil
81 }
82
83 // Done reports whether the long-running operation has completed.
84 func (op *BulkDeleteDocumentsOperation) Done() bool {
85 return op.lro.Done()
86 }
87
88 // Name returns the name of the long-running operation.
89 // The name is assigned by the server and is unique within the service from which the operation is created.
90 func (op *BulkDeleteDocumentsOperation) Name() string {
91 return op.lro.Name()
92 }
93
94 // CloneDatabaseOperation manages a long-running operation from CloneDatabase.
95 type CloneDatabaseOperation struct {
96 lro *longrunning.Operation
97 pollPath string
98 }
99
100 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
101 //
102 // See documentation of Poll for error-handling information.
103 func (op *CloneDatabaseOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
104 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
105 var resp adminpb.Database
106 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
107 return nil, err
108 }
109 return &resp, nil
110 }
111
112 // Poll fetches the latest state of the long-running operation.
113 //
114 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
115 //
116 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
117 // the operation has completed with failure, the error is returned and op.Done will return true.
118 // If Poll succeeds and the operation has completed successfully,
119 // op.Done will return true, and the response of the operation is returned.
120 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
121 func (op *CloneDatabaseOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
122 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
123 var resp adminpb.Database
124 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
125 return nil, err
126 }
127 if !op.Done() {
128 return nil, nil
129 }
130 return &resp, nil
131 }
132
133 // Metadata returns metadata associated with the long-running operation.
134 // Metadata itself does not contact the server, but Poll does.
135 // To get the latest metadata, call this method after a successful call to Poll.
136 // If the metadata is not available, the returned metadata and error are both nil.
137 func (op *CloneDatabaseOperation) Metadata() (*adminpb.CloneDatabaseMetadata, error) {
138 var meta adminpb.CloneDatabaseMetadata
139 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
140 return nil, nil
141 } else if err != nil {
142 return nil, err
143 }
144 return &meta, nil
145 }
146
147 // Done reports whether the long-running operation has completed.
148 func (op *CloneDatabaseOperation) Done() bool {
149 return op.lro.Done()
150 }
151
152 // Name returns the name of the long-running operation.
153 // The name is assigned by the server and is unique within the service from which the operation is created.
154 func (op *CloneDatabaseOperation) Name() string {
155 return op.lro.Name()
156 }
157
158 // CreateDatabaseOperation manages a long-running operation from CreateDatabase.
159 type CreateDatabaseOperation struct {
160 lro *longrunning.Operation
161 pollPath string
162 }
163
164 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
165 //
166 // See documentation of Poll for error-handling information.
167 func (op *CreateDatabaseOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
168 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
169 var resp adminpb.Database
170 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
171 return nil, err
172 }
173 return &resp, nil
174 }
175
176 // Poll fetches the latest state of the long-running operation.
177 //
178 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
179 //
180 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
181 // the operation has completed with failure, the error is returned and op.Done will return true.
182 // If Poll succeeds and the operation has completed successfully,
183 // op.Done will return true, and the response of the operation is returned.
184 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
185 func (op *CreateDatabaseOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
186 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
187 var resp adminpb.Database
188 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
189 return nil, err
190 }
191 if !op.Done() {
192 return nil, nil
193 }
194 return &resp, nil
195 }
196
197 // Metadata returns metadata associated with the long-running operation.
198 // Metadata itself does not contact the server, but Poll does.
199 // To get the latest metadata, call this method after a successful call to Poll.
200 // If the metadata is not available, the returned metadata and error are both nil.
201 func (op *CreateDatabaseOperation) Metadata() (*adminpb.CreateDatabaseMetadata, error) {
202 var meta adminpb.CreateDatabaseMetadata
203 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
204 return nil, nil
205 } else if err != nil {
206 return nil, err
207 }
208 return &meta, nil
209 }
210
211 // Done reports whether the long-running operation has completed.
212 func (op *CreateDatabaseOperation) Done() bool {
213 return op.lro.Done()
214 }
215
216 // Name returns the name of the long-running operation.
217 // The name is assigned by the server and is unique within the service from which the operation is created.
218 func (op *CreateDatabaseOperation) Name() string {
219 return op.lro.Name()
220 }
221
222 // CreateIndexOperation manages a long-running operation from CreateIndex.
223 type CreateIndexOperation struct {
224 lro *longrunning.Operation
225 pollPath string
226 }
227
228 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
229 //
230 // See documentation of Poll for error-handling information.
231 func (op *CreateIndexOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, error) {
232 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
233 var resp adminpb.Index
234 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
235 return nil, err
236 }
237 return &resp, nil
238 }
239
240 // Poll fetches the latest state of the long-running operation.
241 //
242 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
243 //
244 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
245 // the operation has completed with failure, the error is returned and op.Done will return true.
246 // If Poll succeeds and the operation has completed successfully,
247 // op.Done will return true, and the response of the operation is returned.
248 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
249 func (op *CreateIndexOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Index, error) {
250 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
251 var resp adminpb.Index
252 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
253 return nil, err
254 }
255 if !op.Done() {
256 return nil, nil
257 }
258 return &resp, nil
259 }
260
261 // Metadata returns metadata associated with the long-running operation.
262 // Metadata itself does not contact the server, but Poll does.
263 // To get the latest metadata, call this method after a successful call to Poll.
264 // If the metadata is not available, the returned metadata and error are both nil.
265 func (op *CreateIndexOperation) Metadata() (*adminpb.IndexOperationMetadata, error) {
266 var meta adminpb.IndexOperationMetadata
267 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
268 return nil, nil
269 } else if err != nil {
270 return nil, err
271 }
272 return &meta, nil
273 }
274
275 // Done reports whether the long-running operation has completed.
276 func (op *CreateIndexOperation) Done() bool {
277 return op.lro.Done()
278 }
279
280 // Name returns the name of the long-running operation.
281 // The name is assigned by the server and is unique within the service from which the operation is created.
282 func (op *CreateIndexOperation) Name() string {
283 return op.lro.Name()
284 }
285
286 // DeleteDatabaseOperation manages a long-running operation from DeleteDatabase.
287 type DeleteDatabaseOperation struct {
288 lro *longrunning.Operation
289 pollPath string
290 }
291
292 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
293 //
294 // See documentation of Poll for error-handling information.
295 func (op *DeleteDatabaseOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
296 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
297 var resp adminpb.Database
298 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
299 return nil, err
300 }
301 return &resp, nil
302 }
303
304 // Poll fetches the latest state of the long-running operation.
305 //
306 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
307 //
308 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
309 // the operation has completed with failure, the error is returned and op.Done will return true.
310 // If Poll succeeds and the operation has completed successfully,
311 // op.Done will return true, and the response of the operation is returned.
312 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
313 func (op *DeleteDatabaseOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
314 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
315 var resp adminpb.Database
316 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
317 return nil, err
318 }
319 if !op.Done() {
320 return nil, nil
321 }
322 return &resp, nil
323 }
324
325 // Metadata returns metadata associated with the long-running operation.
326 // Metadata itself does not contact the server, but Poll does.
327 // To get the latest metadata, call this method after a successful call to Poll.
328 // If the metadata is not available, the returned metadata and error are both nil.
329 func (op *DeleteDatabaseOperation) Metadata() (*adminpb.DeleteDatabaseMetadata, error) {
330 var meta adminpb.DeleteDatabaseMetadata
331 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
332 return nil, nil
333 } else if err != nil {
334 return nil, err
335 }
336 return &meta, nil
337 }
338
339 // Done reports whether the long-running operation has completed.
340 func (op *DeleteDatabaseOperation) Done() bool {
341 return op.lro.Done()
342 }
343
344 // Name returns the name of the long-running operation.
345 // The name is assigned by the server and is unique within the service from which the operation is created.
346 func (op *DeleteDatabaseOperation) Name() string {
347 return op.lro.Name()
348 }
349
350 // ExportDocumentsOperation manages a long-running operation from ExportDocuments.
351 type ExportDocumentsOperation struct {
352 lro *longrunning.Operation
353 pollPath string
354 }
355
356 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
357 //
358 // See documentation of Poll for error-handling information.
359 func (op *ExportDocumentsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.ExportDocumentsResponse, error) {
360 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
361 var resp adminpb.ExportDocumentsResponse
362 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
363 return nil, err
364 }
365 return &resp, nil
366 }
367
368 // Poll fetches the latest state of the long-running operation.
369 //
370 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
371 //
372 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
373 // the operation has completed with failure, the error is returned and op.Done will return true.
374 // If Poll succeeds and the operation has completed successfully,
375 // op.Done will return true, and the response of the operation is returned.
376 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
377 func (op *ExportDocumentsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.ExportDocumentsResponse, error) {
378 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
379 var resp adminpb.ExportDocumentsResponse
380 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
381 return nil, err
382 }
383 if !op.Done() {
384 return nil, nil
385 }
386 return &resp, nil
387 }
388
389 // Metadata returns metadata associated with the long-running operation.
390 // Metadata itself does not contact the server, but Poll does.
391 // To get the latest metadata, call this method after a successful call to Poll.
392 // If the metadata is not available, the returned metadata and error are both nil.
393 func (op *ExportDocumentsOperation) Metadata() (*adminpb.ExportDocumentsMetadata, error) {
394 var meta adminpb.ExportDocumentsMetadata
395 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
396 return nil, nil
397 } else if err != nil {
398 return nil, err
399 }
400 return &meta, nil
401 }
402
403 // Done reports whether the long-running operation has completed.
404 func (op *ExportDocumentsOperation) Done() bool {
405 return op.lro.Done()
406 }
407
408 // Name returns the name of the long-running operation.
409 // The name is assigned by the server and is unique within the service from which the operation is created.
410 func (op *ExportDocumentsOperation) Name() string {
411 return op.lro.Name()
412 }
413
414 // ImportDocumentsOperation manages a long-running operation from ImportDocuments.
415 type ImportDocumentsOperation struct {
416 lro *longrunning.Operation
417 pollPath string
418 }
419
420 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
421 //
422 // See documentation of Poll for error-handling information.
423 func (op *ImportDocumentsOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
424 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
425 return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
426 }
427
428 // Poll fetches the latest state of the long-running operation.
429 //
430 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
431 //
432 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
433 // the operation has completed with failure, the error is returned and op.Done will return true.
434 // If Poll succeeds and the operation has completed successfully,
435 // op.Done will return true, and the response of the operation is returned.
436 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
437 func (op *ImportDocumentsOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
438 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
439 return op.lro.Poll(ctx, nil, opts...)
440 }
441
442 // Metadata returns metadata associated with the long-running operation.
443 // Metadata itself does not contact the server, but Poll does.
444 // To get the latest metadata, call this method after a successful call to Poll.
445 // If the metadata is not available, the returned metadata and error are both nil.
446 func (op *ImportDocumentsOperation) Metadata() (*adminpb.ImportDocumentsMetadata, error) {
447 var meta adminpb.ImportDocumentsMetadata
448 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
449 return nil, nil
450 } else if err != nil {
451 return nil, err
452 }
453 return &meta, nil
454 }
455
456 // Done reports whether the long-running operation has completed.
457 func (op *ImportDocumentsOperation) Done() bool {
458 return op.lro.Done()
459 }
460
461 // Name returns the name of the long-running operation.
462 // The name is assigned by the server and is unique within the service from which the operation is created.
463 func (op *ImportDocumentsOperation) Name() string {
464 return op.lro.Name()
465 }
466
467 // RestoreDatabaseOperation manages a long-running operation from RestoreDatabase.
468 type RestoreDatabaseOperation struct {
469 lro *longrunning.Operation
470 pollPath string
471 }
472
473 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
474 //
475 // See documentation of Poll for error-handling information.
476 func (op *RestoreDatabaseOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
477 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
478 var resp adminpb.Database
479 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
480 return nil, err
481 }
482 return &resp, nil
483 }
484
485 // Poll fetches the latest state of the long-running operation.
486 //
487 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
488 //
489 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
490 // the operation has completed with failure, the error is returned and op.Done will return true.
491 // If Poll succeeds and the operation has completed successfully,
492 // op.Done will return true, and the response of the operation is returned.
493 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
494 func (op *RestoreDatabaseOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
495 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
496 var resp adminpb.Database
497 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
498 return nil, err
499 }
500 if !op.Done() {
501 return nil, nil
502 }
503 return &resp, nil
504 }
505
506 // Metadata returns metadata associated with the long-running operation.
507 // Metadata itself does not contact the server, but Poll does.
508 // To get the latest metadata, call this method after a successful call to Poll.
509 // If the metadata is not available, the returned metadata and error are both nil.
510 func (op *RestoreDatabaseOperation) Metadata() (*adminpb.RestoreDatabaseMetadata, error) {
511 var meta adminpb.RestoreDatabaseMetadata
512 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
513 return nil, nil
514 } else if err != nil {
515 return nil, err
516 }
517 return &meta, nil
518 }
519
520 // Done reports whether the long-running operation has completed.
521 func (op *RestoreDatabaseOperation) Done() bool {
522 return op.lro.Done()
523 }
524
525 // Name returns the name of the long-running operation.
526 // The name is assigned by the server and is unique within the service from which the operation is created.
527 func (op *RestoreDatabaseOperation) Name() string {
528 return op.lro.Name()
529 }
530
531 // UpdateDatabaseOperation manages a long-running operation from UpdateDatabase.
532 type UpdateDatabaseOperation struct {
533 lro *longrunning.Operation
534 pollPath string
535 }
536
537 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
538 //
539 // See documentation of Poll for error-handling information.
540 func (op *UpdateDatabaseOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
541 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
542 var resp adminpb.Database
543 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
544 return nil, err
545 }
546 return &resp, nil
547 }
548
549 // Poll fetches the latest state of the long-running operation.
550 //
551 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
552 //
553 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
554 // the operation has completed with failure, the error is returned and op.Done will return true.
555 // If Poll succeeds and the operation has completed successfully,
556 // op.Done will return true, and the response of the operation is returned.
557 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
558 func (op *UpdateDatabaseOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Database, error) {
559 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
560 var resp adminpb.Database
561 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
562 return nil, err
563 }
564 if !op.Done() {
565 return nil, nil
566 }
567 return &resp, nil
568 }
569
570 // Metadata returns metadata associated with the long-running operation.
571 // Metadata itself does not contact the server, but Poll does.
572 // To get the latest metadata, call this method after a successful call to Poll.
573 // If the metadata is not available, the returned metadata and error are both nil.
574 func (op *UpdateDatabaseOperation) Metadata() (*adminpb.UpdateDatabaseMetadata, error) {
575 var meta adminpb.UpdateDatabaseMetadata
576 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
577 return nil, nil
578 } else if err != nil {
579 return nil, err
580 }
581 return &meta, nil
582 }
583
584 // Done reports whether the long-running operation has completed.
585 func (op *UpdateDatabaseOperation) Done() bool {
586 return op.lro.Done()
587 }
588
589 // Name returns the name of the long-running operation.
590 // The name is assigned by the server and is unique within the service from which the operation is created.
591 func (op *UpdateDatabaseOperation) Name() string {
592 return op.lro.Name()
593 }
594
595 // UpdateFieldOperation manages a long-running operation from UpdateField.
596 type UpdateFieldOperation struct {
597 lro *longrunning.Operation
598 pollPath string
599 }
600
601 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
602 //
603 // See documentation of Poll for error-handling information.
604 func (op *UpdateFieldOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*adminpb.Field, error) {
605 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
606 var resp adminpb.Field
607 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
608 return nil, err
609 }
610 return &resp, nil
611 }
612
613 // Poll fetches the latest state of the long-running operation.
614 //
615 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
616 //
617 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
618 // the operation has completed with failure, the error is returned and op.Done will return true.
619 // If Poll succeeds and the operation has completed successfully,
620 // op.Done will return true, and the response of the operation is returned.
621 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
622 func (op *UpdateFieldOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*adminpb.Field, error) {
623 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
624 var resp adminpb.Field
625 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
626 return nil, err
627 }
628 if !op.Done() {
629 return nil, nil
630 }
631 return &resp, nil
632 }
633
634 // Metadata returns metadata associated with the long-running operation.
635 // Metadata itself does not contact the server, but Poll does.
636 // To get the latest metadata, call this method after a successful call to Poll.
637 // If the metadata is not available, the returned metadata and error are both nil.
638 func (op *UpdateFieldOperation) Metadata() (*adminpb.FieldOperationMetadata, error) {
639 var meta adminpb.FieldOperationMetadata
640 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
641 return nil, nil
642 } else if err != nil {
643 return nil, err
644 }
645 return &meta, nil
646 }
647
648 // Done reports whether the long-running operation has completed.
649 func (op *UpdateFieldOperation) Done() bool {
650 return op.lro.Done()
651 }
652
653 // Name returns the name of the long-running operation.
654 // The name is assigned by the server and is unique within the service from which the operation is created.
655 func (op *UpdateFieldOperation) Name() string {
656 return op.lro.Name()
657 }
658
659 // FieldIterator manages a stream of *adminpb.Field.
660 type FieldIterator struct {
661 items []*adminpb.Field
662 pageInfo *iterator.PageInfo
663 nextFunc func() error
664
665 // Response is the raw response for the current page.
666 // It must be cast to the RPC response type.
667 // Calling Next() or InternalFetch() updates this value.
668 Response interface{}
669
670 // InternalFetch is for use by the Google Cloud Libraries only.
671 // It is not part of the stable interface of this package.
672 //
673 // InternalFetch returns results from a single call to the underlying RPC.
674 // The number of results is no greater than pageSize.
675 // If there are no more results, nextPageToken is empty and err is nil.
676 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.Field, nextPageToken string, err error)
677 }
678
679 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
680 func (it *FieldIterator) PageInfo() *iterator.PageInfo {
681 return it.pageInfo
682 }
683
684 // Next returns the next result. Its second return value is iterator.Done if there are no more
685 // results. Once Next returns Done, all subsequent calls will return Done.
686 func (it *FieldIterator) Next() (*adminpb.Field, error) {
687 var item *adminpb.Field
688 if err := it.nextFunc(); err != nil {
689 return item, err
690 }
691 item = it.items[0]
692 it.items = it.items[1:]
693 return item, nil
694 }
695
696 func (it *FieldIterator) bufLen() int {
697 return len(it.items)
698 }
699
700 func (it *FieldIterator) takeBuf() interface{} {
701 b := it.items
702 it.items = nil
703 return b
704 }
705
706 // IndexIterator manages a stream of *adminpb.Index.
707 type IndexIterator struct {
708 items []*adminpb.Index
709 pageInfo *iterator.PageInfo
710 nextFunc func() error
711
712 // Response is the raw response for the current page.
713 // It must be cast to the RPC response type.
714 // Calling Next() or InternalFetch() updates this value.
715 Response interface{}
716
717 // InternalFetch is for use by the Google Cloud Libraries only.
718 // It is not part of the stable interface of this package.
719 //
720 // InternalFetch returns results from a single call to the underlying RPC.
721 // The number of results is no greater than pageSize.
722 // If there are no more results, nextPageToken is empty and err is nil.
723 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.Index, nextPageToken string, err error)
724 }
725
726 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
727 func (it *IndexIterator) PageInfo() *iterator.PageInfo {
728 return it.pageInfo
729 }
730
731 // Next returns the next result. Its second return value is iterator.Done if there are no more
732 // results. Once Next returns Done, all subsequent calls will return Done.
733 func (it *IndexIterator) Next() (*adminpb.Index, error) {
734 var item *adminpb.Index
735 if err := it.nextFunc(); err != nil {
736 return item, err
737 }
738 item = it.items[0]
739 it.items = it.items[1:]
740 return item, nil
741 }
742
743 func (it *IndexIterator) bufLen() int {
744 return len(it.items)
745 }
746
747 func (it *IndexIterator) takeBuf() interface{} {
748 b := it.items
749 it.items = nil
750 return b
751 }
752
753 // OperationIterator manages a stream of *longrunningpb.Operation.
754 type OperationIterator struct {
755 items []*longrunningpb.Operation
756 pageInfo *iterator.PageInfo
757 nextFunc func() error
758
759 // Response is the raw response for the current page.
760 // It must be cast to the RPC response type.
761 // Calling Next() or InternalFetch() updates this value.
762 Response interface{}
763
764 // InternalFetch is for use by the Google Cloud Libraries only.
765 // It is not part of the stable interface of this package.
766 //
767 // InternalFetch returns results from a single call to the underlying RPC.
768 // The number of results is no greater than pageSize.
769 // If there are no more results, nextPageToken is empty and err is nil.
770 InternalFetch func(pageSize int, pageToken string) (results []*longrunningpb.Operation, nextPageToken string, err error)
771 }
772
773 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
774 func (it *OperationIterator) PageInfo() *iterator.PageInfo {
775 return it.pageInfo
776 }
777
778 // Next returns the next result. Its second return value is iterator.Done if there are no more
779 // results. Once Next returns Done, all subsequent calls will return Done.
780 func (it *OperationIterator) Next() (*longrunningpb.Operation, error) {
781 var item *longrunningpb.Operation
782 if err := it.nextFunc(); err != nil {
783 return item, err
784 }
785 item = it.items[0]
786 it.items = it.items[1:]
787 return item, nil
788 }
789
790 func (it *OperationIterator) bufLen() int {
791 return len(it.items)
792 }
793
794 func (it *OperationIterator) takeBuf() interface{} {
795 b := it.items
796 it.items = nil
797 return b
798 }