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 migration
18
19import (
20	"context"
21	"fmt"
22	"math"
23	"net/url"
24	"time"
25
26	gax "github.com/googleapis/gax-go/v2"
27	"google.golang.org/api/iterator"
28	"google.golang.org/api/option"
29	"google.golang.org/api/option/internaloption"
30	gtransport "google.golang.org/api/transport/grpc"
31	migrationpb "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2alpha"
32	"google.golang.org/grpc"
33	"google.golang.org/grpc/codes"
34	"google.golang.org/grpc/metadata"
35	"google.golang.org/protobuf/proto"
36)
37
38var newClientHook clientHook
39
40// CallOptions contains the retry settings for each method of Client.
41type CallOptions struct {
42	CreateMigrationWorkflow []gax.CallOption
43	GetMigrationWorkflow    []gax.CallOption
44	ListMigrationWorkflows  []gax.CallOption
45	DeleteMigrationWorkflow []gax.CallOption
46	StartMigrationWorkflow  []gax.CallOption
47	GetMigrationSubtask     []gax.CallOption
48	ListMigrationSubtasks   []gax.CallOption
49}
50
51func defaultGRPCClientOptions() []option.ClientOption {
52	return []option.ClientOption{
53		internaloption.WithDefaultEndpoint("bigquerymigration.googleapis.com:443"),
54		internaloption.WithDefaultMTLSEndpoint("bigquerymigration.mtls.googleapis.com:443"),
55		internaloption.WithDefaultAudience("https://bigquerymigration.googleapis.com/"),
56		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
57		internaloption.EnableJwtWithScope(),
58		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
59		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
60			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
61	}
62}
63
64func defaultCallOptions() *CallOptions {
65	return &CallOptions{
66		CreateMigrationWorkflow: []gax.CallOption{},
67		GetMigrationWorkflow: []gax.CallOption{
68			gax.WithRetry(func() gax.Retryer {
69				return gax.OnCodes([]codes.Code{
70					codes.Unavailable,
71				}, gax.Backoff{
72					Initial:    1000 * time.Millisecond,
73					Max:        10000 * time.Millisecond,
74					Multiplier: 1.30,
75				})
76			}),
77		},
78		ListMigrationWorkflows: []gax.CallOption{
79			gax.WithRetry(func() gax.Retryer {
80				return gax.OnCodes([]codes.Code{
81					codes.Unavailable,
82				}, gax.Backoff{
83					Initial:    1000 * time.Millisecond,
84					Max:        10000 * time.Millisecond,
85					Multiplier: 1.30,
86				})
87			}),
88		},
89		DeleteMigrationWorkflow: []gax.CallOption{},
90		StartMigrationWorkflow: []gax.CallOption{
91			gax.WithRetry(func() gax.Retryer {
92				return gax.OnCodes([]codes.Code{
93					codes.Unavailable,
94				}, gax.Backoff{
95					Initial:    1000 * time.Millisecond,
96					Max:        10000 * time.Millisecond,
97					Multiplier: 1.30,
98				})
99			}),
100		},
101		GetMigrationSubtask: []gax.CallOption{
102			gax.WithRetry(func() gax.Retryer {
103				return gax.OnCodes([]codes.Code{
104					codes.Unavailable,
105				}, gax.Backoff{
106					Initial:    1000 * time.Millisecond,
107					Max:        10000 * time.Millisecond,
108					Multiplier: 1.30,
109				})
110			}),
111		},
112		ListMigrationSubtasks: []gax.CallOption{
113			gax.WithRetry(func() gax.Retryer {
114				return gax.OnCodes([]codes.Code{
115					codes.Unavailable,
116				}, gax.Backoff{
117					Initial:    1000 * time.Millisecond,
118					Max:        10000 * time.Millisecond,
119					Multiplier: 1.30,
120				})
121			}),
122		},
123	}
124}
125
126// internalClient is an interface that defines the methods availaible from BigQuery Migration API.
127type internalClient interface {
128	Close() error
129	setGoogleClientInfo(...string)
130	Connection() *grpc.ClientConn
131	CreateMigrationWorkflow(context.Context, *migrationpb.CreateMigrationWorkflowRequest, ...gax.CallOption) (*migrationpb.MigrationWorkflow, error)
132	GetMigrationWorkflow(context.Context, *migrationpb.GetMigrationWorkflowRequest, ...gax.CallOption) (*migrationpb.MigrationWorkflow, error)
133	ListMigrationWorkflows(context.Context, *migrationpb.ListMigrationWorkflowsRequest, ...gax.CallOption) *MigrationWorkflowIterator
134	DeleteMigrationWorkflow(context.Context, *migrationpb.DeleteMigrationWorkflowRequest, ...gax.CallOption) error
135	StartMigrationWorkflow(context.Context, *migrationpb.StartMigrationWorkflowRequest, ...gax.CallOption) error
136	GetMigrationSubtask(context.Context, *migrationpb.GetMigrationSubtaskRequest, ...gax.CallOption) (*migrationpb.MigrationSubtask, error)
137	ListMigrationSubtasks(context.Context, *migrationpb.ListMigrationSubtasksRequest, ...gax.CallOption) *MigrationSubtaskIterator
138}
139
140// Client is a client for interacting with BigQuery Migration API.
141// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
142//
143// Service to handle EDW migrations.
144type Client struct {
145	// The internal transport-dependent client.
146	internalClient internalClient
147
148	// The call options for this service.
149	CallOptions *CallOptions
150}
151
152// Wrapper methods routed to the internal client.
153
154// Close closes the connection to the API service. The user should invoke this when
155// the client is no longer required.
156func (c *Client) Close() error {
157	return c.internalClient.Close()
158}
159
160// setGoogleClientInfo sets the name and version of the application in
161// the `x-goog-api-client` header passed on each request. Intended for
162// use by Google-written clients.
163func (c *Client) setGoogleClientInfo(keyval ...string) {
164	c.internalClient.setGoogleClientInfo(keyval...)
165}
166
167// Connection returns a connection to the API service.
168//
169// Deprecated.
170func (c *Client) Connection() *grpc.ClientConn {
171	return c.internalClient.Connection()
172}
173
174// CreateMigrationWorkflow creates a migration workflow.
175func (c *Client) CreateMigrationWorkflow(ctx context.Context, req *migrationpb.CreateMigrationWorkflowRequest, opts ...gax.CallOption) (*migrationpb.MigrationWorkflow, error) {
176	return c.internalClient.CreateMigrationWorkflow(ctx, req, opts...)
177}
178
179// GetMigrationWorkflow gets a previously created migration workflow.
180func (c *Client) GetMigrationWorkflow(ctx context.Context, req *migrationpb.GetMigrationWorkflowRequest, opts ...gax.CallOption) (*migrationpb.MigrationWorkflow, error) {
181	return c.internalClient.GetMigrationWorkflow(ctx, req, opts...)
182}
183
184// ListMigrationWorkflows lists previously created migration workflow.
185func (c *Client) ListMigrationWorkflows(ctx context.Context, req *migrationpb.ListMigrationWorkflowsRequest, opts ...gax.CallOption) *MigrationWorkflowIterator {
186	return c.internalClient.ListMigrationWorkflows(ctx, req, opts...)
187}
188
189// DeleteMigrationWorkflow deletes a migration workflow by name.
190func (c *Client) DeleteMigrationWorkflow(ctx context.Context, req *migrationpb.DeleteMigrationWorkflowRequest, opts ...gax.CallOption) error {
191	return c.internalClient.DeleteMigrationWorkflow(ctx, req, opts...)
192}
193
194// StartMigrationWorkflow starts a previously created migration workflow. I.e., the state transitions
195// from DRAFT to RUNNING. This is a no-op if the state is already RUNNING.
196// An error will be signaled if the state is anything other than DRAFT or
197// RUNNING.
198func (c *Client) StartMigrationWorkflow(ctx context.Context, req *migrationpb.StartMigrationWorkflowRequest, opts ...gax.CallOption) error {
199	return c.internalClient.StartMigrationWorkflow(ctx, req, opts...)
200}
201
202// GetMigrationSubtask gets a previously created migration subtask.
203func (c *Client) GetMigrationSubtask(ctx context.Context, req *migrationpb.GetMigrationSubtaskRequest, opts ...gax.CallOption) (*migrationpb.MigrationSubtask, error) {
204	return c.internalClient.GetMigrationSubtask(ctx, req, opts...)
205}
206
207// ListMigrationSubtasks lists previously created migration subtasks.
208func (c *Client) ListMigrationSubtasks(ctx context.Context, req *migrationpb.ListMigrationSubtasksRequest, opts ...gax.CallOption) *MigrationSubtaskIterator {
209	return c.internalClient.ListMigrationSubtasks(ctx, req, opts...)
210}
211
212// gRPCClient is a client for interacting with BigQuery Migration API over gRPC transport.
213//
214// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
215type gRPCClient struct {
216	// Connection pool of gRPC connections to the service.
217	connPool gtransport.ConnPool
218
219	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
220	disableDeadlines bool
221
222	// Points back to the CallOptions field of the containing Client
223	CallOptions **CallOptions
224
225	// The gRPC API client.
226	client migrationpb.MigrationServiceClient
227
228	// The x-goog-* metadata to be sent with each request.
229	xGoogMetadata metadata.MD
230}
231
232// NewClient creates a new migration service client based on gRPC.
233// The returned client must be Closed when it is done being used to clean up its underlying connections.
234//
235// Service to handle EDW migrations.
236func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
237	clientOpts := defaultGRPCClientOptions()
238	if newClientHook != nil {
239		hookOpts, err := newClientHook(ctx, clientHookParams{})
240		if err != nil {
241			return nil, err
242		}
243		clientOpts = append(clientOpts, hookOpts...)
244	}
245
246	disableDeadlines, err := checkDisableDeadlines()
247	if err != nil {
248		return nil, err
249	}
250
251	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
252	if err != nil {
253		return nil, err
254	}
255	client := Client{CallOptions: defaultCallOptions()}
256
257	c := &gRPCClient{
258		connPool:         connPool,
259		disableDeadlines: disableDeadlines,
260		client:           migrationpb.NewMigrationServiceClient(connPool),
261		CallOptions:      &client.CallOptions,
262	}
263	c.setGoogleClientInfo()
264
265	client.internalClient = c
266
267	return &client, nil
268}
269
270// Connection returns a connection to the API service.
271//
272// Deprecated.
273func (c *gRPCClient) Connection() *grpc.ClientConn {
274	return c.connPool.Conn()
275}
276
277// setGoogleClientInfo sets the name and version of the application in
278// the `x-goog-api-client` header passed on each request. Intended for
279// use by Google-written clients.
280func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
281	kv := append([]string{"gl-go", versionGo()}, keyval...)
282	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
283	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
284}
285
286// Close closes the connection to the API service. The user should invoke this when
287// the client is no longer required.
288func (c *gRPCClient) Close() error {
289	return c.connPool.Close()
290}
291
292func (c *gRPCClient) CreateMigrationWorkflow(ctx context.Context, req *migrationpb.CreateMigrationWorkflowRequest, opts ...gax.CallOption) (*migrationpb.MigrationWorkflow, error) {
293	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
294		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
295		defer cancel()
296		ctx = cctx
297	}
298	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
299	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
300	opts = append((*c.CallOptions).CreateMigrationWorkflow[0:len((*c.CallOptions).CreateMigrationWorkflow):len((*c.CallOptions).CreateMigrationWorkflow)], opts...)
301	var resp *migrationpb.MigrationWorkflow
302	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
303		var err error
304		resp, err = c.client.CreateMigrationWorkflow(ctx, req, settings.GRPC...)
305		return err
306	}, opts...)
307	if err != nil {
308		return nil, err
309	}
310	return resp, nil
311}
312
313func (c *gRPCClient) GetMigrationWorkflow(ctx context.Context, req *migrationpb.GetMigrationWorkflowRequest, opts ...gax.CallOption) (*migrationpb.MigrationWorkflow, error) {
314	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
315		cctx, cancel := context.WithTimeout(ctx, 120000*time.Millisecond)
316		defer cancel()
317		ctx = cctx
318	}
319	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
320	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
321	opts = append((*c.CallOptions).GetMigrationWorkflow[0:len((*c.CallOptions).GetMigrationWorkflow):len((*c.CallOptions).GetMigrationWorkflow)], opts...)
322	var resp *migrationpb.MigrationWorkflow
323	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
324		var err error
325		resp, err = c.client.GetMigrationWorkflow(ctx, req, settings.GRPC...)
326		return err
327	}, opts...)
328	if err != nil {
329		return nil, err
330	}
331	return resp, nil
332}
333
334func (c *gRPCClient) ListMigrationWorkflows(ctx context.Context, req *migrationpb.ListMigrationWorkflowsRequest, opts ...gax.CallOption) *MigrationWorkflowIterator {
335	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
336	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
337	opts = append((*c.CallOptions).ListMigrationWorkflows[0:len((*c.CallOptions).ListMigrationWorkflows):len((*c.CallOptions).ListMigrationWorkflows)], opts...)
338	it := &MigrationWorkflowIterator{}
339	req = proto.Clone(req).(*migrationpb.ListMigrationWorkflowsRequest)
340	it.InternalFetch = func(pageSize int, pageToken string) ([]*migrationpb.MigrationWorkflow, string, error) {
341		resp := &migrationpb.ListMigrationWorkflowsResponse{}
342		if pageToken != "" {
343			req.PageToken = pageToken
344		}
345		if pageSize > math.MaxInt32 {
346			req.PageSize = math.MaxInt32
347		} else if pageSize != 0 {
348			req.PageSize = int32(pageSize)
349		}
350		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
351			var err error
352			resp, err = c.client.ListMigrationWorkflows(ctx, req, settings.GRPC...)
353			return err
354		}, opts...)
355		if err != nil {
356			return nil, "", err
357		}
358
359		it.Response = resp
360		return resp.GetMigrationWorkflows(), resp.GetNextPageToken(), nil
361	}
362	fetch := func(pageSize int, pageToken string) (string, error) {
363		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
364		if err != nil {
365			return "", err
366		}
367		it.items = append(it.items, items...)
368		return nextPageToken, nil
369	}
370
371	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
372	it.pageInfo.MaxSize = int(req.GetPageSize())
373	it.pageInfo.Token = req.GetPageToken()
374
375	return it
376}
377
378func (c *gRPCClient) DeleteMigrationWorkflow(ctx context.Context, req *migrationpb.DeleteMigrationWorkflowRequest, opts ...gax.CallOption) error {
379	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
380		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
381		defer cancel()
382		ctx = cctx
383	}
384	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
385	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
386	opts = append((*c.CallOptions).DeleteMigrationWorkflow[0:len((*c.CallOptions).DeleteMigrationWorkflow):len((*c.CallOptions).DeleteMigrationWorkflow)], opts...)
387	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
388		var err error
389		_, err = c.client.DeleteMigrationWorkflow(ctx, req, settings.GRPC...)
390		return err
391	}, opts...)
392	return err
393}
394
395func (c *gRPCClient) StartMigrationWorkflow(ctx context.Context, req *migrationpb.StartMigrationWorkflowRequest, opts ...gax.CallOption) error {
396	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
397		cctx, cancel := context.WithTimeout(ctx, 120000*time.Millisecond)
398		defer cancel()
399		ctx = cctx
400	}
401	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
402	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
403	opts = append((*c.CallOptions).StartMigrationWorkflow[0:len((*c.CallOptions).StartMigrationWorkflow):len((*c.CallOptions).StartMigrationWorkflow)], opts...)
404	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
405		var err error
406		_, err = c.client.StartMigrationWorkflow(ctx, req, settings.GRPC...)
407		return err
408	}, opts...)
409	return err
410}
411
412func (c *gRPCClient) GetMigrationSubtask(ctx context.Context, req *migrationpb.GetMigrationSubtaskRequest, opts ...gax.CallOption) (*migrationpb.MigrationSubtask, error) {
413	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
414		cctx, cancel := context.WithTimeout(ctx, 120000*time.Millisecond)
415		defer cancel()
416		ctx = cctx
417	}
418	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
419	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
420	opts = append((*c.CallOptions).GetMigrationSubtask[0:len((*c.CallOptions).GetMigrationSubtask):len((*c.CallOptions).GetMigrationSubtask)], opts...)
421	var resp *migrationpb.MigrationSubtask
422	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
423		var err error
424		resp, err = c.client.GetMigrationSubtask(ctx, req, settings.GRPC...)
425		return err
426	}, opts...)
427	if err != nil {
428		return nil, err
429	}
430	return resp, nil
431}
432
433func (c *gRPCClient) ListMigrationSubtasks(ctx context.Context, req *migrationpb.ListMigrationSubtasksRequest, opts ...gax.CallOption) *MigrationSubtaskIterator {
434	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
435	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
436	opts = append((*c.CallOptions).ListMigrationSubtasks[0:len((*c.CallOptions).ListMigrationSubtasks):len((*c.CallOptions).ListMigrationSubtasks)], opts...)
437	it := &MigrationSubtaskIterator{}
438	req = proto.Clone(req).(*migrationpb.ListMigrationSubtasksRequest)
439	it.InternalFetch = func(pageSize int, pageToken string) ([]*migrationpb.MigrationSubtask, string, error) {
440		resp := &migrationpb.ListMigrationSubtasksResponse{}
441		if pageToken != "" {
442			req.PageToken = pageToken
443		}
444		if pageSize > math.MaxInt32 {
445			req.PageSize = math.MaxInt32
446		} else if pageSize != 0 {
447			req.PageSize = int32(pageSize)
448		}
449		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
450			var err error
451			resp, err = c.client.ListMigrationSubtasks(ctx, req, settings.GRPC...)
452			return err
453		}, opts...)
454		if err != nil {
455			return nil, "", err
456		}
457
458		it.Response = resp
459		return resp.GetMigrationSubtasks(), resp.GetNextPageToken(), nil
460	}
461	fetch := func(pageSize int, pageToken string) (string, error) {
462		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
463		if err != nil {
464			return "", err
465		}
466		it.items = append(it.items, items...)
467		return nextPageToken, nil
468	}
469
470	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
471	it.pageInfo.MaxSize = int(req.GetPageSize())
472	it.pageInfo.Token = req.GetPageToken()
473
474	return it
475}
476
477// MigrationSubtaskIterator manages a stream of *migrationpb.MigrationSubtask.
478type MigrationSubtaskIterator struct {
479	items    []*migrationpb.MigrationSubtask
480	pageInfo *iterator.PageInfo
481	nextFunc func() error
482
483	// Response is the raw response for the current page.
484	// It must be cast to the RPC response type.
485	// Calling Next() or InternalFetch() updates this value.
486	Response interface{}
487
488	// InternalFetch is for use by the Google Cloud Libraries only.
489	// It is not part of the stable interface of this package.
490	//
491	// InternalFetch returns results from a single call to the underlying RPC.
492	// The number of results is no greater than pageSize.
493	// If there are no more results, nextPageToken is empty and err is nil.
494	InternalFetch func(pageSize int, pageToken string) (results []*migrationpb.MigrationSubtask, nextPageToken string, err error)
495}
496
497// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
498func (it *MigrationSubtaskIterator) PageInfo() *iterator.PageInfo {
499	return it.pageInfo
500}
501
502// Next returns the next result. Its second return value is iterator.Done if there are no more
503// results. Once Next returns Done, all subsequent calls will return Done.
504func (it *MigrationSubtaskIterator) Next() (*migrationpb.MigrationSubtask, error) {
505	var item *migrationpb.MigrationSubtask
506	if err := it.nextFunc(); err != nil {
507		return item, err
508	}
509	item = it.items[0]
510	it.items = it.items[1:]
511	return item, nil
512}
513
514func (it *MigrationSubtaskIterator) bufLen() int {
515	return len(it.items)
516}
517
518func (it *MigrationSubtaskIterator) takeBuf() interface{} {
519	b := it.items
520	it.items = nil
521	return b
522}
523
524// MigrationWorkflowIterator manages a stream of *migrationpb.MigrationWorkflow.
525type MigrationWorkflowIterator struct {
526	items    []*migrationpb.MigrationWorkflow
527	pageInfo *iterator.PageInfo
528	nextFunc func() error
529
530	// Response is the raw response for the current page.
531	// It must be cast to the RPC response type.
532	// Calling Next() or InternalFetch() updates this value.
533	Response interface{}
534
535	// InternalFetch is for use by the Google Cloud Libraries only.
536	// It is not part of the stable interface of this package.
537	//
538	// InternalFetch returns results from a single call to the underlying RPC.
539	// The number of results is no greater than pageSize.
540	// If there are no more results, nextPageToken is empty and err is nil.
541	InternalFetch func(pageSize int, pageToken string) (results []*migrationpb.MigrationWorkflow, nextPageToken string, err error)
542}
543
544// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
545func (it *MigrationWorkflowIterator) PageInfo() *iterator.PageInfo {
546	return it.pageInfo
547}
548
549// Next returns the next result. Its second return value is iterator.Done if there are no more
550// results. Once Next returns Done, all subsequent calls will return Done.
551func (it *MigrationWorkflowIterator) Next() (*migrationpb.MigrationWorkflow, error) {
552	var item *migrationpb.MigrationWorkflow
553	if err := it.nextFunc(); err != nil {
554		return item, err
555	}
556	item = it.items[0]
557	it.items = it.items[1:]
558	return item, nil
559}
560
561func (it *MigrationWorkflowIterator) bufLen() int {
562	return len(it.items)
563}
564
565func (it *MigrationWorkflowIterator) takeBuf() interface{} {
566	b := it.items
567	it.items = nil
568	return b
569}
570