| 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 filestore |
| 18 |
|
| 19 |
import ( |
| 20 |
"context" |
| 21 |
"time" |
| 22 |
|
| 23 |
filestorepb "cloud.google.com/go/filestore/apiv1/filestorepb" |
| 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 |
commonpb "google.golang.org/genproto/googleapis/cloud/common" |
| 29 |
locationpb "google.golang.org/genproto/googleapis/cloud/location" |
| 30 |
) |
| 31 |
|
| 32 |
// CreateBackupOperation manages a long-running operation from CreateBackup. |
| 33 |
type CreateBackupOperation struct { |
| 34 |
lro *longrunning.Operation |
| 35 |
pollPath string |
| 36 |
} |
| 37 |
|
| 38 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 39 |
// |
| 40 |
// See documentation of Poll for error-handling information. |
| 41 |
func (op *CreateBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Backup, error) { |
| 42 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 43 |
var resp filestorepb.Backup |
| 44 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 45 |
return nil, err |
| 46 |
} |
| 47 |
return &resp, nil |
| 48 |
} |
| 49 |
|
| 50 |
// Poll fetches the latest state of the long-running operation. |
| 51 |
// |
| 52 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 53 |
// |
| 54 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 55 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 56 |
// If Poll succeeds and the operation has completed successfully, |
| 57 |
// op.Done will return true, and the response of the operation is returned. |
| 58 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 59 |
func (op *CreateBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Backup, error) { |
| 60 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 61 |
var resp filestorepb.Backup |
| 62 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 63 |
return nil, err |
| 64 |
} |
| 65 |
if !op.Done() { |
| 66 |
return nil, nil |
| 67 |
} |
| 68 |
return &resp, nil |
| 69 |
} |
| 70 |
|
| 71 |
// Metadata returns metadata associated with the long-running operation. |
| 72 |
// Metadata itself does not contact the server, but Poll does. |
| 73 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 74 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 75 |
func (op *CreateBackupOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 76 |
var meta commonpb.OperationMetadata |
| 77 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 78 |
return nil, nil |
| 79 |
} else if err != nil { |
| 80 |
return nil, err |
| 81 |
} |
| 82 |
return &meta, nil |
| 83 |
} |
| 84 |
|
| 85 |
// Done reports whether the long-running operation has completed. |
| 86 |
func (op *CreateBackupOperation) Done() bool { |
| 87 |
return op.lro.Done() |
| 88 |
} |
| 89 |
|
| 90 |
// Name returns the name of the long-running operation. |
| 91 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 92 |
func (op *CreateBackupOperation) Name() string { |
| 93 |
return op.lro.Name() |
| 94 |
} |
| 95 |
|
| 96 |
// CreateInstanceOperation manages a long-running operation from CreateInstance. |
| 97 |
type CreateInstanceOperation struct { |
| 98 |
lro *longrunning.Operation |
| 99 |
pollPath string |
| 100 |
} |
| 101 |
|
| 102 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 103 |
// |
| 104 |
// See documentation of Poll for error-handling information. |
| 105 |
func (op *CreateInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 106 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 107 |
var resp filestorepb.Instance |
| 108 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 109 |
return nil, err |
| 110 |
} |
| 111 |
return &resp, nil |
| 112 |
} |
| 113 |
|
| 114 |
// Poll fetches the latest state of the long-running operation. |
| 115 |
// |
| 116 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 117 |
// |
| 118 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 119 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 120 |
// If Poll succeeds and the operation has completed successfully, |
| 121 |
// op.Done will return true, and the response of the operation is returned. |
| 122 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 123 |
func (op *CreateInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 124 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 125 |
var resp filestorepb.Instance |
| 126 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 127 |
return nil, err |
| 128 |
} |
| 129 |
if !op.Done() { |
| 130 |
return nil, nil |
| 131 |
} |
| 132 |
return &resp, nil |
| 133 |
} |
| 134 |
|
| 135 |
// Metadata returns metadata associated with the long-running operation. |
| 136 |
// Metadata itself does not contact the server, but Poll does. |
| 137 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 138 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 139 |
func (op *CreateInstanceOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 140 |
var meta commonpb.OperationMetadata |
| 141 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 142 |
return nil, nil |
| 143 |
} else if err != nil { |
| 144 |
return nil, err |
| 145 |
} |
| 146 |
return &meta, nil |
| 147 |
} |
| 148 |
|
| 149 |
// Done reports whether the long-running operation has completed. |
| 150 |
func (op *CreateInstanceOperation) Done() bool { |
| 151 |
return op.lro.Done() |
| 152 |
} |
| 153 |
|
| 154 |
// Name returns the name of the long-running operation. |
| 155 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 156 |
func (op *CreateInstanceOperation) Name() string { |
| 157 |
return op.lro.Name() |
| 158 |
} |
| 159 |
|
| 160 |
// CreateSnapshotOperation manages a long-running operation from CreateSnapshot. |
| 161 |
type CreateSnapshotOperation struct { |
| 162 |
lro *longrunning.Operation |
| 163 |
pollPath string |
| 164 |
} |
| 165 |
|
| 166 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 167 |
// |
| 168 |
// See documentation of Poll for error-handling information. |
| 169 |
func (op *CreateSnapshotOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Snapshot, error) { |
| 170 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 171 |
var resp filestorepb.Snapshot |
| 172 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 173 |
return nil, err |
| 174 |
} |
| 175 |
return &resp, nil |
| 176 |
} |
| 177 |
|
| 178 |
// Poll fetches the latest state of the long-running operation. |
| 179 |
// |
| 180 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 181 |
// |
| 182 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 183 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 184 |
// If Poll succeeds and the operation has completed successfully, |
| 185 |
// op.Done will return true, and the response of the operation is returned. |
| 186 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 187 |
func (op *CreateSnapshotOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Snapshot, error) { |
| 188 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 189 |
var resp filestorepb.Snapshot |
| 190 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 191 |
return nil, err |
| 192 |
} |
| 193 |
if !op.Done() { |
| 194 |
return nil, nil |
| 195 |
} |
| 196 |
return &resp, nil |
| 197 |
} |
| 198 |
|
| 199 |
// Metadata returns metadata associated with the long-running operation. |
| 200 |
// Metadata itself does not contact the server, but Poll does. |
| 201 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 202 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 203 |
func (op *CreateSnapshotOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 204 |
var meta commonpb.OperationMetadata |
| 205 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 206 |
return nil, nil |
| 207 |
} else if err != nil { |
| 208 |
return nil, err |
| 209 |
} |
| 210 |
return &meta, nil |
| 211 |
} |
| 212 |
|
| 213 |
// Done reports whether the long-running operation has completed. |
| 214 |
func (op *CreateSnapshotOperation) Done() bool { |
| 215 |
return op.lro.Done() |
| 216 |
} |
| 217 |
|
| 218 |
// Name returns the name of the long-running operation. |
| 219 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 220 |
func (op *CreateSnapshotOperation) Name() string { |
| 221 |
return op.lro.Name() |
| 222 |
} |
| 223 |
|
| 224 |
// DeleteBackupOperation manages a long-running operation from DeleteBackup. |
| 225 |
type DeleteBackupOperation struct { |
| 226 |
lro *longrunning.Operation |
| 227 |
pollPath string |
| 228 |
} |
| 229 |
|
| 230 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 231 |
// |
| 232 |
// See documentation of Poll for error-handling information. |
| 233 |
func (op *DeleteBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { |
| 234 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 235 |
return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) |
| 236 |
} |
| 237 |
|
| 238 |
// Poll fetches the latest state of the long-running operation. |
| 239 |
// |
| 240 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 241 |
// |
| 242 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 243 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 244 |
// If Poll succeeds and the operation has completed successfully, |
| 245 |
// op.Done will return true, and the response of the operation is returned. |
| 246 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 247 |
func (op *DeleteBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { |
| 248 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 249 |
return op.lro.Poll(ctx, nil, opts...) |
| 250 |
} |
| 251 |
|
| 252 |
// Metadata returns metadata associated with the long-running operation. |
| 253 |
// Metadata itself does not contact the server, but Poll does. |
| 254 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 255 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 256 |
func (op *DeleteBackupOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 257 |
var meta commonpb.OperationMetadata |
| 258 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 259 |
return nil, nil |
| 260 |
} else if err != nil { |
| 261 |
return nil, err |
| 262 |
} |
| 263 |
return &meta, nil |
| 264 |
} |
| 265 |
|
| 266 |
// Done reports whether the long-running operation has completed. |
| 267 |
func (op *DeleteBackupOperation) Done() bool { |
| 268 |
return op.lro.Done() |
| 269 |
} |
| 270 |
|
| 271 |
// Name returns the name of the long-running operation. |
| 272 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 273 |
func (op *DeleteBackupOperation) Name() string { |
| 274 |
return op.lro.Name() |
| 275 |
} |
| 276 |
|
| 277 |
// DeleteInstanceOperation manages a long-running operation from DeleteInstance. |
| 278 |
type DeleteInstanceOperation struct { |
| 279 |
lro *longrunning.Operation |
| 280 |
pollPath string |
| 281 |
} |
| 282 |
|
| 283 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 284 |
// |
| 285 |
// See documentation of Poll for error-handling information. |
| 286 |
func (op *DeleteInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { |
| 287 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 288 |
return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) |
| 289 |
} |
| 290 |
|
| 291 |
// Poll fetches the latest state of the long-running operation. |
| 292 |
// |
| 293 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 294 |
// |
| 295 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 296 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 297 |
// If Poll succeeds and the operation has completed successfully, |
| 298 |
// op.Done will return true, and the response of the operation is returned. |
| 299 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 300 |
func (op *DeleteInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { |
| 301 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 302 |
return op.lro.Poll(ctx, nil, opts...) |
| 303 |
} |
| 304 |
|
| 305 |
// Metadata returns metadata associated with the long-running operation. |
| 306 |
// Metadata itself does not contact the server, but Poll does. |
| 307 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 308 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 309 |
func (op *DeleteInstanceOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 310 |
var meta commonpb.OperationMetadata |
| 311 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 312 |
return nil, nil |
| 313 |
} else if err != nil { |
| 314 |
return nil, err |
| 315 |
} |
| 316 |
return &meta, nil |
| 317 |
} |
| 318 |
|
| 319 |
// Done reports whether the long-running operation has completed. |
| 320 |
func (op *DeleteInstanceOperation) Done() bool { |
| 321 |
return op.lro.Done() |
| 322 |
} |
| 323 |
|
| 324 |
// Name returns the name of the long-running operation. |
| 325 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 326 |
func (op *DeleteInstanceOperation) Name() string { |
| 327 |
return op.lro.Name() |
| 328 |
} |
| 329 |
|
| 330 |
// DeleteSnapshotOperation manages a long-running operation from DeleteSnapshot. |
| 331 |
type DeleteSnapshotOperation struct { |
| 332 |
lro *longrunning.Operation |
| 333 |
pollPath string |
| 334 |
} |
| 335 |
|
| 336 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 337 |
// |
| 338 |
// See documentation of Poll for error-handling information. |
| 339 |
func (op *DeleteSnapshotOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { |
| 340 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 341 |
return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) |
| 342 |
} |
| 343 |
|
| 344 |
// Poll fetches the latest state of the long-running operation. |
| 345 |
// |
| 346 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 347 |
// |
| 348 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 349 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 350 |
// If Poll succeeds and the operation has completed successfully, |
| 351 |
// op.Done will return true, and the response of the operation is returned. |
| 352 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 353 |
func (op *DeleteSnapshotOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { |
| 354 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 355 |
return op.lro.Poll(ctx, nil, opts...) |
| 356 |
} |
| 357 |
|
| 358 |
// Metadata returns metadata associated with the long-running operation. |
| 359 |
// Metadata itself does not contact the server, but Poll does. |
| 360 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 361 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 362 |
func (op *DeleteSnapshotOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 363 |
var meta commonpb.OperationMetadata |
| 364 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 365 |
return nil, nil |
| 366 |
} else if err != nil { |
| 367 |
return nil, err |
| 368 |
} |
| 369 |
return &meta, nil |
| 370 |
} |
| 371 |
|
| 372 |
// Done reports whether the long-running operation has completed. |
| 373 |
func (op *DeleteSnapshotOperation) Done() bool { |
| 374 |
return op.lro.Done() |
| 375 |
} |
| 376 |
|
| 377 |
// Name returns the name of the long-running operation. |
| 378 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 379 |
func (op *DeleteSnapshotOperation) Name() string { |
| 380 |
return op.lro.Name() |
| 381 |
} |
| 382 |
|
| 383 |
// PromoteReplicaOperation manages a long-running operation from PromoteReplica. |
| 384 |
type PromoteReplicaOperation struct { |
| 385 |
lro *longrunning.Operation |
| 386 |
pollPath string |
| 387 |
} |
| 388 |
|
| 389 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 390 |
// |
| 391 |
// See documentation of Poll for error-handling information. |
| 392 |
func (op *PromoteReplicaOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 393 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 394 |
var resp filestorepb.Instance |
| 395 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 396 |
return nil, err |
| 397 |
} |
| 398 |
return &resp, nil |
| 399 |
} |
| 400 |
|
| 401 |
// Poll fetches the latest state of the long-running operation. |
| 402 |
// |
| 403 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 404 |
// |
| 405 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 406 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 407 |
// If Poll succeeds and the operation has completed successfully, |
| 408 |
// op.Done will return true, and the response of the operation is returned. |
| 409 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 410 |
func (op *PromoteReplicaOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 411 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 412 |
var resp filestorepb.Instance |
| 413 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 414 |
return nil, err |
| 415 |
} |
| 416 |
if !op.Done() { |
| 417 |
return nil, nil |
| 418 |
} |
| 419 |
return &resp, nil |
| 420 |
} |
| 421 |
|
| 422 |
// Metadata returns metadata associated with the long-running operation. |
| 423 |
// Metadata itself does not contact the server, but Poll does. |
| 424 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 425 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 426 |
func (op *PromoteReplicaOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 427 |
var meta commonpb.OperationMetadata |
| 428 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 429 |
return nil, nil |
| 430 |
} else if err != nil { |
| 431 |
return nil, err |
| 432 |
} |
| 433 |
return &meta, nil |
| 434 |
} |
| 435 |
|
| 436 |
// Done reports whether the long-running operation has completed. |
| 437 |
func (op *PromoteReplicaOperation) Done() bool { |
| 438 |
return op.lro.Done() |
| 439 |
} |
| 440 |
|
| 441 |
// Name returns the name of the long-running operation. |
| 442 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 443 |
func (op *PromoteReplicaOperation) Name() string { |
| 444 |
return op.lro.Name() |
| 445 |
} |
| 446 |
|
| 447 |
// RestoreInstanceOperation manages a long-running operation from RestoreInstance. |
| 448 |
type RestoreInstanceOperation struct { |
| 449 |
lro *longrunning.Operation |
| 450 |
pollPath string |
| 451 |
} |
| 452 |
|
| 453 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 454 |
// |
| 455 |
// See documentation of Poll for error-handling information. |
| 456 |
func (op *RestoreInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 457 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 458 |
var resp filestorepb.Instance |
| 459 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 460 |
return nil, err |
| 461 |
} |
| 462 |
return &resp, nil |
| 463 |
} |
| 464 |
|
| 465 |
// Poll fetches the latest state of the long-running operation. |
| 466 |
// |
| 467 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 468 |
// |
| 469 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 470 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 471 |
// If Poll succeeds and the operation has completed successfully, |
| 472 |
// op.Done will return true, and the response of the operation is returned. |
| 473 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 474 |
func (op *RestoreInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 475 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 476 |
var resp filestorepb.Instance |
| 477 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 478 |
return nil, err |
| 479 |
} |
| 480 |
if !op.Done() { |
| 481 |
return nil, nil |
| 482 |
} |
| 483 |
return &resp, nil |
| 484 |
} |
| 485 |
|
| 486 |
// Metadata returns metadata associated with the long-running operation. |
| 487 |
// Metadata itself does not contact the server, but Poll does. |
| 488 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 489 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 490 |
func (op *RestoreInstanceOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 491 |
var meta commonpb.OperationMetadata |
| 492 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 493 |
return nil, nil |
| 494 |
} else if err != nil { |
| 495 |
return nil, err |
| 496 |
} |
| 497 |
return &meta, nil |
| 498 |
} |
| 499 |
|
| 500 |
// Done reports whether the long-running operation has completed. |
| 501 |
func (op *RestoreInstanceOperation) Done() bool { |
| 502 |
return op.lro.Done() |
| 503 |
} |
| 504 |
|
| 505 |
// Name returns the name of the long-running operation. |
| 506 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 507 |
func (op *RestoreInstanceOperation) Name() string { |
| 508 |
return op.lro.Name() |
| 509 |
} |
| 510 |
|
| 511 |
// RevertInstanceOperation manages a long-running operation from RevertInstance. |
| 512 |
type RevertInstanceOperation struct { |
| 513 |
lro *longrunning.Operation |
| 514 |
pollPath string |
| 515 |
} |
| 516 |
|
| 517 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 518 |
// |
| 519 |
// See documentation of Poll for error-handling information. |
| 520 |
func (op *RevertInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 521 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 522 |
var resp filestorepb.Instance |
| 523 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 524 |
return nil, err |
| 525 |
} |
| 526 |
return &resp, nil |
| 527 |
} |
| 528 |
|
| 529 |
// Poll fetches the latest state of the long-running operation. |
| 530 |
// |
| 531 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 532 |
// |
| 533 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 534 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 535 |
// If Poll succeeds and the operation has completed successfully, |
| 536 |
// op.Done will return true, and the response of the operation is returned. |
| 537 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 538 |
func (op *RevertInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 539 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 540 |
var resp filestorepb.Instance |
| 541 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 542 |
return nil, err |
| 543 |
} |
| 544 |
if !op.Done() { |
| 545 |
return nil, nil |
| 546 |
} |
| 547 |
return &resp, nil |
| 548 |
} |
| 549 |
|
| 550 |
// Metadata returns metadata associated with the long-running operation. |
| 551 |
// Metadata itself does not contact the server, but Poll does. |
| 552 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 553 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 554 |
func (op *RevertInstanceOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 555 |
var meta commonpb.OperationMetadata |
| 556 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 557 |
return nil, nil |
| 558 |
} else if err != nil { |
| 559 |
return nil, err |
| 560 |
} |
| 561 |
return &meta, nil |
| 562 |
} |
| 563 |
|
| 564 |
// Done reports whether the long-running operation has completed. |
| 565 |
func (op *RevertInstanceOperation) Done() bool { |
| 566 |
return op.lro.Done() |
| 567 |
} |
| 568 |
|
| 569 |
// Name returns the name of the long-running operation. |
| 570 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 571 |
func (op *RevertInstanceOperation) Name() string { |
| 572 |
return op.lro.Name() |
| 573 |
} |
| 574 |
|
| 575 |
// UpdateBackupOperation manages a long-running operation from UpdateBackup. |
| 576 |
type UpdateBackupOperation struct { |
| 577 |
lro *longrunning.Operation |
| 578 |
pollPath string |
| 579 |
} |
| 580 |
|
| 581 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 582 |
// |
| 583 |
// See documentation of Poll for error-handling information. |
| 584 |
func (op *UpdateBackupOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Backup, error) { |
| 585 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 586 |
var resp filestorepb.Backup |
| 587 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 588 |
return nil, err |
| 589 |
} |
| 590 |
return &resp, nil |
| 591 |
} |
| 592 |
|
| 593 |
// Poll fetches the latest state of the long-running operation. |
| 594 |
// |
| 595 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 596 |
// |
| 597 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 598 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 599 |
// If Poll succeeds and the operation has completed successfully, |
| 600 |
// op.Done will return true, and the response of the operation is returned. |
| 601 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 602 |
func (op *UpdateBackupOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Backup, error) { |
| 603 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 604 |
var resp filestorepb.Backup |
| 605 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 606 |
return nil, err |
| 607 |
} |
| 608 |
if !op.Done() { |
| 609 |
return nil, nil |
| 610 |
} |
| 611 |
return &resp, nil |
| 612 |
} |
| 613 |
|
| 614 |
// Metadata returns metadata associated with the long-running operation. |
| 615 |
// Metadata itself does not contact the server, but Poll does. |
| 616 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 617 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 618 |
func (op *UpdateBackupOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 619 |
var meta commonpb.OperationMetadata |
| 620 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 621 |
return nil, nil |
| 622 |
} else if err != nil { |
| 623 |
return nil, err |
| 624 |
} |
| 625 |
return &meta, nil |
| 626 |
} |
| 627 |
|
| 628 |
// Done reports whether the long-running operation has completed. |
| 629 |
func (op *UpdateBackupOperation) Done() bool { |
| 630 |
return op.lro.Done() |
| 631 |
} |
| 632 |
|
| 633 |
// Name returns the name of the long-running operation. |
| 634 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 635 |
func (op *UpdateBackupOperation) Name() string { |
| 636 |
return op.lro.Name() |
| 637 |
} |
| 638 |
|
| 639 |
// UpdateInstanceOperation manages a long-running operation from UpdateInstance. |
| 640 |
type UpdateInstanceOperation struct { |
| 641 |
lro *longrunning.Operation |
| 642 |
pollPath string |
| 643 |
} |
| 644 |
|
| 645 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 646 |
// |
| 647 |
// See documentation of Poll for error-handling information. |
| 648 |
func (op *UpdateInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 649 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 650 |
var resp filestorepb.Instance |
| 651 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 652 |
return nil, err |
| 653 |
} |
| 654 |
return &resp, nil |
| 655 |
} |
| 656 |
|
| 657 |
// Poll fetches the latest state of the long-running operation. |
| 658 |
// |
| 659 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 660 |
// |
| 661 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 662 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 663 |
// If Poll succeeds and the operation has completed successfully, |
| 664 |
// op.Done will return true, and the response of the operation is returned. |
| 665 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 666 |
func (op *UpdateInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Instance, error) { |
| 667 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 668 |
var resp filestorepb.Instance |
| 669 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 670 |
return nil, err |
| 671 |
} |
| 672 |
if !op.Done() { |
| 673 |
return nil, nil |
| 674 |
} |
| 675 |
return &resp, nil |
| 676 |
} |
| 677 |
|
| 678 |
// Metadata returns metadata associated with the long-running operation. |
| 679 |
// Metadata itself does not contact the server, but Poll does. |
| 680 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 681 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 682 |
func (op *UpdateInstanceOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 683 |
var meta commonpb.OperationMetadata |
| 684 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 685 |
return nil, nil |
| 686 |
} else if err != nil { |
| 687 |
return nil, err |
| 688 |
} |
| 689 |
return &meta, nil |
| 690 |
} |
| 691 |
|
| 692 |
// Done reports whether the long-running operation has completed. |
| 693 |
func (op *UpdateInstanceOperation) Done() bool { |
| 694 |
return op.lro.Done() |
| 695 |
} |
| 696 |
|
| 697 |
// Name returns the name of the long-running operation. |
| 698 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 699 |
func (op *UpdateInstanceOperation) Name() string { |
| 700 |
return op.lro.Name() |
| 701 |
} |
| 702 |
|
| 703 |
// UpdateSnapshotOperation manages a long-running operation from UpdateSnapshot. |
| 704 |
type UpdateSnapshotOperation struct { |
| 705 |
lro *longrunning.Operation |
| 706 |
pollPath string |
| 707 |
} |
| 708 |
|
| 709 |
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. |
| 710 |
// |
| 711 |
// See documentation of Poll for error-handling information. |
| 712 |
func (op *UpdateSnapshotOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Snapshot, error) { |
| 713 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 714 |
var resp filestorepb.Snapshot |
| 715 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 716 |
return nil, err |
| 717 |
} |
| 718 |
return &resp, nil |
| 719 |
} |
| 720 |
|
| 721 |
// Poll fetches the latest state of the long-running operation. |
| 722 |
// |
| 723 |
// Poll also fetches the latest metadata, which can be retrieved by Metadata. |
| 724 |
// |
| 725 |
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and |
| 726 |
// the operation has completed with failure, the error is returned and op.Done will return true. |
| 727 |
// If Poll succeeds and the operation has completed successfully, |
| 728 |
// op.Done will return true, and the response of the operation is returned. |
| 729 |
// If Poll succeeds and the operation has not completed, the returned response and error are both nil. |
| 730 |
func (op *UpdateSnapshotOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*filestorepb.Snapshot, error) { |
| 731 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 732 |
var resp filestorepb.Snapshot |
| 733 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 734 |
return nil, err |
| 735 |
} |
| 736 |
if !op.Done() { |
| 737 |
return nil, nil |
| 738 |
} |
| 739 |
return &resp, nil |
| 740 |
} |
| 741 |
|
| 742 |
// Metadata returns metadata associated with the long-running operation. |
| 743 |
// Metadata itself does not contact the server, but Poll does. |
| 744 |
// To get the latest metadata, call this method after a successful call to Poll. |
| 745 |
// If the metadata is not available, the returned metadata and error are both nil. |
| 746 |
func (op *UpdateSnapshotOperation) Metadata() (*commonpb.OperationMetadata, error) { |
| 747 |
var meta commonpb.OperationMetadata |
| 748 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 749 |
return nil, nil |
| 750 |
} else if err != nil { |
| 751 |
return nil, err |
| 752 |
} |
| 753 |
return &meta, nil |
| 754 |
} |
| 755 |
|
| 756 |
// Done reports whether the long-running operation has completed. |
| 757 |
func (op *UpdateSnapshotOperation) Done() bool { |
| 758 |
return op.lro.Done() |
| 759 |
} |
| 760 |
|
| 761 |
// Name returns the name of the long-running operation. |
| 762 |
// The name is assigned by the server and is unique within the service from which the operation is created. |
| 763 |
func (op *UpdateSnapshotOperation) Name() string { |
| 764 |
return op.lro.Name() |
| 765 |
} |
| 766 |
|
| 767 |
// BackupIterator manages a stream of *filestorepb.Backup. |
| 768 |
type BackupIterator struct { |
| 769 |
items []*filestorepb.Backup |
| 770 |
pageInfo *iterator.PageInfo |
| 771 |
nextFunc func() error |
| 772 |
|
| 773 |
// Response is the raw response for the current page. |
| 774 |
// It must be cast to the RPC response type. |
| 775 |
// Calling Next() or InternalFetch() updates this value. |
| 776 |
Response interface{} |
| 777 |
|
| 778 |
// InternalFetch is for use by the Google Cloud Libraries only. |
| 779 |
// It is not part of the stable interface of this package. |
| 780 |
// |
| 781 |
// InternalFetch returns results from a single call to the underlying RPC. |
| 782 |
// The number of results is no greater than pageSize. |
| 783 |
// If there are no more results, nextPageToken is empty and err is nil. |
| 784 |
InternalFetch func(pageSize int, pageToken string) (results []*filestorepb.Backup, nextPageToken string, err error) |
| 785 |
} |
| 786 |
|
| 787 |
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details. |
| 788 |
func (it *BackupIterator) PageInfo() *iterator.PageInfo { |
| 789 |
return it.pageInfo |
| 790 |
} |
| 791 |
|
| 792 |
// Next returns the next result. Its second return value is iterator.Done if there are no more |
| 793 |
// results. Once Next returns Done, all subsequent calls will return Done. |
| 794 |
func (it *BackupIterator) Next() (*filestorepb.Backup, error) { |
| 795 |
var item *filestorepb.Backup |
| 796 |
if err := it.nextFunc(); err != nil { |
| 797 |
return item, err |
| 798 |
} |
| 799 |
item = it.items[0] |
| 800 |
it.items = it.items[1:] |
| 801 |
return item, nil |
| 802 |
} |
| 803 |
|
| 804 |
func (it *BackupIterator) bufLen() int { |
| 805 |
return len(it.items) |
| 806 |
} |
| 807 |
|
| 808 |
func (it *BackupIterator) takeBuf() interface{} { |
| 809 |
b := it.items |
| 810 |
it.items = nil |
| 811 |
return b |
| 812 |
} |
| 813 |
|
| 814 |
// InstanceIterator manages a stream of *filestorepb.Instance. |
| 815 |
type InstanceIterator struct { |
| 816 |
items []*filestorepb.Instance |
| 817 |
pageInfo *iterator.PageInfo |
| 818 |
nextFunc func() error |
| 819 |
|
| 820 |
// Response is the raw response for the current page. |
| 821 |
// It must be cast to the RPC response type. |
| 822 |
// Calling Next() or InternalFetch() updates this value. |
| 823 |
Response interface{} |
| 824 |
|
| 825 |
// InternalFetch is for use by the Google Cloud Libraries only. |
| 826 |
// It is not part of the stable interface of this package. |
| 827 |
// |
| 828 |
// InternalFetch returns results from a single call to the underlying RPC. |
| 829 |
// The number of results is no greater than pageSize. |
| 830 |
// If there are no more results, nextPageToken is empty and err is nil. |
| 831 |
InternalFetch func(pageSize int, pageToken string) (results []*filestorepb.Instance, nextPageToken string, err error) |
| 832 |
} |
| 833 |
|
| 834 |
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details. |
| 835 |
func (it *InstanceIterator) PageInfo() *iterator.PageInfo { |
| 836 |
return it.pageInfo |
| 837 |
} |
| 838 |
|
| 839 |
// Next returns the next result. Its second return value is iterator.Done if there are no more |
| 840 |
// results. Once Next returns Done, all subsequent calls will return Done. |
| 841 |
func (it *InstanceIterator) Next() (*filestorepb.Instance, error) { |
| 842 |
var item *filestorepb.Instance |
| 843 |
if err := it.nextFunc(); err != nil { |
| 844 |
return item, err |
| 845 |
} |
| 846 |
item = it.items[0] |
| 847 |
it.items = it.items[1:] |
| 848 |
return item, nil |
| 849 |
} |
| 850 |
|
| 851 |
func (it *InstanceIterator) bufLen() int { |
| 852 |
return len(it.items) |
| 853 |
} |
| 854 |
|
| 855 |
func (it *InstanceIterator) takeBuf() interface{} { |
| 856 |
b := it.items |
| 857 |
it.items = nil |
| 858 |
return b |
| 859 |
} |
| 860 |
|
| 861 |
// LocationIterator manages a stream of *locationpb.Location. |
| 862 |
type LocationIterator struct { |
| 863 |
items []*locationpb.Location |
| 864 |
pageInfo *iterator.PageInfo |
| 865 |
nextFunc func() error |
| 866 |
|
| 867 |
// Response is the raw response for the current page. |
| 868 |
// It must be cast to the RPC response type. |
| 869 |
// Calling Next() or InternalFetch() updates this value. |
| 870 |
Response interface{} |
| 871 |
|
| 872 |
// InternalFetch is for use by the Google Cloud Libraries only. |
| 873 |
// It is not part of the stable interface of this package. |
| 874 |
// |
| 875 |
// InternalFetch returns results from a single call to the underlying RPC. |
| 876 |
// The number of results is no greater than pageSize. |
| 877 |
// If there are no more results, nextPageToken is empty and err is nil. |
| 878 |
InternalFetch func(pageSize int, pageToken string) (results []*locationpb.Location, nextPageToken string, err error) |
| 879 |
} |
| 880 |
|
| 881 |
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details. |
| 882 |
func (it *LocationIterator) PageInfo() *iterator.PageInfo { |
| 883 |
return it.pageInfo |
| 884 |
} |
| 885 |
|
| 886 |
// Next returns the next result. Its second return value is iterator.Done if there are no more |
| 887 |
// results. Once Next returns Done, all subsequent calls will return Done. |
| 888 |
func (it *LocationIterator) Next() (*locationpb.Location, error) { |
| 889 |
var item *locationpb.Location |
| 890 |
if err := it.nextFunc(); err != nil { |
| 891 |
return item, err |
| 892 |
} |
| 893 |
item = it.items[0] |
| 894 |
it.items = it.items[1:] |
| 895 |
return item, nil |
| 896 |
} |
| 897 |
|
| 898 |
func (it *LocationIterator) bufLen() int { |
| 899 |
return len(it.items) |
| 900 |
} |
| 901 |
|
| 902 |
func (it *LocationIterator) takeBuf() interface{} { |
| 903 |
b := it.items |
| 904 |
it.items = nil |
| 905 |
return b |
| 906 |
} |
| 907 |
|
| 908 |
// OperationIterator manages a stream of *longrunningpb.Operation. |
| 909 |
type OperationIterator struct { |
| 910 |
items []*longrunningpb.Operation |
| 911 |
pageInfo *iterator.PageInfo |
| 912 |
nextFunc func() error |
| 913 |
|
| 914 |
// Response is the raw response for the current page. |
| 915 |
// It must be cast to the RPC response type. |
| 916 |
// Calling Next() or InternalFetch() updates this value. |
| 917 |
Response interface{} |
| 918 |
|
| 919 |
// InternalFetch is for use by the Google Cloud Libraries only. |
| 920 |
// It is not part of the stable interface of this package. |
| 921 |
// |
| 922 |
// InternalFetch returns results from a single call to the underlying RPC. |
| 923 |
// The number of results is no greater than pageSize. |
| 924 |
// If there are no more results, nextPageToken is empty and err is nil. |
| 925 |
InternalFetch func(pageSize int, pageToken string) (results []*longrunningpb.Operation, nextPageToken string, err error) |
| 926 |
} |
| 927 |
|
| 928 |
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details. |
| 929 |
func (it *OperationIterator) PageInfo() *iterator.PageInfo { |
| 930 |
return it.pageInfo |
| 931 |
} |
| 932 |
|
| 933 |
// Next returns the next result. Its second return value is iterator.Done if there are no more |
| 934 |
// results. Once Next returns Done, all subsequent calls will return Done. |
| 935 |
func (it *OperationIterator) Next() (*longrunningpb.Operation, error) { |
| 936 |
var item *longrunningpb.Operation |
| 937 |
if err := it.nextFunc(); err != nil { |
| 938 |
return item, err |
| 939 |
} |
| 940 |
item = it.items[0] |
| 941 |
it.items = it.items[1:] |
| 942 |
return item, nil |
| 943 |
} |
| 944 |
|
| 945 |
func (it *OperationIterator) bufLen() int { |
| 946 |
return len(it.items) |
| 947 |
} |
| 948 |
|
| 949 |
func (it *OperationIterator) takeBuf() interface{} { |
| 950 |
b := it.items |
| 951 |
it.items = nil |
| 952 |
return b |
| 953 |
} |
| 954 |
|
| 955 |
// SnapshotIterator manages a stream of *filestorepb.Snapshot. |
| 956 |
type SnapshotIterator struct { |
| 957 |
items []*filestorepb.Snapshot |
| 958 |
pageInfo *iterator.PageInfo |
| 959 |
nextFunc func() error |
| 960 |
|
| 961 |
// Response is the raw response for the current page. |
| 962 |
// It must be cast to the RPC response type. |
| 963 |
// Calling Next() or InternalFetch() updates this value. |
| 964 |
Response interface{} |
| 965 |
|
| 966 |
// InternalFetch is for use by the Google Cloud Libraries only. |
| 967 |
// It is not part of the stable interface of this package. |
| 968 |
// |
| 969 |
// InternalFetch returns results from a single call to the underlying RPC. |
| 970 |
// The number of results is no greater than pageSize. |
| 971 |
// If there are no more results, nextPageToken is empty and err is nil. |
| 972 |
InternalFetch func(pageSize int, pageToken string) (results []*filestorepb.Snapshot, nextPageToken string, err error) |
| 973 |
} |
| 974 |
|
| 975 |
// PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details. |
| 976 |
func (it *SnapshotIterator) PageInfo() *iterator.PageInfo { |
| 977 |
return it.pageInfo |
| 978 |
} |
| 979 |
|
| 980 |
// Next returns the next result. Its second return value is iterator.Done if there are no more |
| 981 |
// results. Once Next returns Done, all subsequent calls will return Done. |
| 982 |
func (it *SnapshotIterator) Next() (*filestorepb.Snapshot, error) { |
| 983 |
var item *filestorepb.Snapshot |
| 984 |
if err := it.nextFunc(); err != nil { |
| 985 |
return item, err |
| 986 |
} |
| 987 |
item = it.items[0] |
| 988 |
it.items = it.items[1:] |
| 989 |
return item, nil |
| 990 |
} |
| 991 |
|
| 992 |
func (it *SnapshotIterator) bufLen() int { |
| 993 |
return len(it.items) |
| 994 |
} |
| 995 |
|
| 996 |
func (it *SnapshotIterator) takeBuf() interface{} { |
| 997 |
b := it.items |
| 998 |
it.items = nil |
| 999 |
return b |
| 1000 |
} |