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