1// Copyright 2021 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
17package artifactregistry
18
19import (
20	"context"
21	"fmt"
22	"math"
23	"net/url"
24	"time"
25
26	"cloud.google.com/go/longrunning"
27	lroauto "cloud.google.com/go/longrunning/autogen"
28	"github.com/golang/protobuf/proto"
29	gax "github.com/googleapis/gax-go/v2"
30	"google.golang.org/api/iterator"
31	"google.golang.org/api/option"
32	"google.golang.org/api/option/internaloption"
33	gtransport "google.golang.org/api/transport/grpc"
34	artifactregistrypb "google.golang.org/genproto/googleapis/devtools/artifactregistry/v1beta2"
35	iampb "google.golang.org/genproto/googleapis/iam/v1"
36	longrunningpb "google.golang.org/genproto/googleapis/longrunning"
37	"google.golang.org/grpc"
38	"google.golang.org/grpc/codes"
39	"google.golang.org/grpc/metadata"
40)
41
42var newClientHook clientHook
43
44// CallOptions contains the retry settings for each method of Client.
45type CallOptions struct {
46	ListRepositories   []gax.CallOption
47	GetRepository      []gax.CallOption
48	CreateRepository   []gax.CallOption
49	UpdateRepository   []gax.CallOption
50	DeleteRepository   []gax.CallOption
51	ListPackages       []gax.CallOption
52	GetPackage         []gax.CallOption
53	DeletePackage      []gax.CallOption
54	ListVersions       []gax.CallOption
55	GetVersion         []gax.CallOption
56	DeleteVersion      []gax.CallOption
57	ListFiles          []gax.CallOption
58	GetFile            []gax.CallOption
59	ListTags           []gax.CallOption
60	GetTag             []gax.CallOption
61	CreateTag          []gax.CallOption
62	UpdateTag          []gax.CallOption
63	DeleteTag          []gax.CallOption
64	SetIamPolicy       []gax.CallOption
65	GetIamPolicy       []gax.CallOption
66	TestIamPermissions []gax.CallOption
67}
68
69func defaultClientOptions() []option.ClientOption {
70	return []option.ClientOption{
71		internaloption.WithDefaultEndpoint("artifactregistry.googleapis.com:443"),
72		internaloption.WithDefaultMTLSEndpoint("artifactregistry.mtls.googleapis.com:443"),
73		internaloption.WithDefaultAudience("https://artifactregistry.googleapis.com/"),
74		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
75		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
76		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
77			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
78	}
79}
80
81func defaultCallOptions() *CallOptions {
82	return &CallOptions{
83		ListRepositories: []gax.CallOption{
84			gax.WithRetry(func() gax.Retryer {
85				return gax.OnCodes([]codes.Code{
86					codes.Unavailable,
87				}, gax.Backoff{
88					Initial:    100 * time.Millisecond,
89					Max:        60000 * time.Millisecond,
90					Multiplier: 1.30,
91				})
92			}),
93		},
94		GetRepository: []gax.CallOption{
95			gax.WithRetry(func() gax.Retryer {
96				return gax.OnCodes([]codes.Code{
97					codes.Unavailable,
98				}, gax.Backoff{
99					Initial:    100 * time.Millisecond,
100					Max:        60000 * time.Millisecond,
101					Multiplier: 1.30,
102				})
103			}),
104		},
105		CreateRepository: []gax.CallOption{},
106		UpdateRepository: []gax.CallOption{},
107		DeleteRepository: []gax.CallOption{
108			gax.WithRetry(func() gax.Retryer {
109				return gax.OnCodes([]codes.Code{
110					codes.Unavailable,
111				}, gax.Backoff{
112					Initial:    100 * time.Millisecond,
113					Max:        60000 * time.Millisecond,
114					Multiplier: 1.30,
115				})
116			}),
117		},
118		ListPackages: []gax.CallOption{
119			gax.WithRetry(func() gax.Retryer {
120				return gax.OnCodes([]codes.Code{
121					codes.Unavailable,
122				}, gax.Backoff{
123					Initial:    100 * time.Millisecond,
124					Max:        60000 * time.Millisecond,
125					Multiplier: 1.30,
126				})
127			}),
128		},
129		GetPackage: []gax.CallOption{
130			gax.WithRetry(func() gax.Retryer {
131				return gax.OnCodes([]codes.Code{
132					codes.Unavailable,
133				}, gax.Backoff{
134					Initial:    100 * time.Millisecond,
135					Max:        60000 * time.Millisecond,
136					Multiplier: 1.30,
137				})
138			}),
139		},
140		DeletePackage: []gax.CallOption{
141			gax.WithRetry(func() gax.Retryer {
142				return gax.OnCodes([]codes.Code{
143					codes.Unavailable,
144				}, gax.Backoff{
145					Initial:    100 * time.Millisecond,
146					Max:        60000 * time.Millisecond,
147					Multiplier: 1.30,
148				})
149			}),
150		},
151		ListVersions: []gax.CallOption{
152			gax.WithRetry(func() gax.Retryer {
153				return gax.OnCodes([]codes.Code{
154					codes.Unavailable,
155				}, gax.Backoff{
156					Initial:    100 * time.Millisecond,
157					Max:        60000 * time.Millisecond,
158					Multiplier: 1.30,
159				})
160			}),
161		},
162		GetVersion: []gax.CallOption{
163			gax.WithRetry(func() gax.Retryer {
164				return gax.OnCodes([]codes.Code{
165					codes.Unavailable,
166				}, gax.Backoff{
167					Initial:    100 * time.Millisecond,
168					Max:        60000 * time.Millisecond,
169					Multiplier: 1.30,
170				})
171			}),
172		},
173		DeleteVersion: []gax.CallOption{
174			gax.WithRetry(func() gax.Retryer {
175				return gax.OnCodes([]codes.Code{
176					codes.Unavailable,
177				}, gax.Backoff{
178					Initial:    100 * time.Millisecond,
179					Max:        60000 * time.Millisecond,
180					Multiplier: 1.30,
181				})
182			}),
183		},
184		ListFiles: []gax.CallOption{
185			gax.WithRetry(func() gax.Retryer {
186				return gax.OnCodes([]codes.Code{
187					codes.Unavailable,
188				}, gax.Backoff{
189					Initial:    100 * time.Millisecond,
190					Max:        60000 * time.Millisecond,
191					Multiplier: 1.30,
192				})
193			}),
194		},
195		GetFile: []gax.CallOption{
196			gax.WithRetry(func() gax.Retryer {
197				return gax.OnCodes([]codes.Code{
198					codes.Unavailable,
199				}, gax.Backoff{
200					Initial:    100 * time.Millisecond,
201					Max:        60000 * time.Millisecond,
202					Multiplier: 1.30,
203				})
204			}),
205		},
206		ListTags: []gax.CallOption{
207			gax.WithRetry(func() gax.Retryer {
208				return gax.OnCodes([]codes.Code{
209					codes.Unavailable,
210				}, gax.Backoff{
211					Initial:    100 * time.Millisecond,
212					Max:        60000 * time.Millisecond,
213					Multiplier: 1.30,
214				})
215			}),
216		},
217		GetTag: []gax.CallOption{
218			gax.WithRetry(func() gax.Retryer {
219				return gax.OnCodes([]codes.Code{
220					codes.Unavailable,
221				}, gax.Backoff{
222					Initial:    100 * time.Millisecond,
223					Max:        60000 * time.Millisecond,
224					Multiplier: 1.30,
225				})
226			}),
227		},
228		CreateTag: []gax.CallOption{},
229		UpdateTag: []gax.CallOption{},
230		DeleteTag: []gax.CallOption{
231			gax.WithRetry(func() gax.Retryer {
232				return gax.OnCodes([]codes.Code{
233					codes.Unavailable,
234				}, gax.Backoff{
235					Initial:    100 * time.Millisecond,
236					Max:        60000 * time.Millisecond,
237					Multiplier: 1.30,
238				})
239			}),
240		},
241		SetIamPolicy: []gax.CallOption{},
242		GetIamPolicy: []gax.CallOption{
243			gax.WithRetry(func() gax.Retryer {
244				return gax.OnCodes([]codes.Code{
245					codes.Unavailable,
246				}, gax.Backoff{
247					Initial:    100 * time.Millisecond,
248					Max:        60000 * time.Millisecond,
249					Multiplier: 1.30,
250				})
251			}),
252		},
253		TestIamPermissions: []gax.CallOption{},
254	}
255}
256
257// Client is a client for interacting with Artifact Registry API.
258//
259// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
260type Client struct {
261	// Connection pool of gRPC connections to the service.
262	connPool gtransport.ConnPool
263
264	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
265	disableDeadlines bool
266
267	// The gRPC API client.
268	client artifactregistrypb.ArtifactRegistryClient
269
270	// LROClient is used internally to handle longrunning operations.
271	// It is exposed so that its CallOptions can be modified if required.
272	// Users should not Close this client.
273	LROClient *lroauto.OperationsClient
274
275	// The call options for this service.
276	CallOptions *CallOptions
277
278	// The x-goog-* metadata to be sent with each request.
279	xGoogMetadata metadata.MD
280}
281
282// NewClient creates a new artifact registry client.
283//
284// The Artifact Registry API service.
285//
286// Artifact Registry is an artifact management system for storing artifacts
287// from different package management systems.
288//
289// The resources managed by this API are:
290//
291//   Repositories, which group packages and their data.
292//
293//   Packages, which group versions and their tags.
294//
295//   Versions, which are specific forms of a package.
296//
297//   Tags, which represent alternative names for versions.
298//
299//   Files, which contain content and are optionally associated with a Package
300//   or Version.
301func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
302	clientOpts := defaultClientOptions()
303
304	if newClientHook != nil {
305		hookOpts, err := newClientHook(ctx, clientHookParams{})
306		if err != nil {
307			return nil, err
308		}
309		clientOpts = append(clientOpts, hookOpts...)
310	}
311
312	disableDeadlines, err := checkDisableDeadlines()
313	if err != nil {
314		return nil, err
315	}
316
317	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
318	if err != nil {
319		return nil, err
320	}
321	c := &Client{
322		connPool:         connPool,
323		disableDeadlines: disableDeadlines,
324		CallOptions:      defaultCallOptions(),
325
326		client: artifactregistrypb.NewArtifactRegistryClient(connPool),
327	}
328	c.setGoogleClientInfo()
329
330	c.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
331	if err != nil {
332		// This error "should not happen", since we are just reusing old connection pool
333		// and never actually need to dial.
334		// If this does happen, we could leak connp. However, we cannot close conn:
335		// If the user invoked the constructor with option.WithGRPCConn,
336		// we would close a connection that's still in use.
337		// TODO: investigate error conditions.
338		return nil, err
339	}
340	return c, nil
341}
342
343// Connection returns a connection to the API service.
344//
345// Deprecated.
346func (c *Client) Connection() *grpc.ClientConn {
347	return c.connPool.Conn()
348}
349
350// Close closes the connection to the API service. The user should invoke this when
351// the client is no longer required.
352func (c *Client) Close() error {
353	return c.connPool.Close()
354}
355
356// setGoogleClientInfo sets the name and version of the application in
357// the `x-goog-api-client` header passed on each request. Intended for
358// use by Google-written clients.
359func (c *Client) setGoogleClientInfo(keyval ...string) {
360	kv := append([]string{"gl-go", versionGo()}, keyval...)
361	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
362	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
363}
364
365// ListRepositories lists repositories.
366func (c *Client) ListRepositories(ctx context.Context, req *artifactregistrypb.ListRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
367	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
368	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
369	opts = append(c.CallOptions.ListRepositories[0:len(c.CallOptions.ListRepositories):len(c.CallOptions.ListRepositories)], opts...)
370	it := &RepositoryIterator{}
371	req = proto.Clone(req).(*artifactregistrypb.ListRepositoriesRequest)
372	it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Repository, string, error) {
373		var resp *artifactregistrypb.ListRepositoriesResponse
374		req.PageToken = pageToken
375		if pageSize > math.MaxInt32 {
376			req.PageSize = math.MaxInt32
377		} else {
378			req.PageSize = int32(pageSize)
379		}
380		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
381			var err error
382			resp, err = c.client.ListRepositories(ctx, req, settings.GRPC...)
383			return err
384		}, opts...)
385		if err != nil {
386			return nil, "", err
387		}
388
389		it.Response = resp
390		return resp.GetRepositories(), resp.GetNextPageToken(), nil
391	}
392	fetch := func(pageSize int, pageToken string) (string, error) {
393		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
394		if err != nil {
395			return "", err
396		}
397		it.items = append(it.items, items...)
398		return nextPageToken, nil
399	}
400	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
401	it.pageInfo.MaxSize = int(req.GetPageSize())
402	it.pageInfo.Token = req.GetPageToken()
403	return it
404}
405
406// GetRepository gets a repository.
407func (c *Client) GetRepository(ctx context.Context, req *artifactregistrypb.GetRepositoryRequest, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
408	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
409		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
410		defer cancel()
411		ctx = cctx
412	}
413	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
414	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
415	opts = append(c.CallOptions.GetRepository[0:len(c.CallOptions.GetRepository):len(c.CallOptions.GetRepository)], opts...)
416	var resp *artifactregistrypb.Repository
417	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
418		var err error
419		resp, err = c.client.GetRepository(ctx, req, settings.GRPC...)
420		return err
421	}, opts...)
422	if err != nil {
423		return nil, err
424	}
425	return resp, nil
426}
427
428// CreateRepository creates a repository. The returned Operation will finish once the
429// repository has been created. Its response will be the created Repository.
430func (c *Client) CreateRepository(ctx context.Context, req *artifactregistrypb.CreateRepositoryRequest, opts ...gax.CallOption) (*CreateRepositoryOperation, error) {
431	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
432		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
433		defer cancel()
434		ctx = cctx
435	}
436	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
437	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
438	opts = append(c.CallOptions.CreateRepository[0:len(c.CallOptions.CreateRepository):len(c.CallOptions.CreateRepository)], opts...)
439	var resp *longrunningpb.Operation
440	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
441		var err error
442		resp, err = c.client.CreateRepository(ctx, req, settings.GRPC...)
443		return err
444	}, opts...)
445	if err != nil {
446		return nil, err
447	}
448	return &CreateRepositoryOperation{
449		lro: longrunning.InternalNewOperation(c.LROClient, resp),
450	}, nil
451}
452
453// UpdateRepository updates a repository.
454func (c *Client) UpdateRepository(ctx context.Context, req *artifactregistrypb.UpdateRepositoryRequest, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
455	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
456		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
457		defer cancel()
458		ctx = cctx
459	}
460	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "repository.name", url.QueryEscape(req.GetRepository().GetName())))
461	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
462	opts = append(c.CallOptions.UpdateRepository[0:len(c.CallOptions.UpdateRepository):len(c.CallOptions.UpdateRepository)], opts...)
463	var resp *artifactregistrypb.Repository
464	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
465		var err error
466		resp, err = c.client.UpdateRepository(ctx, req, settings.GRPC...)
467		return err
468	}, opts...)
469	if err != nil {
470		return nil, err
471	}
472	return resp, nil
473}
474
475// DeleteRepository deletes a repository and all of its contents. The returned Operation will
476// finish once the repository has been deleted. It will not have any Operation
477// metadata and will return a google.protobuf.Empty response.
478func (c *Client) DeleteRepository(ctx context.Context, req *artifactregistrypb.DeleteRepositoryRequest, opts ...gax.CallOption) (*DeleteRepositoryOperation, error) {
479	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
480		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
481		defer cancel()
482		ctx = cctx
483	}
484	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
485	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
486	opts = append(c.CallOptions.DeleteRepository[0:len(c.CallOptions.DeleteRepository):len(c.CallOptions.DeleteRepository)], opts...)
487	var resp *longrunningpb.Operation
488	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
489		var err error
490		resp, err = c.client.DeleteRepository(ctx, req, settings.GRPC...)
491		return err
492	}, opts...)
493	if err != nil {
494		return nil, err
495	}
496	return &DeleteRepositoryOperation{
497		lro: longrunning.InternalNewOperation(c.LROClient, resp),
498	}, nil
499}
500
501// ListPackages lists packages.
502func (c *Client) ListPackages(ctx context.Context, req *artifactregistrypb.ListPackagesRequest, opts ...gax.CallOption) *PackageIterator {
503	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
504	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
505	opts = append(c.CallOptions.ListPackages[0:len(c.CallOptions.ListPackages):len(c.CallOptions.ListPackages)], opts...)
506	it := &PackageIterator{}
507	req = proto.Clone(req).(*artifactregistrypb.ListPackagesRequest)
508	it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Package, string, error) {
509		var resp *artifactregistrypb.ListPackagesResponse
510		req.PageToken = pageToken
511		if pageSize > math.MaxInt32 {
512			req.PageSize = math.MaxInt32
513		} else {
514			req.PageSize = int32(pageSize)
515		}
516		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
517			var err error
518			resp, err = c.client.ListPackages(ctx, req, settings.GRPC...)
519			return err
520		}, opts...)
521		if err != nil {
522			return nil, "", err
523		}
524
525		it.Response = resp
526		return resp.GetPackages(), resp.GetNextPageToken(), nil
527	}
528	fetch := func(pageSize int, pageToken string) (string, error) {
529		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
530		if err != nil {
531			return "", err
532		}
533		it.items = append(it.items, items...)
534		return nextPageToken, nil
535	}
536	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
537	it.pageInfo.MaxSize = int(req.GetPageSize())
538	it.pageInfo.Token = req.GetPageToken()
539	return it
540}
541
542// GetPackage gets a package.
543func (c *Client) GetPackage(ctx context.Context, req *artifactregistrypb.GetPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.Package, error) {
544	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
545		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
546		defer cancel()
547		ctx = cctx
548	}
549	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
550	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
551	opts = append(c.CallOptions.GetPackage[0:len(c.CallOptions.GetPackage):len(c.CallOptions.GetPackage)], opts...)
552	var resp *artifactregistrypb.Package
553	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
554		var err error
555		resp, err = c.client.GetPackage(ctx, req, settings.GRPC...)
556		return err
557	}, opts...)
558	if err != nil {
559		return nil, err
560	}
561	return resp, nil
562}
563
564// DeletePackage deletes a package and all of its versions and tags. The returned operation
565// will complete once the package has been deleted.
566func (c *Client) DeletePackage(ctx context.Context, req *artifactregistrypb.DeletePackageRequest, opts ...gax.CallOption) (*DeletePackageOperation, error) {
567	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
568		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
569		defer cancel()
570		ctx = cctx
571	}
572	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
573	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
574	opts = append(c.CallOptions.DeletePackage[0:len(c.CallOptions.DeletePackage):len(c.CallOptions.DeletePackage)], opts...)
575	var resp *longrunningpb.Operation
576	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
577		var err error
578		resp, err = c.client.DeletePackage(ctx, req, settings.GRPC...)
579		return err
580	}, opts...)
581	if err != nil {
582		return nil, err
583	}
584	return &DeletePackageOperation{
585		lro: longrunning.InternalNewOperation(c.LROClient, resp),
586	}, nil
587}
588
589// ListVersions lists versions.
590func (c *Client) ListVersions(ctx context.Context, req *artifactregistrypb.ListVersionsRequest, opts ...gax.CallOption) *VersionIterator {
591	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
592	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
593	opts = append(c.CallOptions.ListVersions[0:len(c.CallOptions.ListVersions):len(c.CallOptions.ListVersions)], opts...)
594	it := &VersionIterator{}
595	req = proto.Clone(req).(*artifactregistrypb.ListVersionsRequest)
596	it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Version, string, error) {
597		var resp *artifactregistrypb.ListVersionsResponse
598		req.PageToken = pageToken
599		if pageSize > math.MaxInt32 {
600			req.PageSize = math.MaxInt32
601		} else {
602			req.PageSize = int32(pageSize)
603		}
604		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
605			var err error
606			resp, err = c.client.ListVersions(ctx, req, settings.GRPC...)
607			return err
608		}, opts...)
609		if err != nil {
610			return nil, "", err
611		}
612
613		it.Response = resp
614		return resp.GetVersions(), resp.GetNextPageToken(), nil
615	}
616	fetch := func(pageSize int, pageToken string) (string, error) {
617		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
618		if err != nil {
619			return "", err
620		}
621		it.items = append(it.items, items...)
622		return nextPageToken, nil
623	}
624	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
625	it.pageInfo.MaxSize = int(req.GetPageSize())
626	it.pageInfo.Token = req.GetPageToken()
627	return it
628}
629
630// GetVersion gets a version
631func (c *Client) GetVersion(ctx context.Context, req *artifactregistrypb.GetVersionRequest, opts ...gax.CallOption) (*artifactregistrypb.Version, error) {
632	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
633		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
634		defer cancel()
635		ctx = cctx
636	}
637	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
638	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
639	opts = append(c.CallOptions.GetVersion[0:len(c.CallOptions.GetVersion):len(c.CallOptions.GetVersion)], opts...)
640	var resp *artifactregistrypb.Version
641	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
642		var err error
643		resp, err = c.client.GetVersion(ctx, req, settings.GRPC...)
644		return err
645	}, opts...)
646	if err != nil {
647		return nil, err
648	}
649	return resp, nil
650}
651
652// DeleteVersion deletes a version and all of its content. The returned operation will
653// complete once the version has been deleted.
654func (c *Client) DeleteVersion(ctx context.Context, req *artifactregistrypb.DeleteVersionRequest, opts ...gax.CallOption) (*DeleteVersionOperation, error) {
655	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
656		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
657		defer cancel()
658		ctx = cctx
659	}
660	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
661	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
662	opts = append(c.CallOptions.DeleteVersion[0:len(c.CallOptions.DeleteVersion):len(c.CallOptions.DeleteVersion)], opts...)
663	var resp *longrunningpb.Operation
664	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
665		var err error
666		resp, err = c.client.DeleteVersion(ctx, req, settings.GRPC...)
667		return err
668	}, opts...)
669	if err != nil {
670		return nil, err
671	}
672	return &DeleteVersionOperation{
673		lro: longrunning.InternalNewOperation(c.LROClient, resp),
674	}, nil
675}
676
677// ListFiles lists files.
678func (c *Client) ListFiles(ctx context.Context, req *artifactregistrypb.ListFilesRequest, opts ...gax.CallOption) *FileIterator {
679	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
680	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
681	opts = append(c.CallOptions.ListFiles[0:len(c.CallOptions.ListFiles):len(c.CallOptions.ListFiles)], opts...)
682	it := &FileIterator{}
683	req = proto.Clone(req).(*artifactregistrypb.ListFilesRequest)
684	it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.File, string, error) {
685		var resp *artifactregistrypb.ListFilesResponse
686		req.PageToken = pageToken
687		if pageSize > math.MaxInt32 {
688			req.PageSize = math.MaxInt32
689		} else {
690			req.PageSize = int32(pageSize)
691		}
692		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
693			var err error
694			resp, err = c.client.ListFiles(ctx, req, settings.GRPC...)
695			return err
696		}, opts...)
697		if err != nil {
698			return nil, "", err
699		}
700
701		it.Response = resp
702		return resp.GetFiles(), resp.GetNextPageToken(), nil
703	}
704	fetch := func(pageSize int, pageToken string) (string, error) {
705		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
706		if err != nil {
707			return "", err
708		}
709		it.items = append(it.items, items...)
710		return nextPageToken, nil
711	}
712	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
713	it.pageInfo.MaxSize = int(req.GetPageSize())
714	it.pageInfo.Token = req.GetPageToken()
715	return it
716}
717
718// GetFile gets a file.
719func (c *Client) GetFile(ctx context.Context, req *artifactregistrypb.GetFileRequest, opts ...gax.CallOption) (*artifactregistrypb.File, error) {
720	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
721		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
722		defer cancel()
723		ctx = cctx
724	}
725	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
726	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
727	opts = append(c.CallOptions.GetFile[0:len(c.CallOptions.GetFile):len(c.CallOptions.GetFile)], opts...)
728	var resp *artifactregistrypb.File
729	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
730		var err error
731		resp, err = c.client.GetFile(ctx, req, settings.GRPC...)
732		return err
733	}, opts...)
734	if err != nil {
735		return nil, err
736	}
737	return resp, nil
738}
739
740// ListTags lists tags.
741func (c *Client) ListTags(ctx context.Context, req *artifactregistrypb.ListTagsRequest, opts ...gax.CallOption) *TagIterator {
742	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
743	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
744	opts = append(c.CallOptions.ListTags[0:len(c.CallOptions.ListTags):len(c.CallOptions.ListTags)], opts...)
745	it := &TagIterator{}
746	req = proto.Clone(req).(*artifactregistrypb.ListTagsRequest)
747	it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Tag, string, error) {
748		var resp *artifactregistrypb.ListTagsResponse
749		req.PageToken = pageToken
750		if pageSize > math.MaxInt32 {
751			req.PageSize = math.MaxInt32
752		} else {
753			req.PageSize = int32(pageSize)
754		}
755		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
756			var err error
757			resp, err = c.client.ListTags(ctx, req, settings.GRPC...)
758			return err
759		}, opts...)
760		if err != nil {
761			return nil, "", err
762		}
763
764		it.Response = resp
765		return resp.GetTags(), resp.GetNextPageToken(), nil
766	}
767	fetch := func(pageSize int, pageToken string) (string, error) {
768		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
769		if err != nil {
770			return "", err
771		}
772		it.items = append(it.items, items...)
773		return nextPageToken, nil
774	}
775	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
776	it.pageInfo.MaxSize = int(req.GetPageSize())
777	it.pageInfo.Token = req.GetPageToken()
778	return it
779}
780
781// GetTag gets a tag.
782func (c *Client) GetTag(ctx context.Context, req *artifactregistrypb.GetTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
783	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
784		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
785		defer cancel()
786		ctx = cctx
787	}
788	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
789	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
790	opts = append(c.CallOptions.GetTag[0:len(c.CallOptions.GetTag):len(c.CallOptions.GetTag)], opts...)
791	var resp *artifactregistrypb.Tag
792	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
793		var err error
794		resp, err = c.client.GetTag(ctx, req, settings.GRPC...)
795		return err
796	}, opts...)
797	if err != nil {
798		return nil, err
799	}
800	return resp, nil
801}
802
803// CreateTag creates a tag.
804func (c *Client) CreateTag(ctx context.Context, req *artifactregistrypb.CreateTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
805	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
806		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
807		defer cancel()
808		ctx = cctx
809	}
810	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
811	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
812	opts = append(c.CallOptions.CreateTag[0:len(c.CallOptions.CreateTag):len(c.CallOptions.CreateTag)], opts...)
813	var resp *artifactregistrypb.Tag
814	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
815		var err error
816		resp, err = c.client.CreateTag(ctx, req, settings.GRPC...)
817		return err
818	}, opts...)
819	if err != nil {
820		return nil, err
821	}
822	return resp, nil
823}
824
825// UpdateTag updates a tag.
826func (c *Client) UpdateTag(ctx context.Context, req *artifactregistrypb.UpdateTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
827	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
828		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
829		defer cancel()
830		ctx = cctx
831	}
832	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "tag.name", url.QueryEscape(req.GetTag().GetName())))
833	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
834	opts = append(c.CallOptions.UpdateTag[0:len(c.CallOptions.UpdateTag):len(c.CallOptions.UpdateTag)], opts...)
835	var resp *artifactregistrypb.Tag
836	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
837		var err error
838		resp, err = c.client.UpdateTag(ctx, req, settings.GRPC...)
839		return err
840	}, opts...)
841	if err != nil {
842		return nil, err
843	}
844	return resp, nil
845}
846
847// DeleteTag deletes a tag.
848func (c *Client) DeleteTag(ctx context.Context, req *artifactregistrypb.DeleteTagRequest, opts ...gax.CallOption) error {
849	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
850		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
851		defer cancel()
852		ctx = cctx
853	}
854	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
855	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
856	opts = append(c.CallOptions.DeleteTag[0:len(c.CallOptions.DeleteTag):len(c.CallOptions.DeleteTag)], opts...)
857	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
858		var err error
859		_, err = c.client.DeleteTag(ctx, req, settings.GRPC...)
860		return err
861	}, opts...)
862	return err
863}
864
865// SetIamPolicy updates the IAM policy for a given resource.
866func (c *Client) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
867	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource())))
868	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
869	opts = append(c.CallOptions.SetIamPolicy[0:len(c.CallOptions.SetIamPolicy):len(c.CallOptions.SetIamPolicy)], opts...)
870	var resp *iampb.Policy
871	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
872		var err error
873		resp, err = c.client.SetIamPolicy(ctx, req, settings.GRPC...)
874		return err
875	}, opts...)
876	if err != nil {
877		return nil, err
878	}
879	return resp, nil
880}
881
882// GetIamPolicy gets the IAM policy for a given resource.
883func (c *Client) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
884	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
885		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
886		defer cancel()
887		ctx = cctx
888	}
889	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource())))
890	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
891	opts = append(c.CallOptions.GetIamPolicy[0:len(c.CallOptions.GetIamPolicy):len(c.CallOptions.GetIamPolicy)], opts...)
892	var resp *iampb.Policy
893	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
894		var err error
895		resp, err = c.client.GetIamPolicy(ctx, req, settings.GRPC...)
896		return err
897	}, opts...)
898	if err != nil {
899		return nil, err
900	}
901	return resp, nil
902}
903
904// TestIamPermissions tests if the caller has a list of permissions on a resource.
905func (c *Client) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
906	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
907		cctx, cancel := context.WithTimeout(ctx, 30000*time.Millisecond)
908		defer cancel()
909		ctx = cctx
910	}
911	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource())))
912	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
913	opts = append(c.CallOptions.TestIamPermissions[0:len(c.CallOptions.TestIamPermissions):len(c.CallOptions.TestIamPermissions)], opts...)
914	var resp *iampb.TestIamPermissionsResponse
915	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
916		var err error
917		resp, err = c.client.TestIamPermissions(ctx, req, settings.GRPC...)
918		return err
919	}, opts...)
920	if err != nil {
921		return nil, err
922	}
923	return resp, nil
924}
925
926// CreateRepositoryOperation manages a long-running operation from CreateRepository.
927type CreateRepositoryOperation struct {
928	lro *longrunning.Operation
929}
930
931// CreateRepositoryOperation returns a new CreateRepositoryOperation from a given name.
932// The name must be that of a previously created CreateRepositoryOperation, possibly from a different process.
933func (c *Client) CreateRepositoryOperation(name string) *CreateRepositoryOperation {
934	return &CreateRepositoryOperation{
935		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
936	}
937}
938
939// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
940//
941// See documentation of Poll for error-handling information.
942func (op *CreateRepositoryOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
943	var resp artifactregistrypb.Repository
944	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
945		return nil, err
946	}
947	return &resp, nil
948}
949
950// Poll fetches the latest state of the long-running operation.
951//
952// Poll also fetches the latest metadata, which can be retrieved by Metadata.
953//
954// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
955// the operation has completed with failure, the error is returned and op.Done will return true.
956// If Poll succeeds and the operation has completed successfully,
957// op.Done will return true, and the response of the operation is returned.
958// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
959func (op *CreateRepositoryOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
960	var resp artifactregistrypb.Repository
961	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
962		return nil, err
963	}
964	if !op.Done() {
965		return nil, nil
966	}
967	return &resp, nil
968}
969
970// Metadata returns metadata associated with the long-running operation.
971// Metadata itself does not contact the server, but Poll does.
972// To get the latest metadata, call this method after a successful call to Poll.
973// If the metadata is not available, the returned metadata and error are both nil.
974func (op *CreateRepositoryOperation) Metadata() (*artifactregistrypb.OperationMetadata, error) {
975	var meta artifactregistrypb.OperationMetadata
976	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
977		return nil, nil
978	} else if err != nil {
979		return nil, err
980	}
981	return &meta, nil
982}
983
984// Done reports whether the long-running operation has completed.
985func (op *CreateRepositoryOperation) Done() bool {
986	return op.lro.Done()
987}
988
989// Name returns the name of the long-running operation.
990// The name is assigned by the server and is unique within the service from which the operation is created.
991func (op *CreateRepositoryOperation) Name() string {
992	return op.lro.Name()
993}
994
995// DeletePackageOperation manages a long-running operation from DeletePackage.
996type DeletePackageOperation struct {
997	lro *longrunning.Operation
998}
999
1000// DeletePackageOperation returns a new DeletePackageOperation from a given name.
1001// The name must be that of a previously created DeletePackageOperation, possibly from a different process.
1002func (c *Client) DeletePackageOperation(name string) *DeletePackageOperation {
1003	return &DeletePackageOperation{
1004		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
1005	}
1006}
1007
1008// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1009//
1010// See documentation of Poll for error-handling information.
1011func (op *DeletePackageOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
1012	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
1013}
1014
1015// Poll fetches the latest state of the long-running operation.
1016//
1017// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1018//
1019// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1020// the operation has completed with failure, the error is returned and op.Done will return true.
1021// If Poll succeeds and the operation has completed successfully,
1022// op.Done will return true, and the response of the operation is returned.
1023// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1024func (op *DeletePackageOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
1025	return op.lro.Poll(ctx, nil, opts...)
1026}
1027
1028// Metadata returns metadata associated with the long-running operation.
1029// Metadata itself does not contact the server, but Poll does.
1030// To get the latest metadata, call this method after a successful call to Poll.
1031// If the metadata is not available, the returned metadata and error are both nil.
1032func (op *DeletePackageOperation) Metadata() (*artifactregistrypb.OperationMetadata, error) {
1033	var meta artifactregistrypb.OperationMetadata
1034	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1035		return nil, nil
1036	} else if err != nil {
1037		return nil, err
1038	}
1039	return &meta, nil
1040}
1041
1042// Done reports whether the long-running operation has completed.
1043func (op *DeletePackageOperation) Done() bool {
1044	return op.lro.Done()
1045}
1046
1047// Name returns the name of the long-running operation.
1048// The name is assigned by the server and is unique within the service from which the operation is created.
1049func (op *DeletePackageOperation) Name() string {
1050	return op.lro.Name()
1051}
1052
1053// DeleteRepositoryOperation manages a long-running operation from DeleteRepository.
1054type DeleteRepositoryOperation struct {
1055	lro *longrunning.Operation
1056}
1057
1058// DeleteRepositoryOperation returns a new DeleteRepositoryOperation from a given name.
1059// The name must be that of a previously created DeleteRepositoryOperation, possibly from a different process.
1060func (c *Client) DeleteRepositoryOperation(name string) *DeleteRepositoryOperation {
1061	return &DeleteRepositoryOperation{
1062		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
1063	}
1064}
1065
1066// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1067//
1068// See documentation of Poll for error-handling information.
1069func (op *DeleteRepositoryOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
1070	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
1071}
1072
1073// Poll fetches the latest state of the long-running operation.
1074//
1075// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1076//
1077// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1078// the operation has completed with failure, the error is returned and op.Done will return true.
1079// If Poll succeeds and the operation has completed successfully,
1080// op.Done will return true, and the response of the operation is returned.
1081// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1082func (op *DeleteRepositoryOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
1083	return op.lro.Poll(ctx, nil, opts...)
1084}
1085
1086// Metadata returns metadata associated with the long-running operation.
1087// Metadata itself does not contact the server, but Poll does.
1088// To get the latest metadata, call this method after a successful call to Poll.
1089// If the metadata is not available, the returned metadata and error are both nil.
1090func (op *DeleteRepositoryOperation) Metadata() (*artifactregistrypb.OperationMetadata, error) {
1091	var meta artifactregistrypb.OperationMetadata
1092	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1093		return nil, nil
1094	} else if err != nil {
1095		return nil, err
1096	}
1097	return &meta, nil
1098}
1099
1100// Done reports whether the long-running operation has completed.
1101func (op *DeleteRepositoryOperation) Done() bool {
1102	return op.lro.Done()
1103}
1104
1105// Name returns the name of the long-running operation.
1106// The name is assigned by the server and is unique within the service from which the operation is created.
1107func (op *DeleteRepositoryOperation) Name() string {
1108	return op.lro.Name()
1109}
1110
1111// DeleteVersionOperation manages a long-running operation from DeleteVersion.
1112type DeleteVersionOperation struct {
1113	lro *longrunning.Operation
1114}
1115
1116// DeleteVersionOperation returns a new DeleteVersionOperation from a given name.
1117// The name must be that of a previously created DeleteVersionOperation, possibly from a different process.
1118func (c *Client) DeleteVersionOperation(name string) *DeleteVersionOperation {
1119	return &DeleteVersionOperation{
1120		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
1121	}
1122}
1123
1124// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1125//
1126// See documentation of Poll for error-handling information.
1127func (op *DeleteVersionOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
1128	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
1129}
1130
1131// Poll fetches the latest state of the long-running operation.
1132//
1133// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1134//
1135// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1136// the operation has completed with failure, the error is returned and op.Done will return true.
1137// If Poll succeeds and the operation has completed successfully,
1138// op.Done will return true, and the response of the operation is returned.
1139// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1140func (op *DeleteVersionOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
1141	return op.lro.Poll(ctx, nil, opts...)
1142}
1143
1144// Metadata returns metadata associated with the long-running operation.
1145// Metadata itself does not contact the server, but Poll does.
1146// To get the latest metadata, call this method after a successful call to Poll.
1147// If the metadata is not available, the returned metadata and error are both nil.
1148func (op *DeleteVersionOperation) Metadata() (*artifactregistrypb.OperationMetadata, error) {
1149	var meta artifactregistrypb.OperationMetadata
1150	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1151		return nil, nil
1152	} else if err != nil {
1153		return nil, err
1154	}
1155	return &meta, nil
1156}
1157
1158// Done reports whether the long-running operation has completed.
1159func (op *DeleteVersionOperation) Done() bool {
1160	return op.lro.Done()
1161}
1162
1163// Name returns the name of the long-running operation.
1164// The name is assigned by the server and is unique within the service from which the operation is created.
1165func (op *DeleteVersionOperation) Name() string {
1166	return op.lro.Name()
1167}
1168
1169// FileIterator manages a stream of *artifactregistrypb.File.
1170type FileIterator struct {
1171	items    []*artifactregistrypb.File
1172	pageInfo *iterator.PageInfo
1173	nextFunc func() error
1174
1175	// Response is the raw response for the current page.
1176	// It must be cast to the RPC response type.
1177	// Calling Next() or InternalFetch() updates this value.
1178	Response interface{}
1179
1180	// InternalFetch is for use by the Google Cloud Libraries only.
1181	// It is not part of the stable interface of this package.
1182	//
1183	// InternalFetch returns results from a single call to the underlying RPC.
1184	// The number of results is no greater than pageSize.
1185	// If there are no more results, nextPageToken is empty and err is nil.
1186	InternalFetch func(pageSize int, pageToken string) (results []*artifactregistrypb.File, nextPageToken string, err error)
1187}
1188
1189// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1190func (it *FileIterator) PageInfo() *iterator.PageInfo {
1191	return it.pageInfo
1192}
1193
1194// Next returns the next result. Its second return value is iterator.Done if there are no more
1195// results. Once Next returns Done, all subsequent calls will return Done.
1196func (it *FileIterator) Next() (*artifactregistrypb.File, error) {
1197	var item *artifactregistrypb.File
1198	if err := it.nextFunc(); err != nil {
1199		return item, err
1200	}
1201	item = it.items[0]
1202	it.items = it.items[1:]
1203	return item, nil
1204}
1205
1206func (it *FileIterator) bufLen() int {
1207	return len(it.items)
1208}
1209
1210func (it *FileIterator) takeBuf() interface{} {
1211	b := it.items
1212	it.items = nil
1213	return b
1214}
1215
1216// PackageIterator manages a stream of *artifactregistrypb.Package.
1217type PackageIterator struct {
1218	items    []*artifactregistrypb.Package
1219	pageInfo *iterator.PageInfo
1220	nextFunc func() error
1221
1222	// Response is the raw response for the current page.
1223	// It must be cast to the RPC response type.
1224	// Calling Next() or InternalFetch() updates this value.
1225	Response interface{}
1226
1227	// InternalFetch is for use by the Google Cloud Libraries only.
1228	// It is not part of the stable interface of this package.
1229	//
1230	// InternalFetch returns results from a single call to the underlying RPC.
1231	// The number of results is no greater than pageSize.
1232	// If there are no more results, nextPageToken is empty and err is nil.
1233	InternalFetch func(pageSize int, pageToken string) (results []*artifactregistrypb.Package, nextPageToken string, err error)
1234}
1235
1236// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1237func (it *PackageIterator) PageInfo() *iterator.PageInfo {
1238	return it.pageInfo
1239}
1240
1241// Next returns the next result. Its second return value is iterator.Done if there are no more
1242// results. Once Next returns Done, all subsequent calls will return Done.
1243func (it *PackageIterator) Next() (*artifactregistrypb.Package, error) {
1244	var item *artifactregistrypb.Package
1245	if err := it.nextFunc(); err != nil {
1246		return item, err
1247	}
1248	item = it.items[0]
1249	it.items = it.items[1:]
1250	return item, nil
1251}
1252
1253func (it *PackageIterator) bufLen() int {
1254	return len(it.items)
1255}
1256
1257func (it *PackageIterator) takeBuf() interface{} {
1258	b := it.items
1259	it.items = nil
1260	return b
1261}
1262
1263// RepositoryIterator manages a stream of *artifactregistrypb.Repository.
1264type RepositoryIterator struct {
1265	items    []*artifactregistrypb.Repository
1266	pageInfo *iterator.PageInfo
1267	nextFunc func() error
1268
1269	// Response is the raw response for the current page.
1270	// It must be cast to the RPC response type.
1271	// Calling Next() or InternalFetch() updates this value.
1272	Response interface{}
1273
1274	// InternalFetch is for use by the Google Cloud Libraries only.
1275	// It is not part of the stable interface of this package.
1276	//
1277	// InternalFetch returns results from a single call to the underlying RPC.
1278	// The number of results is no greater than pageSize.
1279	// If there are no more results, nextPageToken is empty and err is nil.
1280	InternalFetch func(pageSize int, pageToken string) (results []*artifactregistrypb.Repository, nextPageToken string, err error)
1281}
1282
1283// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1284func (it *RepositoryIterator) PageInfo() *iterator.PageInfo {
1285	return it.pageInfo
1286}
1287
1288// Next returns the next result. Its second return value is iterator.Done if there are no more
1289// results. Once Next returns Done, all subsequent calls will return Done.
1290func (it *RepositoryIterator) Next() (*artifactregistrypb.Repository, error) {
1291	var item *artifactregistrypb.Repository
1292	if err := it.nextFunc(); err != nil {
1293		return item, err
1294	}
1295	item = it.items[0]
1296	it.items = it.items[1:]
1297	return item, nil
1298}
1299
1300func (it *RepositoryIterator) bufLen() int {
1301	return len(it.items)
1302}
1303
1304func (it *RepositoryIterator) takeBuf() interface{} {
1305	b := it.items
1306	it.items = nil
1307	return b
1308}
1309
1310// TagIterator manages a stream of *artifactregistrypb.Tag.
1311type TagIterator struct {
1312	items    []*artifactregistrypb.Tag
1313	pageInfo *iterator.PageInfo
1314	nextFunc func() error
1315
1316	// Response is the raw response for the current page.
1317	// It must be cast to the RPC response type.
1318	// Calling Next() or InternalFetch() updates this value.
1319	Response interface{}
1320
1321	// InternalFetch is for use by the Google Cloud Libraries only.
1322	// It is not part of the stable interface of this package.
1323	//
1324	// InternalFetch returns results from a single call to the underlying RPC.
1325	// The number of results is no greater than pageSize.
1326	// If there are no more results, nextPageToken is empty and err is nil.
1327	InternalFetch func(pageSize int, pageToken string) (results []*artifactregistrypb.Tag, nextPageToken string, err error)
1328}
1329
1330// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1331func (it *TagIterator) PageInfo() *iterator.PageInfo {
1332	return it.pageInfo
1333}
1334
1335// Next returns the next result. Its second return value is iterator.Done if there are no more
1336// results. Once Next returns Done, all subsequent calls will return Done.
1337func (it *TagIterator) Next() (*artifactregistrypb.Tag, error) {
1338	var item *artifactregistrypb.Tag
1339	if err := it.nextFunc(); err != nil {
1340		return item, err
1341	}
1342	item = it.items[0]
1343	it.items = it.items[1:]
1344	return item, nil
1345}
1346
1347func (it *TagIterator) bufLen() int {
1348	return len(it.items)
1349}
1350
1351func (it *TagIterator) takeBuf() interface{} {
1352	b := it.items
1353	it.items = nil
1354	return b
1355}
1356
1357// VersionIterator manages a stream of *artifactregistrypb.Version.
1358type VersionIterator struct {
1359	items    []*artifactregistrypb.Version
1360	pageInfo *iterator.PageInfo
1361	nextFunc func() error
1362
1363	// Response is the raw response for the current page.
1364	// It must be cast to the RPC response type.
1365	// Calling Next() or InternalFetch() updates this value.
1366	Response interface{}
1367
1368	// InternalFetch is for use by the Google Cloud Libraries only.
1369	// It is not part of the stable interface of this package.
1370	//
1371	// InternalFetch returns results from a single call to the underlying RPC.
1372	// The number of results is no greater than pageSize.
1373	// If there are no more results, nextPageToken is empty and err is nil.
1374	InternalFetch func(pageSize int, pageToken string) (results []*artifactregistrypb.Version, nextPageToken string, err error)
1375}
1376
1377// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1378func (it *VersionIterator) PageInfo() *iterator.PageInfo {
1379	return it.pageInfo
1380}
1381
1382// Next returns the next result. Its second return value is iterator.Done if there are no more
1383// results. Once Next returns Done, all subsequent calls will return Done.
1384func (it *VersionIterator) Next() (*artifactregistrypb.Version, error) {
1385	var item *artifactregistrypb.Version
1386	if err := it.nextFunc(); err != nil {
1387		return item, err
1388	}
1389	item = it.items[0]
1390	it.items = it.items[1:]
1391	return item, nil
1392}
1393
1394func (it *VersionIterator) bufLen() int {
1395	return len(it.items)
1396}
1397
1398func (it *VersionIterator) takeBuf() interface{} {
1399	b := it.items
1400	it.items = nil
1401	return b
1402}
1403