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