| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package licensemanager |
| 18 |
|
| 19 |
import ( |
| 20 |
"context" |
| 21 |
"time" |
| 22 |
|
| 23 |
licensemanagerpb "cloud.google.com/go/licensemanager/apiv1/licensemanagerpb" |
| 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 |
locationpb "google.golang.org/genproto/googleapis/cloud/location" |
| 29 |
) |
| 30 |
|
| 31 |
|
| 32 |
type CreateConfigurationOperation struct { |
| 33 |
lro *longrunning.Operation |
| 34 |
pollPath string |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
func (op *CreateConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) { |
| 41 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 42 |
var resp licensemanagerpb.Configuration |
| 43 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 44 |
return nil, err |
| 45 |
} |
| 46 |
return &resp, nil |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
func (op *CreateConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) { |
| 59 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 60 |
var resp licensemanagerpb.Configuration |
| 61 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 62 |
return nil, err |
| 63 |
} |
| 64 |
if !op.Done() { |
| 65 |
return nil, nil |
| 66 |
} |
| 67 |
return &resp, nil |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
func (op *CreateConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) { |
| 75 |
var meta licensemanagerpb.OperationMetadata |
| 76 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 77 |
return nil, nil |
| 78 |
} else if err != nil { |
| 79 |
return nil, err |
| 80 |
} |
| 81 |
return &meta, nil |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
func (op *CreateConfigurationOperation) Done() bool { |
| 86 |
return op.lro.Done() |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
func (op *CreateConfigurationOperation) Name() string { |
| 92 |
return op.lro.Name() |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
type DeactivateConfigurationOperation struct { |
| 97 |
lro *longrunning.Operation |
| 98 |
pollPath string |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
func (op *DeactivateConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) { |
| 105 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 106 |
var resp licensemanagerpb.Configuration |
| 107 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 108 |
return nil, err |
| 109 |
} |
| 110 |
return &resp, nil |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
func (op *DeactivateConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) { |
| 123 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 124 |
var resp licensemanagerpb.Configuration |
| 125 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 126 |
return nil, err |
| 127 |
} |
| 128 |
if !op.Done() { |
| 129 |
return nil, nil |
| 130 |
} |
| 131 |
return &resp, nil |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
func (op *DeactivateConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) { |
| 139 |
var meta licensemanagerpb.OperationMetadata |
| 140 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 141 |
return nil, nil |
| 142 |
} else if err != nil { |
| 143 |
return nil, err |
| 144 |
} |
| 145 |
return &meta, nil |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
func (op *DeactivateConfigurationOperation) Done() bool { |
| 150 |
return op.lro.Done() |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
func (op *DeactivateConfigurationOperation) Name() string { |
| 156 |
return op.lro.Name() |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
type DeleteConfigurationOperation struct { |
| 161 |
lro *longrunning.Operation |
| 162 |
pollPath string |
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
func (op *DeleteConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { |
| 169 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 170 |
return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
func (op *DeleteConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { |
| 183 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 184 |
return op.lro.Poll(ctx, nil, opts...) |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
func (op *DeleteConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) { |
| 192 |
var meta licensemanagerpb.OperationMetadata |
| 193 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 194 |
return nil, nil |
| 195 |
} else if err != nil { |
| 196 |
return nil, err |
| 197 |
} |
| 198 |
return &meta, nil |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
func (op *DeleteConfigurationOperation) Done() bool { |
| 203 |
return op.lro.Done() |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
func (op *DeleteConfigurationOperation) Name() string { |
| 209 |
return op.lro.Name() |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
type ReactivateConfigurationOperation struct { |
| 214 |
lro *longrunning.Operation |
| 215 |
pollPath string |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
func (op *ReactivateConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) { |
| 222 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 223 |
var resp licensemanagerpb.Configuration |
| 224 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 225 |
return nil, err |
| 226 |
} |
| 227 |
return &resp, nil |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
func (op *ReactivateConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) { |
| 240 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 241 |
var resp licensemanagerpb.Configuration |
| 242 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 243 |
return nil, err |
| 244 |
} |
| 245 |
if !op.Done() { |
| 246 |
return nil, nil |
| 247 |
} |
| 248 |
return &resp, nil |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
func (op *ReactivateConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) { |
| 256 |
var meta licensemanagerpb.OperationMetadata |
| 257 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 258 |
return nil, nil |
| 259 |
} else if err != nil { |
| 260 |
return nil, err |
| 261 |
} |
| 262 |
return &meta, nil |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
func (op *ReactivateConfigurationOperation) Done() bool { |
| 267 |
return op.lro.Done() |
| 268 |
} |
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
func (op *ReactivateConfigurationOperation) Name() string { |
| 273 |
return op.lro.Name() |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
type UpdateConfigurationOperation struct { |
| 278 |
lro *longrunning.Operation |
| 279 |
pollPath string |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
func (op *UpdateConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) { |
| 286 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 287 |
var resp licensemanagerpb.Configuration |
| 288 |
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { |
| 289 |
return nil, err |
| 290 |
} |
| 291 |
return &resp, nil |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
func (op *UpdateConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) { |
| 304 |
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...) |
| 305 |
var resp licensemanagerpb.Configuration |
| 306 |
if err := op.lro.Poll(ctx, &resp, opts...); err != nil { |
| 307 |
return nil, err |
| 308 |
} |
| 309 |
if !op.Done() { |
| 310 |
return nil, nil |
| 311 |
} |
| 312 |
return &resp, nil |
| 313 |
} |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
func (op *UpdateConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) { |
| 320 |
var meta licensemanagerpb.OperationMetadata |
| 321 |
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { |
| 322 |
return nil, nil |
| 323 |
} else if err != nil { |
| 324 |
return nil, err |
| 325 |
} |
| 326 |
return &meta, nil |
| 327 |
} |
| 328 |
|
| 329 |
|
| 330 |
func (op *UpdateConfigurationOperation) Done() bool { |
| 331 |
return op.lro.Done() |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
func (op *UpdateConfigurationOperation) Name() string { |
| 337 |
return op.lro.Name() |
| 338 |
} |
| 339 |
|
| 340 |
|
| 341 |
type ConfigurationIterator struct { |
| 342 |
items []*licensemanagerpb.Configuration |
| 343 |
pageInfo *iterator.PageInfo |
| 344 |
nextFunc func() error |
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
Response interface{} |
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
InternalFetch func(pageSize int, pageToken string) (results []*licensemanagerpb.Configuration, nextPageToken string, err error) |
| 358 |
} |
| 359 |
|
| 360 |
|
| 361 |
func (it *ConfigurationIterator) PageInfo() *iterator.PageInfo { |
| 362 |
return it.pageInfo |
| 363 |
} |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
func (it *ConfigurationIterator) Next() (*licensemanagerpb.Configuration, error) { |
| 368 |
var item *licensemanagerpb.Configuration |
| 369 |
if err := it.nextFunc(); err != nil { |
| 370 |
return item, err |
| 371 |
} |
| 372 |
item = it.items[0] |
| 373 |
it.items = it.items[1:] |
| 374 |
return item, nil |
| 375 |
} |
| 376 |
|
| 377 |
func (it *ConfigurationIterator) bufLen() int { |
| 378 |
return len(it.items) |
| 379 |
} |
| 380 |
|
| 381 |
func (it *ConfigurationIterator) takeBuf() interface{} { |
| 382 |
b := it.items |
| 383 |
it.items = nil |
| 384 |
return b |
| 385 |
} |
| 386 |
|
| 387 |
|
| 388 |
type InstanceIterator struct { |
| 389 |
items []*licensemanagerpb.Instance |
| 390 |
pageInfo *iterator.PageInfo |
| 391 |
nextFunc func() error |
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
Response interface{} |
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
InternalFetch func(pageSize int, pageToken string) (results []*licensemanagerpb.Instance, nextPageToken string, err error) |
| 405 |
} |
| 406 |
|
| 407 |
|
| 408 |
func (it *InstanceIterator) PageInfo() *iterator.PageInfo { |
| 409 |
return it.pageInfo |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
func (it *InstanceIterator) Next() (*licensemanagerpb.Instance, error) { |
| 415 |
var item *licensemanagerpb.Instance |
| 416 |
if err := it.nextFunc(); err != nil { |
| 417 |
return item, err |
| 418 |
} |
| 419 |
item = it.items[0] |
| 420 |
it.items = it.items[1:] |
| 421 |
return item, nil |
| 422 |
} |
| 423 |
|
| 424 |
func (it *InstanceIterator) bufLen() int { |
| 425 |
return len(it.items) |
| 426 |
} |
| 427 |
|
| 428 |
func (it *InstanceIterator) takeBuf() interface{} { |
| 429 |
b := it.items |
| 430 |
it.items = nil |
| 431 |
return b |
| 432 |
} |
| 433 |
|
| 434 |
|
| 435 |
type LocationIterator struct { |
| 436 |
items []*locationpb.Location |
| 437 |
pageInfo *iterator.PageInfo |
| 438 |
nextFunc func() error |
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
Response interface{} |
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
InternalFetch func(pageSize int, pageToken string) (results []*locationpb.Location, nextPageToken string, err error) |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
func (it *LocationIterator) PageInfo() *iterator.PageInfo { |
| 456 |
return it.pageInfo |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
func (it *LocationIterator) Next() (*locationpb.Location, error) { |
| 462 |
var item *locationpb.Location |
| 463 |
if err := it.nextFunc(); err != nil { |
| 464 |
return item, err |
| 465 |
} |
| 466 |
item = it.items[0] |
| 467 |
it.items = it.items[1:] |
| 468 |
return item, nil |
| 469 |
} |
| 470 |
|
| 471 |
func (it *LocationIterator) bufLen() int { |
| 472 |
return len(it.items) |
| 473 |
} |
| 474 |
|
| 475 |
func (it *LocationIterator) takeBuf() interface{} { |
| 476 |
b := it.items |
| 477 |
it.items = nil |
| 478 |
return b |
| 479 |
} |
| 480 |
|
| 481 |
|
| 482 |
type OperationIterator struct { |
| 483 |
items []*longrunningpb.Operation |
| 484 |
pageInfo *iterator.PageInfo |
| 485 |
nextFunc func() error |
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
Response interface{} |
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
InternalFetch func(pageSize int, pageToken string) (results []*longrunningpb.Operation, nextPageToken string, err error) |
| 499 |
} |
| 500 |
|
| 501 |
|
| 502 |
func (it *OperationIterator) PageInfo() *iterator.PageInfo { |
| 503 |
return it.pageInfo |
| 504 |
} |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
func (it *OperationIterator) Next() (*longrunningpb.Operation, error) { |
| 509 |
var item *longrunningpb.Operation |
| 510 |
if err := it.nextFunc(); err != nil { |
| 511 |
return item, err |
| 512 |
} |
| 513 |
item = it.items[0] |
| 514 |
it.items = it.items[1:] |
| 515 |
return item, nil |
| 516 |
} |
| 517 |
|
| 518 |
func (it *OperationIterator) bufLen() int { |
| 519 |
return len(it.items) |
| 520 |
} |
| 521 |
|
| 522 |
func (it *OperationIterator) takeBuf() interface{} { |
| 523 |
b := it.items |
| 524 |
it.items = nil |
| 525 |
return b |
| 526 |
} |
| 527 |
|
| 528 |
|
| 529 |
type ProductIterator struct { |
| 530 |
items []*licensemanagerpb.Product |
| 531 |
pageInfo *iterator.PageInfo |
| 532 |
nextFunc func() error |
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
Response interface{} |
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
InternalFetch func(pageSize int, pageToken string) (results []*licensemanagerpb.Product, nextPageToken string, err error) |
| 546 |
} |
| 547 |
|
| 548 |
|
| 549 |
func (it *ProductIterator) PageInfo() *iterator.PageInfo { |
| 550 |
return it.pageInfo |
| 551 |
} |
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
func (it *ProductIterator) Next() (*licensemanagerpb.Product, error) { |
| 556 |
var item *licensemanagerpb.Product |
| 557 |
if err := it.nextFunc(); err != nil { |
| 558 |
return item, err |
| 559 |
} |
| 560 |
item = it.items[0] |
| 561 |
it.items = it.items[1:] |
| 562 |
return item, nil |
| 563 |
} |
| 564 |
|
| 565 |
func (it *ProductIterator) bufLen() int { |
| 566 |
return len(it.items) |
| 567 |
} |
| 568 |
|
| 569 |
func (it *ProductIterator) takeBuf() interface{} { |
| 570 |
b := it.items |
| 571 |
it.items = nil |
| 572 |
return b |
| 573 |
} |
| 574 |
|
| 575 |
|
| 576 |
type UsageIterator struct { |
| 577 |
items []*licensemanagerpb.Usage |
| 578 |
pageInfo *iterator.PageInfo |
| 579 |
nextFunc func() error |
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
Response interface{} |
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
InternalFetch func(pageSize int, pageToken string) (results []*licensemanagerpb.Usage, nextPageToken string, err error) |
| 593 |
} |
| 594 |
|
| 595 |
|
| 596 |
func (it *UsageIterator) PageInfo() *iterator.PageInfo { |
| 597 |
return it.pageInfo |
| 598 |
} |
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
func (it *UsageIterator) Next() (*licensemanagerpb.Usage, error) { |
| 603 |
var item *licensemanagerpb.Usage |
| 604 |
if err := it.nextFunc(); err != nil { |
| 605 |
return item, err |
| 606 |
} |
| 607 |
item = it.items[0] |
| 608 |
it.items = it.items[1:] |
| 609 |
return item, nil |
| 610 |
} |
| 611 |
|
| 612 |
func (it *UsageIterator) bufLen() int { |
| 613 |
return len(it.items) |
| 614 |
} |
| 615 |
|
| 616 |
func (it *UsageIterator) takeBuf() interface{} { |
| 617 |
b := it.items |
| 618 |
it.items = nil |
| 619 |
return b |
| 620 |
} |