1// Copyright 2020 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 datacatalog
18
19import (
20	"context"
21	"fmt"
22	"math"
23	"net/url"
24	"time"
25
26	"github.com/golang/protobuf/proto"
27	gax "github.com/googleapis/gax-go/v2"
28	"google.golang.org/api/iterator"
29	"google.golang.org/api/option"
30	gtransport "google.golang.org/api/transport/grpc"
31	datacatalogpb "google.golang.org/genproto/googleapis/cloud/datacatalog/v1"
32	iampb "google.golang.org/genproto/googleapis/iam/v1"
33	"google.golang.org/grpc"
34	"google.golang.org/grpc/codes"
35	"google.golang.org/grpc/metadata"
36)
37
38// CallOptions contains the retry settings for each method of Client.
39type CallOptions struct {
40	SearchCatalog          []gax.CallOption
41	CreateEntryGroup       []gax.CallOption
42	GetEntryGroup          []gax.CallOption
43	UpdateEntryGroup       []gax.CallOption
44	DeleteEntryGroup       []gax.CallOption
45	ListEntryGroups        []gax.CallOption
46	CreateEntry            []gax.CallOption
47	UpdateEntry            []gax.CallOption
48	DeleteEntry            []gax.CallOption
49	GetEntry               []gax.CallOption
50	LookupEntry            []gax.CallOption
51	ListEntries            []gax.CallOption
52	CreateTagTemplate      []gax.CallOption
53	GetTagTemplate         []gax.CallOption
54	UpdateTagTemplate      []gax.CallOption
55	DeleteTagTemplate      []gax.CallOption
56	CreateTagTemplateField []gax.CallOption
57	UpdateTagTemplateField []gax.CallOption
58	RenameTagTemplateField []gax.CallOption
59	DeleteTagTemplateField []gax.CallOption
60	CreateTag              []gax.CallOption
61	UpdateTag              []gax.CallOption
62	DeleteTag              []gax.CallOption
63	ListTags               []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		option.WithEndpoint("datacatalog.googleapis.com:443"),
72		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
73		option.WithScopes(DefaultAuthScopes()...),
74		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
75			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
76	}
77}
78
79func defaultCallOptions() *CallOptions {
80	return &CallOptions{
81		SearchCatalog: []gax.CallOption{
82			gax.WithRetry(func() gax.Retryer {
83				return gax.OnCodes([]codes.Code{
84					codes.Unavailable,
85				}, gax.Backoff{
86					Initial:    100 * time.Millisecond,
87					Max:        60000 * time.Millisecond,
88					Multiplier: 1.30,
89				})
90			}),
91		},
92		CreateEntryGroup: []gax.CallOption{},
93		GetEntryGroup: []gax.CallOption{
94			gax.WithRetry(func() gax.Retryer {
95				return gax.OnCodes([]codes.Code{
96					codes.Unavailable,
97				}, gax.Backoff{
98					Initial:    100 * time.Millisecond,
99					Max:        60000 * time.Millisecond,
100					Multiplier: 1.30,
101				})
102			}),
103		},
104		UpdateEntryGroup: []gax.CallOption{},
105		DeleteEntryGroup: []gax.CallOption{},
106		ListEntryGroups: []gax.CallOption{
107			gax.WithRetry(func() gax.Retryer {
108				return gax.OnCodes([]codes.Code{
109					codes.Unavailable,
110				}, gax.Backoff{
111					Initial:    100 * time.Millisecond,
112					Max:        60000 * time.Millisecond,
113					Multiplier: 1.30,
114				})
115			}),
116		},
117		CreateEntry: []gax.CallOption{},
118		UpdateEntry: []gax.CallOption{},
119		DeleteEntry: []gax.CallOption{},
120		GetEntry: []gax.CallOption{
121			gax.WithRetry(func() gax.Retryer {
122				return gax.OnCodes([]codes.Code{
123					codes.Unavailable,
124				}, gax.Backoff{
125					Initial:    100 * time.Millisecond,
126					Max:        60000 * time.Millisecond,
127					Multiplier: 1.30,
128				})
129			}),
130		},
131		LookupEntry: []gax.CallOption{
132			gax.WithRetry(func() gax.Retryer {
133				return gax.OnCodes([]codes.Code{
134					codes.Unavailable,
135				}, gax.Backoff{
136					Initial:    100 * time.Millisecond,
137					Max:        60000 * time.Millisecond,
138					Multiplier: 1.30,
139				})
140			}),
141		},
142		ListEntries: []gax.CallOption{
143			gax.WithRetry(func() gax.Retryer {
144				return gax.OnCodes([]codes.Code{
145					codes.Unavailable,
146				}, gax.Backoff{
147					Initial:    100 * time.Millisecond,
148					Max:        60000 * time.Millisecond,
149					Multiplier: 1.30,
150				})
151			}),
152		},
153		CreateTagTemplate:      []gax.CallOption{},
154		GetTagTemplate:         []gax.CallOption{},
155		UpdateTagTemplate:      []gax.CallOption{},
156		DeleteTagTemplate:      []gax.CallOption{},
157		CreateTagTemplateField: []gax.CallOption{},
158		UpdateTagTemplateField: []gax.CallOption{},
159		RenameTagTemplateField: []gax.CallOption{},
160		DeleteTagTemplateField: []gax.CallOption{},
161		CreateTag:              []gax.CallOption{},
162		UpdateTag:              []gax.CallOption{},
163		DeleteTag:              []gax.CallOption{},
164		ListTags: []gax.CallOption{
165			gax.WithRetry(func() gax.Retryer {
166				return gax.OnCodes([]codes.Code{
167					codes.Unavailable,
168				}, gax.Backoff{
169					Initial:    100 * time.Millisecond,
170					Max:        60000 * time.Millisecond,
171					Multiplier: 1.30,
172				})
173			}),
174		},
175		SetIamPolicy: []gax.CallOption{},
176		GetIamPolicy: []gax.CallOption{
177			gax.WithRetry(func() gax.Retryer {
178				return gax.OnCodes([]codes.Code{
179					codes.Unavailable,
180				}, gax.Backoff{
181					Initial:    100 * time.Millisecond,
182					Max:        60000 * time.Millisecond,
183					Multiplier: 1.30,
184				})
185			}),
186		},
187		TestIamPermissions: []gax.CallOption{},
188	}
189}
190
191// Client is a client for interacting with Google Cloud Data Catalog API.
192//
193// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
194type Client struct {
195	// Connection pool of gRPC connections to the service.
196	connPool gtransport.ConnPool
197
198	// The gRPC API client.
199	client datacatalogpb.DataCatalogClient
200
201	// The call options for this service.
202	CallOptions *CallOptions
203
204	// The x-goog-* metadata to be sent with each request.
205	xGoogMetadata metadata.MD
206}
207
208// NewClient creates a new data catalog client.
209//
210// Data Catalog API service allows clients to discover, understand, and manage
211// their data.
212func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
213	connPool, err := gtransport.DialPool(ctx, append(defaultClientOptions(), opts...)...)
214	if err != nil {
215		return nil, err
216	}
217	c := &Client{
218		connPool:    connPool,
219		CallOptions: defaultCallOptions(),
220
221		client: datacatalogpb.NewDataCatalogClient(connPool),
222	}
223	c.setGoogleClientInfo()
224
225	return c, nil
226}
227
228// Connection returns a connection to the API service.
229//
230// Deprecated.
231func (c *Client) Connection() *grpc.ClientConn {
232	return c.connPool.Conn()
233}
234
235// Close closes the connection to the API service. The user should invoke this when
236// the client is no longer required.
237func (c *Client) Close() error {
238	return c.connPool.Close()
239}
240
241// setGoogleClientInfo sets the name and version of the application in
242// the `x-goog-api-client` header passed on each request. Intended for
243// use by Google-written clients.
244func (c *Client) setGoogleClientInfo(keyval ...string) {
245	kv := append([]string{"gl-go", versionGo()}, keyval...)
246	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
247	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
248}
249
250// SearchCatalog searches Data Catalog for multiple resources like entries, tags that
251// match a query.
252//
253// This is a custom method
254// (https://cloud.google.com/apis/design/custom_methods (at https://cloud.google.com/apis/design/custom_methods)) and does not return
255// the complete resource, only the resource identifier and high level
256// fields. Clients can subsequentally call Get methods.
257//
258// Note that Data Catalog search queries do not guarantee full recall. Query
259// results that match your query may not be returned, even in subsequent
260// result pages. Also note that results returned (and not returned) can vary
261// across repeated search queries.
262//
263// See Data Catalog Search
264// Syntax (at /data-catalog/docs/how-to/search-reference) for more information.
265func (c *Client) SearchCatalog(ctx context.Context, req *datacatalogpb.SearchCatalogRequest, opts ...gax.CallOption) *SearchCatalogResultIterator {
266	ctx = insertMetadata(ctx, c.xGoogMetadata)
267	opts = append(c.CallOptions.SearchCatalog[0:len(c.CallOptions.SearchCatalog):len(c.CallOptions.SearchCatalog)], opts...)
268	it := &SearchCatalogResultIterator{}
269	req = proto.Clone(req).(*datacatalogpb.SearchCatalogRequest)
270	it.InternalFetch = func(pageSize int, pageToken string) ([]*datacatalogpb.SearchCatalogResult, string, error) {
271		var resp *datacatalogpb.SearchCatalogResponse
272		req.PageToken = pageToken
273		if pageSize > math.MaxInt32 {
274			req.PageSize = math.MaxInt32
275		} else {
276			req.PageSize = int32(pageSize)
277		}
278		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
279			var err error
280			resp, err = c.client.SearchCatalog(ctx, req, settings.GRPC...)
281			return err
282		}, opts...)
283		if err != nil {
284			return nil, "", err
285		}
286
287		it.Response = resp
288		return resp.Results, resp.NextPageToken, nil
289	}
290	fetch := func(pageSize int, pageToken string) (string, error) {
291		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
292		if err != nil {
293			return "", err
294		}
295		it.items = append(it.items, items...)
296		return nextPageToken, nil
297	}
298	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
299	it.pageInfo.MaxSize = int(req.PageSize)
300	it.pageInfo.Token = req.PageToken
301	return it
302}
303
304// CreateEntryGroup creates an EntryGroup.
305//
306// An entry group contains logically related entries together with Cloud
307// Identity and Access Management policies that specify the users who can
308// create, edit, and view entries within the entry group.
309//
310// Data Catalog automatically creates an entry group for BigQuery entries
311// (“@bigquery”) and Pub/Sub topics ("@pubsub"). Users create their own entry
312// group to contain Cloud Storage fileset entries or custom type entries,
313// and the IAM policies associated with those entries. Entry groups, like
314// entries, can be searched.
315//
316// A maximum of 10,000 entry groups may be created per organization across all
317// locations.
318//
319// Users should enable the Data Catalog API in the project identified by
320// the parent parameter (see [Data Catalog Resource Project]
321// (/data-catalog/docs/concepts/resource-project) for more information).
322func (c *Client) CreateEntryGroup(ctx context.Context, req *datacatalogpb.CreateEntryGroupRequest, opts ...gax.CallOption) (*datacatalogpb.EntryGroup, error) {
323	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
324	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
325	opts = append(c.CallOptions.CreateEntryGroup[0:len(c.CallOptions.CreateEntryGroup):len(c.CallOptions.CreateEntryGroup)], opts...)
326	var resp *datacatalogpb.EntryGroup
327	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
328		var err error
329		resp, err = c.client.CreateEntryGroup(ctx, req, settings.GRPC...)
330		return err
331	}, opts...)
332	if err != nil {
333		return nil, err
334	}
335	return resp, nil
336}
337
338// GetEntryGroup gets an EntryGroup.
339func (c *Client) GetEntryGroup(ctx context.Context, req *datacatalogpb.GetEntryGroupRequest, opts ...gax.CallOption) (*datacatalogpb.EntryGroup, error) {
340	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
341	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
342	opts = append(c.CallOptions.GetEntryGroup[0:len(c.CallOptions.GetEntryGroup):len(c.CallOptions.GetEntryGroup)], opts...)
343	var resp *datacatalogpb.EntryGroup
344	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
345		var err error
346		resp, err = c.client.GetEntryGroup(ctx, req, settings.GRPC...)
347		return err
348	}, opts...)
349	if err != nil {
350		return nil, err
351	}
352	return resp, nil
353}
354
355// UpdateEntryGroup updates an EntryGroup. The user should enable the Data Catalog API in the
356// project identified by the entry_group.name parameter (see [Data Catalog
357// Resource Project] (/data-catalog/docs/concepts/resource-project) for more
358// information).
359func (c *Client) UpdateEntryGroup(ctx context.Context, req *datacatalogpb.UpdateEntryGroupRequest, opts ...gax.CallOption) (*datacatalogpb.EntryGroup, error) {
360	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "entry_group.name", url.QueryEscape(req.GetEntryGroup().GetName())))
361	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
362	opts = append(c.CallOptions.UpdateEntryGroup[0:len(c.CallOptions.UpdateEntryGroup):len(c.CallOptions.UpdateEntryGroup)], opts...)
363	var resp *datacatalogpb.EntryGroup
364	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
365		var err error
366		resp, err = c.client.UpdateEntryGroup(ctx, req, settings.GRPC...)
367		return err
368	}, opts...)
369	if err != nil {
370		return nil, err
371	}
372	return resp, nil
373}
374
375// DeleteEntryGroup deletes an EntryGroup. Only entry groups that do not contain entries can be
376// deleted. Users should enable the Data Catalog API in the project
377// identified by the name parameter (see [Data Catalog Resource Project]
378// (/data-catalog/docs/concepts/resource-project) for more information).
379func (c *Client) DeleteEntryGroup(ctx context.Context, req *datacatalogpb.DeleteEntryGroupRequest, opts ...gax.CallOption) error {
380	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
381	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
382	opts = append(c.CallOptions.DeleteEntryGroup[0:len(c.CallOptions.DeleteEntryGroup):len(c.CallOptions.DeleteEntryGroup)], opts...)
383	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
384		var err error
385		_, err = c.client.DeleteEntryGroup(ctx, req, settings.GRPC...)
386		return err
387	}, opts...)
388	return err
389}
390
391// ListEntryGroups lists entry groups.
392func (c *Client) ListEntryGroups(ctx context.Context, req *datacatalogpb.ListEntryGroupsRequest, opts ...gax.CallOption) *EntryGroupIterator {
393	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
394	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
395	opts = append(c.CallOptions.ListEntryGroups[0:len(c.CallOptions.ListEntryGroups):len(c.CallOptions.ListEntryGroups)], opts...)
396	it := &EntryGroupIterator{}
397	req = proto.Clone(req).(*datacatalogpb.ListEntryGroupsRequest)
398	it.InternalFetch = func(pageSize int, pageToken string) ([]*datacatalogpb.EntryGroup, string, error) {
399		var resp *datacatalogpb.ListEntryGroupsResponse
400		req.PageToken = pageToken
401		if pageSize > math.MaxInt32 {
402			req.PageSize = math.MaxInt32
403		} else {
404			req.PageSize = int32(pageSize)
405		}
406		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
407			var err error
408			resp, err = c.client.ListEntryGroups(ctx, req, settings.GRPC...)
409			return err
410		}, opts...)
411		if err != nil {
412			return nil, "", err
413		}
414
415		it.Response = resp
416		return resp.EntryGroups, resp.NextPageToken, nil
417	}
418	fetch := func(pageSize int, pageToken string) (string, error) {
419		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
420		if err != nil {
421			return "", err
422		}
423		it.items = append(it.items, items...)
424		return nextPageToken, nil
425	}
426	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
427	it.pageInfo.MaxSize = int(req.PageSize)
428	it.pageInfo.Token = req.PageToken
429	return it
430}
431
432// CreateEntry creates an entry. Only entries of ‘FILESET’ type or user-specified type can
433// be created.
434//
435// Users should enable the Data Catalog API in the project identified by
436// the parent parameter (see [Data Catalog Resource Project]
437// (/data-catalog/docs/concepts/resource-project) for more information).
438//
439// A maximum of 100,000 entries may be created per entry group.
440func (c *Client) CreateEntry(ctx context.Context, req *datacatalogpb.CreateEntryRequest, opts ...gax.CallOption) (*datacatalogpb.Entry, error) {
441	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
442	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
443	opts = append(c.CallOptions.CreateEntry[0:len(c.CallOptions.CreateEntry):len(c.CallOptions.CreateEntry)], opts...)
444	var resp *datacatalogpb.Entry
445	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
446		var err error
447		resp, err = c.client.CreateEntry(ctx, req, settings.GRPC...)
448		return err
449	}, opts...)
450	if err != nil {
451		return nil, err
452	}
453	return resp, nil
454}
455
456// UpdateEntry updates an existing entry.
457// Users should enable the Data Catalog API in the project identified by
458// the entry.name parameter (see [Data Catalog Resource Project]
459// (/data-catalog/docs/concepts/resource-project) for more information).
460func (c *Client) UpdateEntry(ctx context.Context, req *datacatalogpb.UpdateEntryRequest, opts ...gax.CallOption) (*datacatalogpb.Entry, error) {
461	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "entry.name", url.QueryEscape(req.GetEntry().GetName())))
462	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
463	opts = append(c.CallOptions.UpdateEntry[0:len(c.CallOptions.UpdateEntry):len(c.CallOptions.UpdateEntry)], opts...)
464	var resp *datacatalogpb.Entry
465	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
466		var err error
467		resp, err = c.client.UpdateEntry(ctx, req, settings.GRPC...)
468		return err
469	}, opts...)
470	if err != nil {
471		return nil, err
472	}
473	return resp, nil
474}
475
476// DeleteEntry deletes an existing entry. Only entries created through
477// CreateEntry
478// method can be deleted.
479// Users should enable the Data Catalog API in the project identified by
480// the name parameter (see [Data Catalog Resource Project]
481// (/data-catalog/docs/concepts/resource-project) for more information).
482func (c *Client) DeleteEntry(ctx context.Context, req *datacatalogpb.DeleteEntryRequest, opts ...gax.CallOption) error {
483	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
484	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
485	opts = append(c.CallOptions.DeleteEntry[0:len(c.CallOptions.DeleteEntry):len(c.CallOptions.DeleteEntry)], opts...)
486	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
487		var err error
488		_, err = c.client.DeleteEntry(ctx, req, settings.GRPC...)
489		return err
490	}, opts...)
491	return err
492}
493
494// GetEntry gets an entry.
495func (c *Client) GetEntry(ctx context.Context, req *datacatalogpb.GetEntryRequest, opts ...gax.CallOption) (*datacatalogpb.Entry, error) {
496	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
497	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
498	opts = append(c.CallOptions.GetEntry[0:len(c.CallOptions.GetEntry):len(c.CallOptions.GetEntry)], opts...)
499	var resp *datacatalogpb.Entry
500	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
501		var err error
502		resp, err = c.client.GetEntry(ctx, req, settings.GRPC...)
503		return err
504	}, opts...)
505	if err != nil {
506		return nil, err
507	}
508	return resp, nil
509}
510
511// LookupEntry get an entry by target resource name. This method allows clients to use
512// the resource name from the source Google Cloud Platform service to get the
513// Data Catalog Entry.
514func (c *Client) LookupEntry(ctx context.Context, req *datacatalogpb.LookupEntryRequest, opts ...gax.CallOption) (*datacatalogpb.Entry, error) {
515	ctx = insertMetadata(ctx, c.xGoogMetadata)
516	opts = append(c.CallOptions.LookupEntry[0:len(c.CallOptions.LookupEntry):len(c.CallOptions.LookupEntry)], opts...)
517	var resp *datacatalogpb.Entry
518	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
519		var err error
520		resp, err = c.client.LookupEntry(ctx, req, settings.GRPC...)
521		return err
522	}, opts...)
523	if err != nil {
524		return nil, err
525	}
526	return resp, nil
527}
528
529// ListEntries lists entries.
530func (c *Client) ListEntries(ctx context.Context, req *datacatalogpb.ListEntriesRequest, opts ...gax.CallOption) *EntryIterator {
531	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
532	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
533	opts = append(c.CallOptions.ListEntries[0:len(c.CallOptions.ListEntries):len(c.CallOptions.ListEntries)], opts...)
534	it := &EntryIterator{}
535	req = proto.Clone(req).(*datacatalogpb.ListEntriesRequest)
536	it.InternalFetch = func(pageSize int, pageToken string) ([]*datacatalogpb.Entry, string, error) {
537		var resp *datacatalogpb.ListEntriesResponse
538		req.PageToken = pageToken
539		if pageSize > math.MaxInt32 {
540			req.PageSize = math.MaxInt32
541		} else {
542			req.PageSize = int32(pageSize)
543		}
544		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
545			var err error
546			resp, err = c.client.ListEntries(ctx, req, settings.GRPC...)
547			return err
548		}, opts...)
549		if err != nil {
550			return nil, "", err
551		}
552
553		it.Response = resp
554		return resp.Entries, resp.NextPageToken, nil
555	}
556	fetch := func(pageSize int, pageToken string) (string, error) {
557		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
558		if err != nil {
559			return "", err
560		}
561		it.items = append(it.items, items...)
562		return nextPageToken, nil
563	}
564	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
565	it.pageInfo.MaxSize = int(req.PageSize)
566	it.pageInfo.Token = req.PageToken
567	return it
568}
569
570// CreateTagTemplate creates a tag template. The user should enable the Data Catalog API in
571// the project identified by the parent parameter (see Data Catalog
572// Resource Project (at /data-catalog/docs/concepts/resource-project) for more
573// information).
574func (c *Client) CreateTagTemplate(ctx context.Context, req *datacatalogpb.CreateTagTemplateRequest, opts ...gax.CallOption) (*datacatalogpb.TagTemplate, error) {
575	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
576	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
577	opts = append(c.CallOptions.CreateTagTemplate[0:len(c.CallOptions.CreateTagTemplate):len(c.CallOptions.CreateTagTemplate)], opts...)
578	var resp *datacatalogpb.TagTemplate
579	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
580		var err error
581		resp, err = c.client.CreateTagTemplate(ctx, req, settings.GRPC...)
582		return err
583	}, opts...)
584	if err != nil {
585		return nil, err
586	}
587	return resp, nil
588}
589
590// GetTagTemplate gets a tag template.
591func (c *Client) GetTagTemplate(ctx context.Context, req *datacatalogpb.GetTagTemplateRequest, opts ...gax.CallOption) (*datacatalogpb.TagTemplate, error) {
592	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
593	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
594	opts = append(c.CallOptions.GetTagTemplate[0:len(c.CallOptions.GetTagTemplate):len(c.CallOptions.GetTagTemplate)], opts...)
595	var resp *datacatalogpb.TagTemplate
596	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
597		var err error
598		resp, err = c.client.GetTagTemplate(ctx, req, settings.GRPC...)
599		return err
600	}, opts...)
601	if err != nil {
602		return nil, err
603	}
604	return resp, nil
605}
606
607// UpdateTagTemplate updates a tag template. This method cannot be used to update the fields of
608// a template. The tag template fields are represented as separate resources
609// and should be updated using their own create/update/delete methods.
610// Users should enable the Data Catalog API in the project identified by
611// the tag_template.name parameter (see [Data Catalog Resource Project]
612// (/data-catalog/docs/concepts/resource-project) for more information).
613func (c *Client) UpdateTagTemplate(ctx context.Context, req *datacatalogpb.UpdateTagTemplateRequest, opts ...gax.CallOption) (*datacatalogpb.TagTemplate, error) {
614	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "tag_template.name", url.QueryEscape(req.GetTagTemplate().GetName())))
615	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
616	opts = append(c.CallOptions.UpdateTagTemplate[0:len(c.CallOptions.UpdateTagTemplate):len(c.CallOptions.UpdateTagTemplate)], opts...)
617	var resp *datacatalogpb.TagTemplate
618	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
619		var err error
620		resp, err = c.client.UpdateTagTemplate(ctx, req, settings.GRPC...)
621		return err
622	}, opts...)
623	if err != nil {
624		return nil, err
625	}
626	return resp, nil
627}
628
629// DeleteTagTemplate deletes a tag template and all tags using the template.
630// Users should enable the Data Catalog API in the project identified by
631// the name parameter (see [Data Catalog Resource Project]
632// (/data-catalog/docs/concepts/resource-project) for more information).
633func (c *Client) DeleteTagTemplate(ctx context.Context, req *datacatalogpb.DeleteTagTemplateRequest, opts ...gax.CallOption) error {
634	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
635	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
636	opts = append(c.CallOptions.DeleteTagTemplate[0:len(c.CallOptions.DeleteTagTemplate):len(c.CallOptions.DeleteTagTemplate)], opts...)
637	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
638		var err error
639		_, err = c.client.DeleteTagTemplate(ctx, req, settings.GRPC...)
640		return err
641	}, opts...)
642	return err
643}
644
645// CreateTagTemplateField creates a field in a tag template. The user should enable the Data Catalog
646// API in the project identified by the parent parameter (see
647// Data Catalog Resource
648// Project (at /data-catalog/docs/concepts/resource-project) for more
649// information).
650func (c *Client) CreateTagTemplateField(ctx context.Context, req *datacatalogpb.CreateTagTemplateFieldRequest, opts ...gax.CallOption) (*datacatalogpb.TagTemplateField, error) {
651	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
652	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
653	opts = append(c.CallOptions.CreateTagTemplateField[0:len(c.CallOptions.CreateTagTemplateField):len(c.CallOptions.CreateTagTemplateField)], opts...)
654	var resp *datacatalogpb.TagTemplateField
655	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
656		var err error
657		resp, err = c.client.CreateTagTemplateField(ctx, req, settings.GRPC...)
658		return err
659	}, opts...)
660	if err != nil {
661		return nil, err
662	}
663	return resp, nil
664}
665
666// UpdateTagTemplateField updates a field in a tag template. This method cannot be used to update the
667// field type. Users should enable the Data Catalog API in the project
668// identified by the name parameter (see [Data Catalog Resource Project]
669// (/data-catalog/docs/concepts/resource-project) for more information).
670func (c *Client) UpdateTagTemplateField(ctx context.Context, req *datacatalogpb.UpdateTagTemplateFieldRequest, opts ...gax.CallOption) (*datacatalogpb.TagTemplateField, error) {
671	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
672	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
673	opts = append(c.CallOptions.UpdateTagTemplateField[0:len(c.CallOptions.UpdateTagTemplateField):len(c.CallOptions.UpdateTagTemplateField)], opts...)
674	var resp *datacatalogpb.TagTemplateField
675	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
676		var err error
677		resp, err = c.client.UpdateTagTemplateField(ctx, req, settings.GRPC...)
678		return err
679	}, opts...)
680	if err != nil {
681		return nil, err
682	}
683	return resp, nil
684}
685
686// RenameTagTemplateField renames a field in a tag template. The user should enable the Data Catalog
687// API in the project identified by the name parameter (see Data Catalog
688// Resource Project (at /data-catalog/docs/concepts/resource-project) for more
689// information).
690func (c *Client) RenameTagTemplateField(ctx context.Context, req *datacatalogpb.RenameTagTemplateFieldRequest, opts ...gax.CallOption) (*datacatalogpb.TagTemplateField, error) {
691	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
692	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
693	opts = append(c.CallOptions.RenameTagTemplateField[0:len(c.CallOptions.RenameTagTemplateField):len(c.CallOptions.RenameTagTemplateField)], opts...)
694	var resp *datacatalogpb.TagTemplateField
695	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
696		var err error
697		resp, err = c.client.RenameTagTemplateField(ctx, req, settings.GRPC...)
698		return err
699	}, opts...)
700	if err != nil {
701		return nil, err
702	}
703	return resp, nil
704}
705
706// DeleteTagTemplateField deletes a field in a tag template and all uses of that field.
707// Users should enable the Data Catalog API in the project identified by
708// the name parameter (see [Data Catalog Resource Project]
709// (/data-catalog/docs/concepts/resource-project) for more information).
710func (c *Client) DeleteTagTemplateField(ctx context.Context, req *datacatalogpb.DeleteTagTemplateFieldRequest, opts ...gax.CallOption) error {
711	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
712	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
713	opts = append(c.CallOptions.DeleteTagTemplateField[0:len(c.CallOptions.DeleteTagTemplateField):len(c.CallOptions.DeleteTagTemplateField)], opts...)
714	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
715		var err error
716		_, err = c.client.DeleteTagTemplateField(ctx, req, settings.GRPC...)
717		return err
718	}, opts...)
719	return err
720}
721
722// CreateTag creates a tag on an Entry.
723// Note: The project identified by the parent parameter for the
724// tag (at /data-catalog/docs/reference/rest/v1/projects.locations.entryGroups.entries.tags/create#path-parameters)
725// and the
726// tag
727// template (at /data-catalog/docs/reference/rest/v1/projects.locations.tagTemplates/create#path-parameters)
728// used to create the tag must be from the same organization.
729func (c *Client) CreateTag(ctx context.Context, req *datacatalogpb.CreateTagRequest, opts ...gax.CallOption) (*datacatalogpb.Tag, error) {
730	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
731	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
732	opts = append(c.CallOptions.CreateTag[0:len(c.CallOptions.CreateTag):len(c.CallOptions.CreateTag)], opts...)
733	var resp *datacatalogpb.Tag
734	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
735		var err error
736		resp, err = c.client.CreateTag(ctx, req, settings.GRPC...)
737		return err
738	}, opts...)
739	if err != nil {
740		return nil, err
741	}
742	return resp, nil
743}
744
745// UpdateTag updates an existing tag.
746func (c *Client) UpdateTag(ctx context.Context, req *datacatalogpb.UpdateTagRequest, opts ...gax.CallOption) (*datacatalogpb.Tag, error) {
747	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "tag.name", url.QueryEscape(req.GetTag().GetName())))
748	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
749	opts = append(c.CallOptions.UpdateTag[0:len(c.CallOptions.UpdateTag):len(c.CallOptions.UpdateTag)], opts...)
750	var resp *datacatalogpb.Tag
751	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
752		var err error
753		resp, err = c.client.UpdateTag(ctx, req, settings.GRPC...)
754		return err
755	}, opts...)
756	if err != nil {
757		return nil, err
758	}
759	return resp, nil
760}
761
762// DeleteTag deletes a tag.
763func (c *Client) DeleteTag(ctx context.Context, req *datacatalogpb.DeleteTagRequest, opts ...gax.CallOption) error {
764	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
765	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
766	opts = append(c.CallOptions.DeleteTag[0:len(c.CallOptions.DeleteTag):len(c.CallOptions.DeleteTag)], opts...)
767	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
768		var err error
769		_, err = c.client.DeleteTag(ctx, req, settings.GRPC...)
770		return err
771	}, opts...)
772	return err
773}
774
775// ListTags lists the tags on an Entry.
776func (c *Client) ListTags(ctx context.Context, req *datacatalogpb.ListTagsRequest, opts ...gax.CallOption) *TagIterator {
777	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
778	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
779	opts = append(c.CallOptions.ListTags[0:len(c.CallOptions.ListTags):len(c.CallOptions.ListTags)], opts...)
780	it := &TagIterator{}
781	req = proto.Clone(req).(*datacatalogpb.ListTagsRequest)
782	it.InternalFetch = func(pageSize int, pageToken string) ([]*datacatalogpb.Tag, string, error) {
783		var resp *datacatalogpb.ListTagsResponse
784		req.PageToken = pageToken
785		if pageSize > math.MaxInt32 {
786			req.PageSize = math.MaxInt32
787		} else {
788			req.PageSize = int32(pageSize)
789		}
790		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
791			var err error
792			resp, err = c.client.ListTags(ctx, req, settings.GRPC...)
793			return err
794		}, opts...)
795		if err != nil {
796			return nil, "", err
797		}
798
799		it.Response = resp
800		return resp.Tags, resp.NextPageToken, nil
801	}
802	fetch := func(pageSize int, pageToken string) (string, error) {
803		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
804		if err != nil {
805			return "", err
806		}
807		it.items = append(it.items, items...)
808		return nextPageToken, nil
809	}
810	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
811	it.pageInfo.MaxSize = int(req.PageSize)
812	it.pageInfo.Token = req.PageToken
813	return it
814}
815
816// SetIamPolicy sets the access control policy for a resource. Replaces any existing
817// policy.
818// Supported resources are:
819//
820//   Tag templates.
821//
822//   Entries.
823//
824//   Entry groups.
825//   Note, this method cannot be used to manage policies for BigQuery, Pub/Sub
826//   and any external Google Cloud Platform resources synced to Data Catalog.
827//
828// Callers must have following Google IAM permission
829//
830//   datacatalog.tagTemplates.setIamPolicy to set policies on tag
831//   templates.
832//
833//   datacatalog.entries.setIamPolicy to set policies on entries.
834//
835//   datacatalog.entryGroups.setIamPolicy to set policies on entry groups.
836func (c *Client) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
837	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource())))
838	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
839	opts = append(c.CallOptions.SetIamPolicy[0:len(c.CallOptions.SetIamPolicy):len(c.CallOptions.SetIamPolicy)], opts...)
840	var resp *iampb.Policy
841	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
842		var err error
843		resp, err = c.client.SetIamPolicy(ctx, req, settings.GRPC...)
844		return err
845	}, opts...)
846	if err != nil {
847		return nil, err
848	}
849	return resp, nil
850}
851
852// GetIamPolicy gets the access control policy for a resource. A NOT_FOUND error
853// is returned if the resource does not exist. An empty policy is returned
854// if the resource exists but does not have a policy set on it.
855//
856// Supported resources are:
857//
858//   Tag templates.
859//
860//   Entries.
861//
862//   Entry groups.
863//   Note, this method cannot be used to manage policies for BigQuery, Pub/Sub
864//   and any external Google Cloud Platform resources synced to Data Catalog.
865//
866// Callers must have following Google IAM permission
867//
868//   datacatalog.tagTemplates.getIamPolicy to get policies on tag
869//   templates.
870//
871//   datacatalog.entries.getIamPolicy to get policies on entries.
872//
873//   datacatalog.entryGroups.getIamPolicy to get policies on entry groups.
874func (c *Client) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
875	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource())))
876	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
877	opts = append(c.CallOptions.GetIamPolicy[0:len(c.CallOptions.GetIamPolicy):len(c.CallOptions.GetIamPolicy)], opts...)
878	var resp *iampb.Policy
879	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
880		var err error
881		resp, err = c.client.GetIamPolicy(ctx, req, settings.GRPC...)
882		return err
883	}, opts...)
884	if err != nil {
885		return nil, err
886	}
887	return resp, nil
888}
889
890// TestIamPermissions returns the caller’s permissions on a resource.
891// If the resource does not exist, an empty set of permissions is returned
892// (We don’t return a NOT_FOUND error).
893//
894// Supported resources are:
895//
896//   Tag templates.
897//
898//   Entries.
899//
900//   Entry groups.
901//   Note, this method cannot be used to manage policies for BigQuery, Pub/Sub
902//   and any external Google Cloud Platform resources synced to Data Catalog.
903//
904// A caller is not required to have Google IAM permission to make this
905// request.
906func (c *Client) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
907	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource())))
908	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
909	opts = append(c.CallOptions.TestIamPermissions[0:len(c.CallOptions.TestIamPermissions):len(c.CallOptions.TestIamPermissions)], opts...)
910	var resp *iampb.TestIamPermissionsResponse
911	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
912		var err error
913		resp, err = c.client.TestIamPermissions(ctx, req, settings.GRPC...)
914		return err
915	}, opts...)
916	if err != nil {
917		return nil, err
918	}
919	return resp, nil
920}
921
922// EntryGroupIterator manages a stream of *datacatalogpb.EntryGroup.
923type EntryGroupIterator struct {
924	items    []*datacatalogpb.EntryGroup
925	pageInfo *iterator.PageInfo
926	nextFunc func() error
927
928	// Response is the raw response for the current page.
929	// It must be cast to the RPC response type.
930	// Calling Next() or InternalFetch() updates this value.
931	Response interface{}
932
933	// InternalFetch is for use by the Google Cloud Libraries only.
934	// It is not part of the stable interface of this package.
935	//
936	// InternalFetch returns results from a single call to the underlying RPC.
937	// The number of results is no greater than pageSize.
938	// If there are no more results, nextPageToken is empty and err is nil.
939	InternalFetch func(pageSize int, pageToken string) (results []*datacatalogpb.EntryGroup, nextPageToken string, err error)
940}
941
942// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
943func (it *EntryGroupIterator) PageInfo() *iterator.PageInfo {
944	return it.pageInfo
945}
946
947// Next returns the next result. Its second return value is iterator.Done if there are no more
948// results. Once Next returns Done, all subsequent calls will return Done.
949func (it *EntryGroupIterator) Next() (*datacatalogpb.EntryGroup, error) {
950	var item *datacatalogpb.EntryGroup
951	if err := it.nextFunc(); err != nil {
952		return item, err
953	}
954	item = it.items[0]
955	it.items = it.items[1:]
956	return item, nil
957}
958
959func (it *EntryGroupIterator) bufLen() int {
960	return len(it.items)
961}
962
963func (it *EntryGroupIterator) takeBuf() interface{} {
964	b := it.items
965	it.items = nil
966	return b
967}
968
969// EntryIterator manages a stream of *datacatalogpb.Entry.
970type EntryIterator struct {
971	items    []*datacatalogpb.Entry
972	pageInfo *iterator.PageInfo
973	nextFunc func() error
974
975	// Response is the raw response for the current page.
976	// It must be cast to the RPC response type.
977	// Calling Next() or InternalFetch() updates this value.
978	Response interface{}
979
980	// InternalFetch is for use by the Google Cloud Libraries only.
981	// It is not part of the stable interface of this package.
982	//
983	// InternalFetch returns results from a single call to the underlying RPC.
984	// The number of results is no greater than pageSize.
985	// If there are no more results, nextPageToken is empty and err is nil.
986	InternalFetch func(pageSize int, pageToken string) (results []*datacatalogpb.Entry, nextPageToken string, err error)
987}
988
989// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
990func (it *EntryIterator) PageInfo() *iterator.PageInfo {
991	return it.pageInfo
992}
993
994// Next returns the next result. Its second return value is iterator.Done if there are no more
995// results. Once Next returns Done, all subsequent calls will return Done.
996func (it *EntryIterator) Next() (*datacatalogpb.Entry, error) {
997	var item *datacatalogpb.Entry
998	if err := it.nextFunc(); err != nil {
999		return item, err
1000	}
1001	item = it.items[0]
1002	it.items = it.items[1:]
1003	return item, nil
1004}
1005
1006func (it *EntryIterator) bufLen() int {
1007	return len(it.items)
1008}
1009
1010func (it *EntryIterator) takeBuf() interface{} {
1011	b := it.items
1012	it.items = nil
1013	return b
1014}
1015
1016// SearchCatalogResultIterator manages a stream of *datacatalogpb.SearchCatalogResult.
1017type SearchCatalogResultIterator struct {
1018	items    []*datacatalogpb.SearchCatalogResult
1019	pageInfo *iterator.PageInfo
1020	nextFunc func() error
1021
1022	// Response is the raw response for the current page.
1023	// It must be cast to the RPC response type.
1024	// Calling Next() or InternalFetch() updates this value.
1025	Response interface{}
1026
1027	// InternalFetch is for use by the Google Cloud Libraries only.
1028	// It is not part of the stable interface of this package.
1029	//
1030	// InternalFetch returns results from a single call to the underlying RPC.
1031	// The number of results is no greater than pageSize.
1032	// If there are no more results, nextPageToken is empty and err is nil.
1033	InternalFetch func(pageSize int, pageToken string) (results []*datacatalogpb.SearchCatalogResult, nextPageToken string, err error)
1034}
1035
1036// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1037func (it *SearchCatalogResultIterator) PageInfo() *iterator.PageInfo {
1038	return it.pageInfo
1039}
1040
1041// Next returns the next result. Its second return value is iterator.Done if there are no more
1042// results. Once Next returns Done, all subsequent calls will return Done.
1043func (it *SearchCatalogResultIterator) Next() (*datacatalogpb.SearchCatalogResult, error) {
1044	var item *datacatalogpb.SearchCatalogResult
1045	if err := it.nextFunc(); err != nil {
1046		return item, err
1047	}
1048	item = it.items[0]
1049	it.items = it.items[1:]
1050	return item, nil
1051}
1052
1053func (it *SearchCatalogResultIterator) bufLen() int {
1054	return len(it.items)
1055}
1056
1057func (it *SearchCatalogResultIterator) takeBuf() interface{} {
1058	b := it.items
1059	it.items = nil
1060	return b
1061}
1062
1063// TagIterator manages a stream of *datacatalogpb.Tag.
1064type TagIterator struct {
1065	items    []*datacatalogpb.Tag
1066	pageInfo *iterator.PageInfo
1067	nextFunc func() error
1068
1069	// Response is the raw response for the current page.
1070	// It must be cast to the RPC response type.
1071	// Calling Next() or InternalFetch() updates this value.
1072	Response interface{}
1073
1074	// InternalFetch is for use by the Google Cloud Libraries only.
1075	// It is not part of the stable interface of this package.
1076	//
1077	// InternalFetch returns results from a single call to the underlying RPC.
1078	// The number of results is no greater than pageSize.
1079	// If there are no more results, nextPageToken is empty and err is nil.
1080	InternalFetch func(pageSize int, pageToken string) (results []*datacatalogpb.Tag, nextPageToken string, err error)
1081}
1082
1083// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1084func (it *TagIterator) PageInfo() *iterator.PageInfo {
1085	return it.pageInfo
1086}
1087
1088// Next returns the next result. Its second return value is iterator.Done if there are no more
1089// results. Once Next returns Done, all subsequent calls will return Done.
1090func (it *TagIterator) Next() (*datacatalogpb.Tag, error) {
1091	var item *datacatalogpb.Tag
1092	if err := it.nextFunc(); err != nil {
1093		return item, err
1094	}
1095	item = it.items[0]
1096	it.items = it.items[1:]
1097	return item, nil
1098}
1099
1100func (it *TagIterator) bufLen() int {
1101	return len(it.items)
1102}
1103
1104func (it *TagIterator) takeBuf() interface{} {
1105	b := it.items
1106	it.items = nil
1107	return b
1108}
1109