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 datastream
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	gax "github.com/googleapis/gax-go/v2"
29	"google.golang.org/api/iterator"
30	"google.golang.org/api/option"
31	"google.golang.org/api/option/internaloption"
32	gtransport "google.golang.org/api/transport/grpc"
33	datastreampb "google.golang.org/genproto/googleapis/cloud/datastream/v1alpha1"
34	longrunningpb "google.golang.org/genproto/googleapis/longrunning"
35	"google.golang.org/grpc"
36	"google.golang.org/grpc/codes"
37	"google.golang.org/grpc/metadata"
38	"google.golang.org/protobuf/proto"
39)
40
41var newClientHook clientHook
42
43// CallOptions contains the retry settings for each method of Client.
44type CallOptions struct {
45	ListConnectionProfiles    []gax.CallOption
46	GetConnectionProfile      []gax.CallOption
47	CreateConnectionProfile   []gax.CallOption
48	UpdateConnectionProfile   []gax.CallOption
49	DeleteConnectionProfile   []gax.CallOption
50	DiscoverConnectionProfile []gax.CallOption
51	ListStreams               []gax.CallOption
52	GetStream                 []gax.CallOption
53	CreateStream              []gax.CallOption
54	UpdateStream              []gax.CallOption
55	DeleteStream              []gax.CallOption
56	FetchErrors               []gax.CallOption
57	FetchStaticIps            []gax.CallOption
58	CreatePrivateConnection   []gax.CallOption
59	GetPrivateConnection      []gax.CallOption
60	ListPrivateConnections    []gax.CallOption
61	DeletePrivateConnection   []gax.CallOption
62	CreateRoute               []gax.CallOption
63	GetRoute                  []gax.CallOption
64	ListRoutes                []gax.CallOption
65	DeleteRoute               []gax.CallOption
66}
67
68func defaultGRPCClientOptions() []option.ClientOption {
69	return []option.ClientOption{
70		internaloption.WithDefaultEndpoint("datastream.googleapis.com:443"),
71		internaloption.WithDefaultMTLSEndpoint("datastream.mtls.googleapis.com:443"),
72		internaloption.WithDefaultAudience("https://datastream.googleapis.com/"),
73		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
74		internaloption.EnableJwtWithScope(),
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		ListConnectionProfiles: []gax.CallOption{
84			gax.WithRetry(func() gax.Retryer {
85				return gax.OnCodes([]codes.Code{
86					codes.Unavailable,
87				}, gax.Backoff{
88					Initial:    1000 * time.Millisecond,
89					Max:        10000 * time.Millisecond,
90					Multiplier: 1.30,
91				})
92			}),
93		},
94		GetConnectionProfile: []gax.CallOption{
95			gax.WithRetry(func() gax.Retryer {
96				return gax.OnCodes([]codes.Code{
97					codes.Unavailable,
98				}, gax.Backoff{
99					Initial:    1000 * time.Millisecond,
100					Max:        10000 * time.Millisecond,
101					Multiplier: 1.30,
102				})
103			}),
104		},
105		CreateConnectionProfile: []gax.CallOption{},
106		UpdateConnectionProfile: []gax.CallOption{},
107		DeleteConnectionProfile: []gax.CallOption{},
108		DiscoverConnectionProfile: []gax.CallOption{
109			gax.WithRetry(func() gax.Retryer {
110				return gax.OnCodes([]codes.Code{
111					codes.Unavailable,
112				}, gax.Backoff{
113					Initial:    1000 * time.Millisecond,
114					Max:        10000 * time.Millisecond,
115					Multiplier: 1.30,
116				})
117			}),
118		},
119		ListStreams: []gax.CallOption{
120			gax.WithRetry(func() gax.Retryer {
121				return gax.OnCodes([]codes.Code{
122					codes.Unavailable,
123				}, gax.Backoff{
124					Initial:    1000 * time.Millisecond,
125					Max:        10000 * time.Millisecond,
126					Multiplier: 1.30,
127				})
128			}),
129		},
130		GetStream: []gax.CallOption{
131			gax.WithRetry(func() gax.Retryer {
132				return gax.OnCodes([]codes.Code{
133					codes.Unavailable,
134				}, gax.Backoff{
135					Initial:    1000 * time.Millisecond,
136					Max:        10000 * time.Millisecond,
137					Multiplier: 1.30,
138				})
139			}),
140		},
141		CreateStream: []gax.CallOption{},
142		UpdateStream: []gax.CallOption{},
143		DeleteStream: []gax.CallOption{},
144		FetchErrors: []gax.CallOption{
145			gax.WithRetry(func() gax.Retryer {
146				return gax.OnCodes([]codes.Code{
147					codes.Unavailable,
148				}, gax.Backoff{
149					Initial:    1000 * time.Millisecond,
150					Max:        10000 * time.Millisecond,
151					Multiplier: 1.30,
152				})
153			}),
154		},
155		FetchStaticIps: []gax.CallOption{
156			gax.WithRetry(func() gax.Retryer {
157				return gax.OnCodes([]codes.Code{
158					codes.Unavailable,
159				}, gax.Backoff{
160					Initial:    1000 * time.Millisecond,
161					Max:        10000 * time.Millisecond,
162					Multiplier: 1.30,
163				})
164			}),
165		},
166		CreatePrivateConnection: []gax.CallOption{},
167		GetPrivateConnection: []gax.CallOption{
168			gax.WithRetry(func() gax.Retryer {
169				return gax.OnCodes([]codes.Code{
170					codes.Unavailable,
171				}, gax.Backoff{
172					Initial:    1000 * time.Millisecond,
173					Max:        10000 * time.Millisecond,
174					Multiplier: 1.30,
175				})
176			}),
177		},
178		ListPrivateConnections: []gax.CallOption{
179			gax.WithRetry(func() gax.Retryer {
180				return gax.OnCodes([]codes.Code{
181					codes.Unavailable,
182				}, gax.Backoff{
183					Initial:    1000 * time.Millisecond,
184					Max:        10000 * time.Millisecond,
185					Multiplier: 1.30,
186				})
187			}),
188		},
189		DeletePrivateConnection: []gax.CallOption{},
190		CreateRoute:             []gax.CallOption{},
191		GetRoute: []gax.CallOption{
192			gax.WithRetry(func() gax.Retryer {
193				return gax.OnCodes([]codes.Code{
194					codes.Unavailable,
195				}, gax.Backoff{
196					Initial:    1000 * time.Millisecond,
197					Max:        10000 * time.Millisecond,
198					Multiplier: 1.30,
199				})
200			}),
201		},
202		ListRoutes: []gax.CallOption{
203			gax.WithRetry(func() gax.Retryer {
204				return gax.OnCodes([]codes.Code{
205					codes.Unavailable,
206				}, gax.Backoff{
207					Initial:    1000 * time.Millisecond,
208					Max:        10000 * time.Millisecond,
209					Multiplier: 1.30,
210				})
211			}),
212		},
213		DeleteRoute: []gax.CallOption{},
214	}
215}
216
217// internalClient is an interface that defines the methods availaible from Datastream API.
218type internalClient interface {
219	Close() error
220	setGoogleClientInfo(...string)
221	Connection() *grpc.ClientConn
222	ListConnectionProfiles(context.Context, *datastreampb.ListConnectionProfilesRequest, ...gax.CallOption) *ConnectionProfileIterator
223	GetConnectionProfile(context.Context, *datastreampb.GetConnectionProfileRequest, ...gax.CallOption) (*datastreampb.ConnectionProfile, error)
224	CreateConnectionProfile(context.Context, *datastreampb.CreateConnectionProfileRequest, ...gax.CallOption) (*CreateConnectionProfileOperation, error)
225	CreateConnectionProfileOperation(name string) *CreateConnectionProfileOperation
226	UpdateConnectionProfile(context.Context, *datastreampb.UpdateConnectionProfileRequest, ...gax.CallOption) (*UpdateConnectionProfileOperation, error)
227	UpdateConnectionProfileOperation(name string) *UpdateConnectionProfileOperation
228	DeleteConnectionProfile(context.Context, *datastreampb.DeleteConnectionProfileRequest, ...gax.CallOption) (*DeleteConnectionProfileOperation, error)
229	DeleteConnectionProfileOperation(name string) *DeleteConnectionProfileOperation
230	DiscoverConnectionProfile(context.Context, *datastreampb.DiscoverConnectionProfileRequest, ...gax.CallOption) (*datastreampb.DiscoverConnectionProfileResponse, error)
231	ListStreams(context.Context, *datastreampb.ListStreamsRequest, ...gax.CallOption) *StreamIterator
232	GetStream(context.Context, *datastreampb.GetStreamRequest, ...gax.CallOption) (*datastreampb.Stream, error)
233	CreateStream(context.Context, *datastreampb.CreateStreamRequest, ...gax.CallOption) (*CreateStreamOperation, error)
234	CreateStreamOperation(name string) *CreateStreamOperation
235	UpdateStream(context.Context, *datastreampb.UpdateStreamRequest, ...gax.CallOption) (*UpdateStreamOperation, error)
236	UpdateStreamOperation(name string) *UpdateStreamOperation
237	DeleteStream(context.Context, *datastreampb.DeleteStreamRequest, ...gax.CallOption) (*DeleteStreamOperation, error)
238	DeleteStreamOperation(name string) *DeleteStreamOperation
239	FetchErrors(context.Context, *datastreampb.FetchErrorsRequest, ...gax.CallOption) (*FetchErrorsOperation, error)
240	FetchErrorsOperation(name string) *FetchErrorsOperation
241	FetchStaticIps(context.Context, *datastreampb.FetchStaticIpsRequest, ...gax.CallOption) *StringIterator
242	CreatePrivateConnection(context.Context, *datastreampb.CreatePrivateConnectionRequest, ...gax.CallOption) (*CreatePrivateConnectionOperation, error)
243	CreatePrivateConnectionOperation(name string) *CreatePrivateConnectionOperation
244	GetPrivateConnection(context.Context, *datastreampb.GetPrivateConnectionRequest, ...gax.CallOption) (*datastreampb.PrivateConnection, error)
245	ListPrivateConnections(context.Context, *datastreampb.ListPrivateConnectionsRequest, ...gax.CallOption) *PrivateConnectionIterator
246	DeletePrivateConnection(context.Context, *datastreampb.DeletePrivateConnectionRequest, ...gax.CallOption) (*DeletePrivateConnectionOperation, error)
247	DeletePrivateConnectionOperation(name string) *DeletePrivateConnectionOperation
248	CreateRoute(context.Context, *datastreampb.CreateRouteRequest, ...gax.CallOption) (*CreateRouteOperation, error)
249	CreateRouteOperation(name string) *CreateRouteOperation
250	GetRoute(context.Context, *datastreampb.GetRouteRequest, ...gax.CallOption) (*datastreampb.Route, error)
251	ListRoutes(context.Context, *datastreampb.ListRoutesRequest, ...gax.CallOption) *RouteIterator
252	DeleteRoute(context.Context, *datastreampb.DeleteRouteRequest, ...gax.CallOption) (*DeleteRouteOperation, error)
253	DeleteRouteOperation(name string) *DeleteRouteOperation
254}
255
256// Client is a client for interacting with Datastream API.
257// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
258//
259// Datastream service
260type Client struct {
261	// The internal transport-dependent client.
262	internalClient internalClient
263
264	// The call options for this service.
265	CallOptions *CallOptions
266
267	// LROClient is used internally to handle long-running operations.
268	// It is exposed so that its CallOptions can be modified if required.
269	// Users should not Close this client.
270	LROClient *lroauto.OperationsClient
271}
272
273// Wrapper methods routed to the internal client.
274
275// Close closes the connection to the API service. The user should invoke this when
276// the client is no longer required.
277func (c *Client) Close() error {
278	return c.internalClient.Close()
279}
280
281// setGoogleClientInfo sets the name and version of the application in
282// the `x-goog-api-client` header passed on each request. Intended for
283// use by Google-written clients.
284func (c *Client) setGoogleClientInfo(keyval ...string) {
285	c.internalClient.setGoogleClientInfo(keyval...)
286}
287
288// Connection returns a connection to the API service.
289//
290// Deprecated.
291func (c *Client) Connection() *grpc.ClientConn {
292	return c.internalClient.Connection()
293}
294
295// ListConnectionProfiles use this method to list connection profiles created in a project and
296// location.
297func (c *Client) ListConnectionProfiles(ctx context.Context, req *datastreampb.ListConnectionProfilesRequest, opts ...gax.CallOption) *ConnectionProfileIterator {
298	return c.internalClient.ListConnectionProfiles(ctx, req, opts...)
299}
300
301// GetConnectionProfile use this method to get details about a connection profile.
302func (c *Client) GetConnectionProfile(ctx context.Context, req *datastreampb.GetConnectionProfileRequest, opts ...gax.CallOption) (*datastreampb.ConnectionProfile, error) {
303	return c.internalClient.GetConnectionProfile(ctx, req, opts...)
304}
305
306// CreateConnectionProfile use this method to create a connection profile in a project and location.
307func (c *Client) CreateConnectionProfile(ctx context.Context, req *datastreampb.CreateConnectionProfileRequest, opts ...gax.CallOption) (*CreateConnectionProfileOperation, error) {
308	return c.internalClient.CreateConnectionProfile(ctx, req, opts...)
309}
310
311// CreateConnectionProfileOperation returns a new CreateConnectionProfileOperation from a given name.
312// The name must be that of a previously created CreateConnectionProfileOperation, possibly from a different process.
313func (c *Client) CreateConnectionProfileOperation(name string) *CreateConnectionProfileOperation {
314	return c.internalClient.CreateConnectionProfileOperation(name)
315}
316
317// UpdateConnectionProfile use this method to update the parameters of a connection profile.
318func (c *Client) UpdateConnectionProfile(ctx context.Context, req *datastreampb.UpdateConnectionProfileRequest, opts ...gax.CallOption) (*UpdateConnectionProfileOperation, error) {
319	return c.internalClient.UpdateConnectionProfile(ctx, req, opts...)
320}
321
322// UpdateConnectionProfileOperation returns a new UpdateConnectionProfileOperation from a given name.
323// The name must be that of a previously created UpdateConnectionProfileOperation, possibly from a different process.
324func (c *Client) UpdateConnectionProfileOperation(name string) *UpdateConnectionProfileOperation {
325	return c.internalClient.UpdateConnectionProfileOperation(name)
326}
327
328// DeleteConnectionProfile use this method to delete a connection profile…
329func (c *Client) DeleteConnectionProfile(ctx context.Context, req *datastreampb.DeleteConnectionProfileRequest, opts ...gax.CallOption) (*DeleteConnectionProfileOperation, error) {
330	return c.internalClient.DeleteConnectionProfile(ctx, req, opts...)
331}
332
333// DeleteConnectionProfileOperation returns a new DeleteConnectionProfileOperation from a given name.
334// The name must be that of a previously created DeleteConnectionProfileOperation, possibly from a different process.
335func (c *Client) DeleteConnectionProfileOperation(name string) *DeleteConnectionProfileOperation {
336	return c.internalClient.DeleteConnectionProfileOperation(name)
337}
338
339// DiscoverConnectionProfile use this method to discover a connection profile.
340// The discover API call exposes the data objects and metadata belonging to
341// the profile. Typically, a request returns children data objects under a
342// parent data object that’s optionally supplied in the request.
343func (c *Client) DiscoverConnectionProfile(ctx context.Context, req *datastreampb.DiscoverConnectionProfileRequest, opts ...gax.CallOption) (*datastreampb.DiscoverConnectionProfileResponse, error) {
344	return c.internalClient.DiscoverConnectionProfile(ctx, req, opts...)
345}
346
347// ListStreams use this method to list streams in a project and location.
348func (c *Client) ListStreams(ctx context.Context, req *datastreampb.ListStreamsRequest, opts ...gax.CallOption) *StreamIterator {
349	return c.internalClient.ListStreams(ctx, req, opts...)
350}
351
352// GetStream use this method to get details about a stream.
353func (c *Client) GetStream(ctx context.Context, req *datastreampb.GetStreamRequest, opts ...gax.CallOption) (*datastreampb.Stream, error) {
354	return c.internalClient.GetStream(ctx, req, opts...)
355}
356
357// CreateStream use this method to create a stream.
358func (c *Client) CreateStream(ctx context.Context, req *datastreampb.CreateStreamRequest, opts ...gax.CallOption) (*CreateStreamOperation, error) {
359	return c.internalClient.CreateStream(ctx, req, opts...)
360}
361
362// CreateStreamOperation returns a new CreateStreamOperation from a given name.
363// The name must be that of a previously created CreateStreamOperation, possibly from a different process.
364func (c *Client) CreateStreamOperation(name string) *CreateStreamOperation {
365	return c.internalClient.CreateStreamOperation(name)
366}
367
368// UpdateStream use this method to update the configuration of a stream.
369func (c *Client) UpdateStream(ctx context.Context, req *datastreampb.UpdateStreamRequest, opts ...gax.CallOption) (*UpdateStreamOperation, error) {
370	return c.internalClient.UpdateStream(ctx, req, opts...)
371}
372
373// UpdateStreamOperation returns a new UpdateStreamOperation from a given name.
374// The name must be that of a previously created UpdateStreamOperation, possibly from a different process.
375func (c *Client) UpdateStreamOperation(name string) *UpdateStreamOperation {
376	return c.internalClient.UpdateStreamOperation(name)
377}
378
379// DeleteStream use this method to delete a stream.
380func (c *Client) DeleteStream(ctx context.Context, req *datastreampb.DeleteStreamRequest, opts ...gax.CallOption) (*DeleteStreamOperation, error) {
381	return c.internalClient.DeleteStream(ctx, req, opts...)
382}
383
384// DeleteStreamOperation returns a new DeleteStreamOperation from a given name.
385// The name must be that of a previously created DeleteStreamOperation, possibly from a different process.
386func (c *Client) DeleteStreamOperation(name string) *DeleteStreamOperation {
387	return c.internalClient.DeleteStreamOperation(name)
388}
389
390// FetchErrors use this method to fetch any errors associated with a stream.
391func (c *Client) FetchErrors(ctx context.Context, req *datastreampb.FetchErrorsRequest, opts ...gax.CallOption) (*FetchErrorsOperation, error) {
392	return c.internalClient.FetchErrors(ctx, req, opts...)
393}
394
395// FetchErrorsOperation returns a new FetchErrorsOperation from a given name.
396// The name must be that of a previously created FetchErrorsOperation, possibly from a different process.
397func (c *Client) FetchErrorsOperation(name string) *FetchErrorsOperation {
398	return c.internalClient.FetchErrorsOperation(name)
399}
400
401// FetchStaticIps the FetchStaticIps API call exposes the static ips used by Datastream.
402// Typically, a request returns children data objects under
403// a parent data object that’s optionally supplied in the request.
404func (c *Client) FetchStaticIps(ctx context.Context, req *datastreampb.FetchStaticIpsRequest, opts ...gax.CallOption) *StringIterator {
405	return c.internalClient.FetchStaticIps(ctx, req, opts...)
406}
407
408// CreatePrivateConnection use this method to create a private connectivity configuration.
409func (c *Client) CreatePrivateConnection(ctx context.Context, req *datastreampb.CreatePrivateConnectionRequest, opts ...gax.CallOption) (*CreatePrivateConnectionOperation, error) {
410	return c.internalClient.CreatePrivateConnection(ctx, req, opts...)
411}
412
413// CreatePrivateConnectionOperation returns a new CreatePrivateConnectionOperation from a given name.
414// The name must be that of a previously created CreatePrivateConnectionOperation, possibly from a different process.
415func (c *Client) CreatePrivateConnectionOperation(name string) *CreatePrivateConnectionOperation {
416	return c.internalClient.CreatePrivateConnectionOperation(name)
417}
418
419// GetPrivateConnection use this method to get details about a private connectivity configuration.
420func (c *Client) GetPrivateConnection(ctx context.Context, req *datastreampb.GetPrivateConnectionRequest, opts ...gax.CallOption) (*datastreampb.PrivateConnection, error) {
421	return c.internalClient.GetPrivateConnection(ctx, req, opts...)
422}
423
424// ListPrivateConnections use this method to list private connectivity configurations in a project
425// and location.
426func (c *Client) ListPrivateConnections(ctx context.Context, req *datastreampb.ListPrivateConnectionsRequest, opts ...gax.CallOption) *PrivateConnectionIterator {
427	return c.internalClient.ListPrivateConnections(ctx, req, opts...)
428}
429
430// DeletePrivateConnection use this method to delete a private connectivity configuration.
431func (c *Client) DeletePrivateConnection(ctx context.Context, req *datastreampb.DeletePrivateConnectionRequest, opts ...gax.CallOption) (*DeletePrivateConnectionOperation, error) {
432	return c.internalClient.DeletePrivateConnection(ctx, req, opts...)
433}
434
435// DeletePrivateConnectionOperation returns a new DeletePrivateConnectionOperation from a given name.
436// The name must be that of a previously created DeletePrivateConnectionOperation, possibly from a different process.
437func (c *Client) DeletePrivateConnectionOperation(name string) *DeletePrivateConnectionOperation {
438	return c.internalClient.DeletePrivateConnectionOperation(name)
439}
440
441// CreateRoute use this method to create a route for a private connectivity in a project
442// and location.
443func (c *Client) CreateRoute(ctx context.Context, req *datastreampb.CreateRouteRequest, opts ...gax.CallOption) (*CreateRouteOperation, error) {
444	return c.internalClient.CreateRoute(ctx, req, opts...)
445}
446
447// CreateRouteOperation returns a new CreateRouteOperation from a given name.
448// The name must be that of a previously created CreateRouteOperation, possibly from a different process.
449func (c *Client) CreateRouteOperation(name string) *CreateRouteOperation {
450	return c.internalClient.CreateRouteOperation(name)
451}
452
453// GetRoute use this method to get details about a route.
454func (c *Client) GetRoute(ctx context.Context, req *datastreampb.GetRouteRequest, opts ...gax.CallOption) (*datastreampb.Route, error) {
455	return c.internalClient.GetRoute(ctx, req, opts...)
456}
457
458// ListRoutes use this method to list routes created for a private connectivity in a
459// project and location.
460func (c *Client) ListRoutes(ctx context.Context, req *datastreampb.ListRoutesRequest, opts ...gax.CallOption) *RouteIterator {
461	return c.internalClient.ListRoutes(ctx, req, opts...)
462}
463
464// DeleteRoute use this method to delete a route.
465func (c *Client) DeleteRoute(ctx context.Context, req *datastreampb.DeleteRouteRequest, opts ...gax.CallOption) (*DeleteRouteOperation, error) {
466	return c.internalClient.DeleteRoute(ctx, req, opts...)
467}
468
469// DeleteRouteOperation returns a new DeleteRouteOperation from a given name.
470// The name must be that of a previously created DeleteRouteOperation, possibly from a different process.
471func (c *Client) DeleteRouteOperation(name string) *DeleteRouteOperation {
472	return c.internalClient.DeleteRouteOperation(name)
473}
474
475// gRPCClient is a client for interacting with Datastream API over gRPC transport.
476//
477// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
478type gRPCClient struct {
479	// Connection pool of gRPC connections to the service.
480	connPool gtransport.ConnPool
481
482	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
483	disableDeadlines bool
484
485	// Points back to the CallOptions field of the containing Client
486	CallOptions **CallOptions
487
488	// The gRPC API client.
489	client datastreampb.DatastreamClient
490
491	// LROClient is used internally to handle long-running operations.
492	// It is exposed so that its CallOptions can be modified if required.
493	// Users should not Close this client.
494	LROClient **lroauto.OperationsClient
495
496	// The x-goog-* metadata to be sent with each request.
497	xGoogMetadata metadata.MD
498}
499
500// NewClient creates a new datastream client based on gRPC.
501// The returned client must be Closed when it is done being used to clean up its underlying connections.
502//
503// Datastream service
504func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
505	clientOpts := defaultGRPCClientOptions()
506	if newClientHook != nil {
507		hookOpts, err := newClientHook(ctx, clientHookParams{})
508		if err != nil {
509			return nil, err
510		}
511		clientOpts = append(clientOpts, hookOpts...)
512	}
513
514	disableDeadlines, err := checkDisableDeadlines()
515	if err != nil {
516		return nil, err
517	}
518
519	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
520	if err != nil {
521		return nil, err
522	}
523	client := Client{CallOptions: defaultCallOptions()}
524
525	c := &gRPCClient{
526		connPool:         connPool,
527		disableDeadlines: disableDeadlines,
528		client:           datastreampb.NewDatastreamClient(connPool),
529		CallOptions:      &client.CallOptions,
530	}
531	c.setGoogleClientInfo()
532
533	client.internalClient = c
534
535	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
536	if err != nil {
537		// This error "should not happen", since we are just reusing old connection pool
538		// and never actually need to dial.
539		// If this does happen, we could leak connp. However, we cannot close conn:
540		// If the user invoked the constructor with option.WithGRPCConn,
541		// we would close a connection that's still in use.
542		// TODO: investigate error conditions.
543		return nil, err
544	}
545	c.LROClient = &client.LROClient
546	return &client, nil
547}
548
549// Connection returns a connection to the API service.
550//
551// Deprecated.
552func (c *gRPCClient) Connection() *grpc.ClientConn {
553	return c.connPool.Conn()
554}
555
556// setGoogleClientInfo sets the name and version of the application in
557// the `x-goog-api-client` header passed on each request. Intended for
558// use by Google-written clients.
559func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
560	kv := append([]string{"gl-go", versionGo()}, keyval...)
561	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
562	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
563}
564
565// Close closes the connection to the API service. The user should invoke this when
566// the client is no longer required.
567func (c *gRPCClient) Close() error {
568	return c.connPool.Close()
569}
570
571func (c *gRPCClient) ListConnectionProfiles(ctx context.Context, req *datastreampb.ListConnectionProfilesRequest, opts ...gax.CallOption) *ConnectionProfileIterator {
572	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
573	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
574	opts = append((*c.CallOptions).ListConnectionProfiles[0:len((*c.CallOptions).ListConnectionProfiles):len((*c.CallOptions).ListConnectionProfiles)], opts...)
575	it := &ConnectionProfileIterator{}
576	req = proto.Clone(req).(*datastreampb.ListConnectionProfilesRequest)
577	it.InternalFetch = func(pageSize int, pageToken string) ([]*datastreampb.ConnectionProfile, string, error) {
578		resp := &datastreampb.ListConnectionProfilesResponse{}
579		if pageToken != "" {
580			req.PageToken = pageToken
581		}
582		if pageSize > math.MaxInt32 {
583			req.PageSize = math.MaxInt32
584		} else if pageSize != 0 {
585			req.PageSize = int32(pageSize)
586		}
587		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
588			var err error
589			resp, err = c.client.ListConnectionProfiles(ctx, req, settings.GRPC...)
590			return err
591		}, opts...)
592		if err != nil {
593			return nil, "", err
594		}
595
596		it.Response = resp
597		return resp.GetConnectionProfiles(), resp.GetNextPageToken(), nil
598	}
599	fetch := func(pageSize int, pageToken string) (string, error) {
600		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
601		if err != nil {
602			return "", err
603		}
604		it.items = append(it.items, items...)
605		return nextPageToken, nil
606	}
607
608	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
609	it.pageInfo.MaxSize = int(req.GetPageSize())
610	it.pageInfo.Token = req.GetPageToken()
611
612	return it
613}
614
615func (c *gRPCClient) GetConnectionProfile(ctx context.Context, req *datastreampb.GetConnectionProfileRequest, opts ...gax.CallOption) (*datastreampb.ConnectionProfile, error) {
616	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
617		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
618		defer cancel()
619		ctx = cctx
620	}
621	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
622	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
623	opts = append((*c.CallOptions).GetConnectionProfile[0:len((*c.CallOptions).GetConnectionProfile):len((*c.CallOptions).GetConnectionProfile)], opts...)
624	var resp *datastreampb.ConnectionProfile
625	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
626		var err error
627		resp, err = c.client.GetConnectionProfile(ctx, req, settings.GRPC...)
628		return err
629	}, opts...)
630	if err != nil {
631		return nil, err
632	}
633	return resp, nil
634}
635
636func (c *gRPCClient) CreateConnectionProfile(ctx context.Context, req *datastreampb.CreateConnectionProfileRequest, opts ...gax.CallOption) (*CreateConnectionProfileOperation, error) {
637	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
638		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
639		defer cancel()
640		ctx = cctx
641	}
642	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
643	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
644	opts = append((*c.CallOptions).CreateConnectionProfile[0:len((*c.CallOptions).CreateConnectionProfile):len((*c.CallOptions).CreateConnectionProfile)], opts...)
645	var resp *longrunningpb.Operation
646	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
647		var err error
648		resp, err = c.client.CreateConnectionProfile(ctx, req, settings.GRPC...)
649		return err
650	}, opts...)
651	if err != nil {
652		return nil, err
653	}
654	return &CreateConnectionProfileOperation{
655		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
656	}, nil
657}
658
659func (c *gRPCClient) UpdateConnectionProfile(ctx context.Context, req *datastreampb.UpdateConnectionProfileRequest, opts ...gax.CallOption) (*UpdateConnectionProfileOperation, error) {
660	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
661		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
662		defer cancel()
663		ctx = cctx
664	}
665	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "connection_profile.name", url.QueryEscape(req.GetConnectionProfile().GetName())))
666	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
667	opts = append((*c.CallOptions).UpdateConnectionProfile[0:len((*c.CallOptions).UpdateConnectionProfile):len((*c.CallOptions).UpdateConnectionProfile)], opts...)
668	var resp *longrunningpb.Operation
669	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
670		var err error
671		resp, err = c.client.UpdateConnectionProfile(ctx, req, settings.GRPC...)
672		return err
673	}, opts...)
674	if err != nil {
675		return nil, err
676	}
677	return &UpdateConnectionProfileOperation{
678		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
679	}, nil
680}
681
682func (c *gRPCClient) DeleteConnectionProfile(ctx context.Context, req *datastreampb.DeleteConnectionProfileRequest, opts ...gax.CallOption) (*DeleteConnectionProfileOperation, error) {
683	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
684		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
685		defer cancel()
686		ctx = cctx
687	}
688	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
689	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
690	opts = append((*c.CallOptions).DeleteConnectionProfile[0:len((*c.CallOptions).DeleteConnectionProfile):len((*c.CallOptions).DeleteConnectionProfile)], opts...)
691	var resp *longrunningpb.Operation
692	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
693		var err error
694		resp, err = c.client.DeleteConnectionProfile(ctx, req, settings.GRPC...)
695		return err
696	}, opts...)
697	if err != nil {
698		return nil, err
699	}
700	return &DeleteConnectionProfileOperation{
701		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
702	}, nil
703}
704
705func (c *gRPCClient) DiscoverConnectionProfile(ctx context.Context, req *datastreampb.DiscoverConnectionProfileRequest, opts ...gax.CallOption) (*datastreampb.DiscoverConnectionProfileResponse, error) {
706	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
707		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
708		defer cancel()
709		ctx = cctx
710	}
711	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
712	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
713	opts = append((*c.CallOptions).DiscoverConnectionProfile[0:len((*c.CallOptions).DiscoverConnectionProfile):len((*c.CallOptions).DiscoverConnectionProfile)], opts...)
714	var resp *datastreampb.DiscoverConnectionProfileResponse
715	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
716		var err error
717		resp, err = c.client.DiscoverConnectionProfile(ctx, req, settings.GRPC...)
718		return err
719	}, opts...)
720	if err != nil {
721		return nil, err
722	}
723	return resp, nil
724}
725
726func (c *gRPCClient) ListStreams(ctx context.Context, req *datastreampb.ListStreamsRequest, opts ...gax.CallOption) *StreamIterator {
727	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
728	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
729	opts = append((*c.CallOptions).ListStreams[0:len((*c.CallOptions).ListStreams):len((*c.CallOptions).ListStreams)], opts...)
730	it := &StreamIterator{}
731	req = proto.Clone(req).(*datastreampb.ListStreamsRequest)
732	it.InternalFetch = func(pageSize int, pageToken string) ([]*datastreampb.Stream, string, error) {
733		resp := &datastreampb.ListStreamsResponse{}
734		if pageToken != "" {
735			req.PageToken = pageToken
736		}
737		if pageSize > math.MaxInt32 {
738			req.PageSize = math.MaxInt32
739		} else if pageSize != 0 {
740			req.PageSize = int32(pageSize)
741		}
742		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
743			var err error
744			resp, err = c.client.ListStreams(ctx, req, settings.GRPC...)
745			return err
746		}, opts...)
747		if err != nil {
748			return nil, "", err
749		}
750
751		it.Response = resp
752		return resp.GetStreams(), resp.GetNextPageToken(), nil
753	}
754	fetch := func(pageSize int, pageToken string) (string, error) {
755		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
756		if err != nil {
757			return "", err
758		}
759		it.items = append(it.items, items...)
760		return nextPageToken, nil
761	}
762
763	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
764	it.pageInfo.MaxSize = int(req.GetPageSize())
765	it.pageInfo.Token = req.GetPageToken()
766
767	return it
768}
769
770func (c *gRPCClient) GetStream(ctx context.Context, req *datastreampb.GetStreamRequest, opts ...gax.CallOption) (*datastreampb.Stream, error) {
771	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
772		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
773		defer cancel()
774		ctx = cctx
775	}
776	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
777	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
778	opts = append((*c.CallOptions).GetStream[0:len((*c.CallOptions).GetStream):len((*c.CallOptions).GetStream)], opts...)
779	var resp *datastreampb.Stream
780	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
781		var err error
782		resp, err = c.client.GetStream(ctx, req, settings.GRPC...)
783		return err
784	}, opts...)
785	if err != nil {
786		return nil, err
787	}
788	return resp, nil
789}
790
791func (c *gRPCClient) CreateStream(ctx context.Context, req *datastreampb.CreateStreamRequest, opts ...gax.CallOption) (*CreateStreamOperation, error) {
792	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
793		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
794		defer cancel()
795		ctx = cctx
796	}
797	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
798	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
799	opts = append((*c.CallOptions).CreateStream[0:len((*c.CallOptions).CreateStream):len((*c.CallOptions).CreateStream)], opts...)
800	var resp *longrunningpb.Operation
801	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
802		var err error
803		resp, err = c.client.CreateStream(ctx, req, settings.GRPC...)
804		return err
805	}, opts...)
806	if err != nil {
807		return nil, err
808	}
809	return &CreateStreamOperation{
810		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
811	}, nil
812}
813
814func (c *gRPCClient) UpdateStream(ctx context.Context, req *datastreampb.UpdateStreamRequest, opts ...gax.CallOption) (*UpdateStreamOperation, error) {
815	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
816		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
817		defer cancel()
818		ctx = cctx
819	}
820	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "stream.name", url.QueryEscape(req.GetStream().GetName())))
821	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
822	opts = append((*c.CallOptions).UpdateStream[0:len((*c.CallOptions).UpdateStream):len((*c.CallOptions).UpdateStream)], opts...)
823	var resp *longrunningpb.Operation
824	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
825		var err error
826		resp, err = c.client.UpdateStream(ctx, req, settings.GRPC...)
827		return err
828	}, opts...)
829	if err != nil {
830		return nil, err
831	}
832	return &UpdateStreamOperation{
833		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
834	}, nil
835}
836
837func (c *gRPCClient) DeleteStream(ctx context.Context, req *datastreampb.DeleteStreamRequest, opts ...gax.CallOption) (*DeleteStreamOperation, error) {
838	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
839		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
840		defer cancel()
841		ctx = cctx
842	}
843	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
844	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
845	opts = append((*c.CallOptions).DeleteStream[0:len((*c.CallOptions).DeleteStream):len((*c.CallOptions).DeleteStream)], opts...)
846	var resp *longrunningpb.Operation
847	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
848		var err error
849		resp, err = c.client.DeleteStream(ctx, req, settings.GRPC...)
850		return err
851	}, opts...)
852	if err != nil {
853		return nil, err
854	}
855	return &DeleteStreamOperation{
856		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
857	}, nil
858}
859
860func (c *gRPCClient) FetchErrors(ctx context.Context, req *datastreampb.FetchErrorsRequest, opts ...gax.CallOption) (*FetchErrorsOperation, error) {
861	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
862		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
863		defer cancel()
864		ctx = cctx
865	}
866	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "stream", url.QueryEscape(req.GetStream())))
867	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
868	opts = append((*c.CallOptions).FetchErrors[0:len((*c.CallOptions).FetchErrors):len((*c.CallOptions).FetchErrors)], opts...)
869	var resp *longrunningpb.Operation
870	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
871		var err error
872		resp, err = c.client.FetchErrors(ctx, req, settings.GRPC...)
873		return err
874	}, opts...)
875	if err != nil {
876		return nil, err
877	}
878	return &FetchErrorsOperation{
879		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
880	}, nil
881}
882
883func (c *gRPCClient) FetchStaticIps(ctx context.Context, req *datastreampb.FetchStaticIpsRequest, opts ...gax.CallOption) *StringIterator {
884	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
885	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
886	opts = append((*c.CallOptions).FetchStaticIps[0:len((*c.CallOptions).FetchStaticIps):len((*c.CallOptions).FetchStaticIps)], opts...)
887	it := &StringIterator{}
888	req = proto.Clone(req).(*datastreampb.FetchStaticIpsRequest)
889	it.InternalFetch = func(pageSize int, pageToken string) ([]string, string, error) {
890		resp := &datastreampb.FetchStaticIpsResponse{}
891		if pageToken != "" {
892			req.PageToken = pageToken
893		}
894		if pageSize > math.MaxInt32 {
895			req.PageSize = math.MaxInt32
896		} else if pageSize != 0 {
897			req.PageSize = int32(pageSize)
898		}
899		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
900			var err error
901			resp, err = c.client.FetchStaticIps(ctx, req, settings.GRPC...)
902			return err
903		}, opts...)
904		if err != nil {
905			return nil, "", err
906		}
907
908		it.Response = resp
909		return resp.GetStaticIps(), resp.GetNextPageToken(), nil
910	}
911	fetch := func(pageSize int, pageToken string) (string, error) {
912		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
913		if err != nil {
914			return "", err
915		}
916		it.items = append(it.items, items...)
917		return nextPageToken, nil
918	}
919
920	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
921	it.pageInfo.MaxSize = int(req.GetPageSize())
922	it.pageInfo.Token = req.GetPageToken()
923
924	return it
925}
926
927func (c *gRPCClient) CreatePrivateConnection(ctx context.Context, req *datastreampb.CreatePrivateConnectionRequest, opts ...gax.CallOption) (*CreatePrivateConnectionOperation, error) {
928	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
929		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
930		defer cancel()
931		ctx = cctx
932	}
933	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
934	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
935	opts = append((*c.CallOptions).CreatePrivateConnection[0:len((*c.CallOptions).CreatePrivateConnection):len((*c.CallOptions).CreatePrivateConnection)], opts...)
936	var resp *longrunningpb.Operation
937	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
938		var err error
939		resp, err = c.client.CreatePrivateConnection(ctx, req, settings.GRPC...)
940		return err
941	}, opts...)
942	if err != nil {
943		return nil, err
944	}
945	return &CreatePrivateConnectionOperation{
946		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
947	}, nil
948}
949
950func (c *gRPCClient) GetPrivateConnection(ctx context.Context, req *datastreampb.GetPrivateConnectionRequest, opts ...gax.CallOption) (*datastreampb.PrivateConnection, error) {
951	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
952		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
953		defer cancel()
954		ctx = cctx
955	}
956	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
957	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
958	opts = append((*c.CallOptions).GetPrivateConnection[0:len((*c.CallOptions).GetPrivateConnection):len((*c.CallOptions).GetPrivateConnection)], opts...)
959	var resp *datastreampb.PrivateConnection
960	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
961		var err error
962		resp, err = c.client.GetPrivateConnection(ctx, req, settings.GRPC...)
963		return err
964	}, opts...)
965	if err != nil {
966		return nil, err
967	}
968	return resp, nil
969}
970
971func (c *gRPCClient) ListPrivateConnections(ctx context.Context, req *datastreampb.ListPrivateConnectionsRequest, opts ...gax.CallOption) *PrivateConnectionIterator {
972	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
973	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
974	opts = append((*c.CallOptions).ListPrivateConnections[0:len((*c.CallOptions).ListPrivateConnections):len((*c.CallOptions).ListPrivateConnections)], opts...)
975	it := &PrivateConnectionIterator{}
976	req = proto.Clone(req).(*datastreampb.ListPrivateConnectionsRequest)
977	it.InternalFetch = func(pageSize int, pageToken string) ([]*datastreampb.PrivateConnection, string, error) {
978		resp := &datastreampb.ListPrivateConnectionsResponse{}
979		if pageToken != "" {
980			req.PageToken = pageToken
981		}
982		if pageSize > math.MaxInt32 {
983			req.PageSize = math.MaxInt32
984		} else if pageSize != 0 {
985			req.PageSize = int32(pageSize)
986		}
987		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
988			var err error
989			resp, err = c.client.ListPrivateConnections(ctx, req, settings.GRPC...)
990			return err
991		}, opts...)
992		if err != nil {
993			return nil, "", err
994		}
995
996		it.Response = resp
997		return resp.GetPrivateConnections(), resp.GetNextPageToken(), nil
998	}
999	fetch := func(pageSize int, pageToken string) (string, error) {
1000		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1001		if err != nil {
1002			return "", err
1003		}
1004		it.items = append(it.items, items...)
1005		return nextPageToken, nil
1006	}
1007
1008	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1009	it.pageInfo.MaxSize = int(req.GetPageSize())
1010	it.pageInfo.Token = req.GetPageToken()
1011
1012	return it
1013}
1014
1015func (c *gRPCClient) DeletePrivateConnection(ctx context.Context, req *datastreampb.DeletePrivateConnectionRequest, opts ...gax.CallOption) (*DeletePrivateConnectionOperation, error) {
1016	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1017		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1018		defer cancel()
1019		ctx = cctx
1020	}
1021	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1022	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1023	opts = append((*c.CallOptions).DeletePrivateConnection[0:len((*c.CallOptions).DeletePrivateConnection):len((*c.CallOptions).DeletePrivateConnection)], opts...)
1024	var resp *longrunningpb.Operation
1025	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1026		var err error
1027		resp, err = c.client.DeletePrivateConnection(ctx, req, settings.GRPC...)
1028		return err
1029	}, opts...)
1030	if err != nil {
1031		return nil, err
1032	}
1033	return &DeletePrivateConnectionOperation{
1034		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1035	}, nil
1036}
1037
1038func (c *gRPCClient) CreateRoute(ctx context.Context, req *datastreampb.CreateRouteRequest, opts ...gax.CallOption) (*CreateRouteOperation, error) {
1039	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1040		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1041		defer cancel()
1042		ctx = cctx
1043	}
1044	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
1045	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1046	opts = append((*c.CallOptions).CreateRoute[0:len((*c.CallOptions).CreateRoute):len((*c.CallOptions).CreateRoute)], opts...)
1047	var resp *longrunningpb.Operation
1048	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1049		var err error
1050		resp, err = c.client.CreateRoute(ctx, req, settings.GRPC...)
1051		return err
1052	}, opts...)
1053	if err != nil {
1054		return nil, err
1055	}
1056	return &CreateRouteOperation{
1057		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1058	}, nil
1059}
1060
1061func (c *gRPCClient) GetRoute(ctx context.Context, req *datastreampb.GetRouteRequest, opts ...gax.CallOption) (*datastreampb.Route, error) {
1062	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1063		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1064		defer cancel()
1065		ctx = cctx
1066	}
1067	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1068	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1069	opts = append((*c.CallOptions).GetRoute[0:len((*c.CallOptions).GetRoute):len((*c.CallOptions).GetRoute)], opts...)
1070	var resp *datastreampb.Route
1071	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1072		var err error
1073		resp, err = c.client.GetRoute(ctx, req, settings.GRPC...)
1074		return err
1075	}, opts...)
1076	if err != nil {
1077		return nil, err
1078	}
1079	return resp, nil
1080}
1081
1082func (c *gRPCClient) ListRoutes(ctx context.Context, req *datastreampb.ListRoutesRequest, opts ...gax.CallOption) *RouteIterator {
1083	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
1084	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1085	opts = append((*c.CallOptions).ListRoutes[0:len((*c.CallOptions).ListRoutes):len((*c.CallOptions).ListRoutes)], opts...)
1086	it := &RouteIterator{}
1087	req = proto.Clone(req).(*datastreampb.ListRoutesRequest)
1088	it.InternalFetch = func(pageSize int, pageToken string) ([]*datastreampb.Route, string, error) {
1089		resp := &datastreampb.ListRoutesResponse{}
1090		if pageToken != "" {
1091			req.PageToken = pageToken
1092		}
1093		if pageSize > math.MaxInt32 {
1094			req.PageSize = math.MaxInt32
1095		} else if pageSize != 0 {
1096			req.PageSize = int32(pageSize)
1097		}
1098		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1099			var err error
1100			resp, err = c.client.ListRoutes(ctx, req, settings.GRPC...)
1101			return err
1102		}, opts...)
1103		if err != nil {
1104			return nil, "", err
1105		}
1106
1107		it.Response = resp
1108		return resp.GetRoutes(), resp.GetNextPageToken(), nil
1109	}
1110	fetch := func(pageSize int, pageToken string) (string, error) {
1111		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1112		if err != nil {
1113			return "", err
1114		}
1115		it.items = append(it.items, items...)
1116		return nextPageToken, nil
1117	}
1118
1119	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1120	it.pageInfo.MaxSize = int(req.GetPageSize())
1121	it.pageInfo.Token = req.GetPageToken()
1122
1123	return it
1124}
1125
1126func (c *gRPCClient) DeleteRoute(ctx context.Context, req *datastreampb.DeleteRouteRequest, opts ...gax.CallOption) (*DeleteRouteOperation, error) {
1127	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1128		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1129		defer cancel()
1130		ctx = cctx
1131	}
1132	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1133	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1134	opts = append((*c.CallOptions).DeleteRoute[0:len((*c.CallOptions).DeleteRoute):len((*c.CallOptions).DeleteRoute)], opts...)
1135	var resp *longrunningpb.Operation
1136	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1137		var err error
1138		resp, err = c.client.DeleteRoute(ctx, req, settings.GRPC...)
1139		return err
1140	}, opts...)
1141	if err != nil {
1142		return nil, err
1143	}
1144	return &DeleteRouteOperation{
1145		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1146	}, nil
1147}
1148
1149// CreateConnectionProfileOperation manages a long-running operation from CreateConnectionProfile.
1150type CreateConnectionProfileOperation struct {
1151	lro *longrunning.Operation
1152}
1153
1154// CreateConnectionProfileOperation returns a new CreateConnectionProfileOperation from a given name.
1155// The name must be that of a previously created CreateConnectionProfileOperation, possibly from a different process.
1156func (c *gRPCClient) CreateConnectionProfileOperation(name string) *CreateConnectionProfileOperation {
1157	return &CreateConnectionProfileOperation{
1158		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1159	}
1160}
1161
1162// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1163//
1164// See documentation of Poll for error-handling information.
1165func (op *CreateConnectionProfileOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*datastreampb.ConnectionProfile, error) {
1166	var resp datastreampb.ConnectionProfile
1167	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1168		return nil, err
1169	}
1170	return &resp, nil
1171}
1172
1173// Poll fetches the latest state of the long-running operation.
1174//
1175// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1176//
1177// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1178// the operation has completed with failure, the error is returned and op.Done will return true.
1179// If Poll succeeds and the operation has completed successfully,
1180// op.Done will return true, and the response of the operation is returned.
1181// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1182func (op *CreateConnectionProfileOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*datastreampb.ConnectionProfile, error) {
1183	var resp datastreampb.ConnectionProfile
1184	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1185		return nil, err
1186	}
1187	if !op.Done() {
1188		return nil, nil
1189	}
1190	return &resp, nil
1191}
1192
1193// Metadata returns metadata associated with the long-running operation.
1194// Metadata itself does not contact the server, but Poll does.
1195// To get the latest metadata, call this method after a successful call to Poll.
1196// If the metadata is not available, the returned metadata and error are both nil.
1197func (op *CreateConnectionProfileOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1198	var meta datastreampb.OperationMetadata
1199	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1200		return nil, nil
1201	} else if err != nil {
1202		return nil, err
1203	}
1204	return &meta, nil
1205}
1206
1207// Done reports whether the long-running operation has completed.
1208func (op *CreateConnectionProfileOperation) Done() bool {
1209	return op.lro.Done()
1210}
1211
1212// Name returns the name of the long-running operation.
1213// The name is assigned by the server and is unique within the service from which the operation is created.
1214func (op *CreateConnectionProfileOperation) Name() string {
1215	return op.lro.Name()
1216}
1217
1218// CreatePrivateConnectionOperation manages a long-running operation from CreatePrivateConnection.
1219type CreatePrivateConnectionOperation struct {
1220	lro *longrunning.Operation
1221}
1222
1223// CreatePrivateConnectionOperation returns a new CreatePrivateConnectionOperation from a given name.
1224// The name must be that of a previously created CreatePrivateConnectionOperation, possibly from a different process.
1225func (c *gRPCClient) CreatePrivateConnectionOperation(name string) *CreatePrivateConnectionOperation {
1226	return &CreatePrivateConnectionOperation{
1227		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1228	}
1229}
1230
1231// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1232//
1233// See documentation of Poll for error-handling information.
1234func (op *CreatePrivateConnectionOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*datastreampb.PrivateConnection, error) {
1235	var resp datastreampb.PrivateConnection
1236	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1237		return nil, err
1238	}
1239	return &resp, nil
1240}
1241
1242// Poll fetches the latest state of the long-running operation.
1243//
1244// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1245//
1246// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1247// the operation has completed with failure, the error is returned and op.Done will return true.
1248// If Poll succeeds and the operation has completed successfully,
1249// op.Done will return true, and the response of the operation is returned.
1250// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1251func (op *CreatePrivateConnectionOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*datastreampb.PrivateConnection, error) {
1252	var resp datastreampb.PrivateConnection
1253	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1254		return nil, err
1255	}
1256	if !op.Done() {
1257		return nil, nil
1258	}
1259	return &resp, nil
1260}
1261
1262// Metadata returns metadata associated with the long-running operation.
1263// Metadata itself does not contact the server, but Poll does.
1264// To get the latest metadata, call this method after a successful call to Poll.
1265// If the metadata is not available, the returned metadata and error are both nil.
1266func (op *CreatePrivateConnectionOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1267	var meta datastreampb.OperationMetadata
1268	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1269		return nil, nil
1270	} else if err != nil {
1271		return nil, err
1272	}
1273	return &meta, nil
1274}
1275
1276// Done reports whether the long-running operation has completed.
1277func (op *CreatePrivateConnectionOperation) Done() bool {
1278	return op.lro.Done()
1279}
1280
1281// Name returns the name of the long-running operation.
1282// The name is assigned by the server and is unique within the service from which the operation is created.
1283func (op *CreatePrivateConnectionOperation) Name() string {
1284	return op.lro.Name()
1285}
1286
1287// CreateRouteOperation manages a long-running operation from CreateRoute.
1288type CreateRouteOperation struct {
1289	lro *longrunning.Operation
1290}
1291
1292// CreateRouteOperation returns a new CreateRouteOperation from a given name.
1293// The name must be that of a previously created CreateRouteOperation, possibly from a different process.
1294func (c *gRPCClient) CreateRouteOperation(name string) *CreateRouteOperation {
1295	return &CreateRouteOperation{
1296		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1297	}
1298}
1299
1300// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1301//
1302// See documentation of Poll for error-handling information.
1303func (op *CreateRouteOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*datastreampb.Route, error) {
1304	var resp datastreampb.Route
1305	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1306		return nil, err
1307	}
1308	return &resp, nil
1309}
1310
1311// Poll fetches the latest state of the long-running operation.
1312//
1313// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1314//
1315// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1316// the operation has completed with failure, the error is returned and op.Done will return true.
1317// If Poll succeeds and the operation has completed successfully,
1318// op.Done will return true, and the response of the operation is returned.
1319// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1320func (op *CreateRouteOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*datastreampb.Route, error) {
1321	var resp datastreampb.Route
1322	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1323		return nil, err
1324	}
1325	if !op.Done() {
1326		return nil, nil
1327	}
1328	return &resp, nil
1329}
1330
1331// Metadata returns metadata associated with the long-running operation.
1332// Metadata itself does not contact the server, but Poll does.
1333// To get the latest metadata, call this method after a successful call to Poll.
1334// If the metadata is not available, the returned metadata and error are both nil.
1335func (op *CreateRouteOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1336	var meta datastreampb.OperationMetadata
1337	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1338		return nil, nil
1339	} else if err != nil {
1340		return nil, err
1341	}
1342	return &meta, nil
1343}
1344
1345// Done reports whether the long-running operation has completed.
1346func (op *CreateRouteOperation) Done() bool {
1347	return op.lro.Done()
1348}
1349
1350// Name returns the name of the long-running operation.
1351// The name is assigned by the server and is unique within the service from which the operation is created.
1352func (op *CreateRouteOperation) Name() string {
1353	return op.lro.Name()
1354}
1355
1356// CreateStreamOperation manages a long-running operation from CreateStream.
1357type CreateStreamOperation struct {
1358	lro *longrunning.Operation
1359}
1360
1361// CreateStreamOperation returns a new CreateStreamOperation from a given name.
1362// The name must be that of a previously created CreateStreamOperation, possibly from a different process.
1363func (c *gRPCClient) CreateStreamOperation(name string) *CreateStreamOperation {
1364	return &CreateStreamOperation{
1365		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1366	}
1367}
1368
1369// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1370//
1371// See documentation of Poll for error-handling information.
1372func (op *CreateStreamOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*datastreampb.Stream, error) {
1373	var resp datastreampb.Stream
1374	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1375		return nil, err
1376	}
1377	return &resp, nil
1378}
1379
1380// Poll fetches the latest state of the long-running operation.
1381//
1382// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1383//
1384// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1385// the operation has completed with failure, the error is returned and op.Done will return true.
1386// If Poll succeeds and the operation has completed successfully,
1387// op.Done will return true, and the response of the operation is returned.
1388// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1389func (op *CreateStreamOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*datastreampb.Stream, error) {
1390	var resp datastreampb.Stream
1391	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1392		return nil, err
1393	}
1394	if !op.Done() {
1395		return nil, nil
1396	}
1397	return &resp, nil
1398}
1399
1400// Metadata returns metadata associated with the long-running operation.
1401// Metadata itself does not contact the server, but Poll does.
1402// To get the latest metadata, call this method after a successful call to Poll.
1403// If the metadata is not available, the returned metadata and error are both nil.
1404func (op *CreateStreamOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1405	var meta datastreampb.OperationMetadata
1406	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1407		return nil, nil
1408	} else if err != nil {
1409		return nil, err
1410	}
1411	return &meta, nil
1412}
1413
1414// Done reports whether the long-running operation has completed.
1415func (op *CreateStreamOperation) Done() bool {
1416	return op.lro.Done()
1417}
1418
1419// Name returns the name of the long-running operation.
1420// The name is assigned by the server and is unique within the service from which the operation is created.
1421func (op *CreateStreamOperation) Name() string {
1422	return op.lro.Name()
1423}
1424
1425// DeleteConnectionProfileOperation manages a long-running operation from DeleteConnectionProfile.
1426type DeleteConnectionProfileOperation struct {
1427	lro *longrunning.Operation
1428}
1429
1430// DeleteConnectionProfileOperation returns a new DeleteConnectionProfileOperation from a given name.
1431// The name must be that of a previously created DeleteConnectionProfileOperation, possibly from a different process.
1432func (c *gRPCClient) DeleteConnectionProfileOperation(name string) *DeleteConnectionProfileOperation {
1433	return &DeleteConnectionProfileOperation{
1434		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1435	}
1436}
1437
1438// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1439//
1440// See documentation of Poll for error-handling information.
1441func (op *DeleteConnectionProfileOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
1442	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
1443}
1444
1445// Poll fetches the latest state of the long-running operation.
1446//
1447// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1448//
1449// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1450// the operation has completed with failure, the error is returned and op.Done will return true.
1451// If Poll succeeds and the operation has completed successfully,
1452// op.Done will return true, and the response of the operation is returned.
1453// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1454func (op *DeleteConnectionProfileOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
1455	return op.lro.Poll(ctx, nil, opts...)
1456}
1457
1458// Metadata returns metadata associated with the long-running operation.
1459// Metadata itself does not contact the server, but Poll does.
1460// To get the latest metadata, call this method after a successful call to Poll.
1461// If the metadata is not available, the returned metadata and error are both nil.
1462func (op *DeleteConnectionProfileOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1463	var meta datastreampb.OperationMetadata
1464	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1465		return nil, nil
1466	} else if err != nil {
1467		return nil, err
1468	}
1469	return &meta, nil
1470}
1471
1472// Done reports whether the long-running operation has completed.
1473func (op *DeleteConnectionProfileOperation) Done() bool {
1474	return op.lro.Done()
1475}
1476
1477// Name returns the name of the long-running operation.
1478// The name is assigned by the server and is unique within the service from which the operation is created.
1479func (op *DeleteConnectionProfileOperation) Name() string {
1480	return op.lro.Name()
1481}
1482
1483// DeletePrivateConnectionOperation manages a long-running operation from DeletePrivateConnection.
1484type DeletePrivateConnectionOperation struct {
1485	lro *longrunning.Operation
1486}
1487
1488// DeletePrivateConnectionOperation returns a new DeletePrivateConnectionOperation from a given name.
1489// The name must be that of a previously created DeletePrivateConnectionOperation, possibly from a different process.
1490func (c *gRPCClient) DeletePrivateConnectionOperation(name string) *DeletePrivateConnectionOperation {
1491	return &DeletePrivateConnectionOperation{
1492		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1493	}
1494}
1495
1496// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1497//
1498// See documentation of Poll for error-handling information.
1499func (op *DeletePrivateConnectionOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
1500	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
1501}
1502
1503// Poll fetches the latest state of the long-running operation.
1504//
1505// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1506//
1507// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1508// the operation has completed with failure, the error is returned and op.Done will return true.
1509// If Poll succeeds and the operation has completed successfully,
1510// op.Done will return true, and the response of the operation is returned.
1511// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1512func (op *DeletePrivateConnectionOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
1513	return op.lro.Poll(ctx, nil, opts...)
1514}
1515
1516// Metadata returns metadata associated with the long-running operation.
1517// Metadata itself does not contact the server, but Poll does.
1518// To get the latest metadata, call this method after a successful call to Poll.
1519// If the metadata is not available, the returned metadata and error are both nil.
1520func (op *DeletePrivateConnectionOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1521	var meta datastreampb.OperationMetadata
1522	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1523		return nil, nil
1524	} else if err != nil {
1525		return nil, err
1526	}
1527	return &meta, nil
1528}
1529
1530// Done reports whether the long-running operation has completed.
1531func (op *DeletePrivateConnectionOperation) Done() bool {
1532	return op.lro.Done()
1533}
1534
1535// Name returns the name of the long-running operation.
1536// The name is assigned by the server and is unique within the service from which the operation is created.
1537func (op *DeletePrivateConnectionOperation) Name() string {
1538	return op.lro.Name()
1539}
1540
1541// DeleteRouteOperation manages a long-running operation from DeleteRoute.
1542type DeleteRouteOperation struct {
1543	lro *longrunning.Operation
1544}
1545
1546// DeleteRouteOperation returns a new DeleteRouteOperation from a given name.
1547// The name must be that of a previously created DeleteRouteOperation, possibly from a different process.
1548func (c *gRPCClient) DeleteRouteOperation(name string) *DeleteRouteOperation {
1549	return &DeleteRouteOperation{
1550		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1551	}
1552}
1553
1554// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1555//
1556// See documentation of Poll for error-handling information.
1557func (op *DeleteRouteOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
1558	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
1559}
1560
1561// Poll fetches the latest state of the long-running operation.
1562//
1563// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1564//
1565// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1566// the operation has completed with failure, the error is returned and op.Done will return true.
1567// If Poll succeeds and the operation has completed successfully,
1568// op.Done will return true, and the response of the operation is returned.
1569// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1570func (op *DeleteRouteOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
1571	return op.lro.Poll(ctx, nil, opts...)
1572}
1573
1574// Metadata returns metadata associated with the long-running operation.
1575// Metadata itself does not contact the server, but Poll does.
1576// To get the latest metadata, call this method after a successful call to Poll.
1577// If the metadata is not available, the returned metadata and error are both nil.
1578func (op *DeleteRouteOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1579	var meta datastreampb.OperationMetadata
1580	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1581		return nil, nil
1582	} else if err != nil {
1583		return nil, err
1584	}
1585	return &meta, nil
1586}
1587
1588// Done reports whether the long-running operation has completed.
1589func (op *DeleteRouteOperation) Done() bool {
1590	return op.lro.Done()
1591}
1592
1593// Name returns the name of the long-running operation.
1594// The name is assigned by the server and is unique within the service from which the operation is created.
1595func (op *DeleteRouteOperation) Name() string {
1596	return op.lro.Name()
1597}
1598
1599// DeleteStreamOperation manages a long-running operation from DeleteStream.
1600type DeleteStreamOperation struct {
1601	lro *longrunning.Operation
1602}
1603
1604// DeleteStreamOperation returns a new DeleteStreamOperation from a given name.
1605// The name must be that of a previously created DeleteStreamOperation, possibly from a different process.
1606func (c *gRPCClient) DeleteStreamOperation(name string) *DeleteStreamOperation {
1607	return &DeleteStreamOperation{
1608		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1609	}
1610}
1611
1612// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1613//
1614// See documentation of Poll for error-handling information.
1615func (op *DeleteStreamOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
1616	return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
1617}
1618
1619// Poll fetches the latest state of the long-running operation.
1620//
1621// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1622//
1623// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1624// the operation has completed with failure, the error is returned and op.Done will return true.
1625// If Poll succeeds and the operation has completed successfully,
1626// op.Done will return true, and the response of the operation is returned.
1627// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1628func (op *DeleteStreamOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
1629	return op.lro.Poll(ctx, nil, opts...)
1630}
1631
1632// Metadata returns metadata associated with the long-running operation.
1633// Metadata itself does not contact the server, but Poll does.
1634// To get the latest metadata, call this method after a successful call to Poll.
1635// If the metadata is not available, the returned metadata and error are both nil.
1636func (op *DeleteStreamOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1637	var meta datastreampb.OperationMetadata
1638	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1639		return nil, nil
1640	} else if err != nil {
1641		return nil, err
1642	}
1643	return &meta, nil
1644}
1645
1646// Done reports whether the long-running operation has completed.
1647func (op *DeleteStreamOperation) Done() bool {
1648	return op.lro.Done()
1649}
1650
1651// Name returns the name of the long-running operation.
1652// The name is assigned by the server and is unique within the service from which the operation is created.
1653func (op *DeleteStreamOperation) Name() string {
1654	return op.lro.Name()
1655}
1656
1657// FetchErrorsOperation manages a long-running operation from FetchErrors.
1658type FetchErrorsOperation struct {
1659	lro *longrunning.Operation
1660}
1661
1662// FetchErrorsOperation returns a new FetchErrorsOperation from a given name.
1663// The name must be that of a previously created FetchErrorsOperation, possibly from a different process.
1664func (c *gRPCClient) FetchErrorsOperation(name string) *FetchErrorsOperation {
1665	return &FetchErrorsOperation{
1666		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1667	}
1668}
1669
1670// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1671//
1672// See documentation of Poll for error-handling information.
1673func (op *FetchErrorsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*datastreampb.FetchErrorsResponse, error) {
1674	var resp datastreampb.FetchErrorsResponse
1675	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1676		return nil, err
1677	}
1678	return &resp, nil
1679}
1680
1681// Poll fetches the latest state of the long-running operation.
1682//
1683// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1684//
1685// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1686// the operation has completed with failure, the error is returned and op.Done will return true.
1687// If Poll succeeds and the operation has completed successfully,
1688// op.Done will return true, and the response of the operation is returned.
1689// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1690func (op *FetchErrorsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*datastreampb.FetchErrorsResponse, error) {
1691	var resp datastreampb.FetchErrorsResponse
1692	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1693		return nil, err
1694	}
1695	if !op.Done() {
1696		return nil, nil
1697	}
1698	return &resp, nil
1699}
1700
1701// Metadata returns metadata associated with the long-running operation.
1702// Metadata itself does not contact the server, but Poll does.
1703// To get the latest metadata, call this method after a successful call to Poll.
1704// If the metadata is not available, the returned metadata and error are both nil.
1705func (op *FetchErrorsOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1706	var meta datastreampb.OperationMetadata
1707	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1708		return nil, nil
1709	} else if err != nil {
1710		return nil, err
1711	}
1712	return &meta, nil
1713}
1714
1715// Done reports whether the long-running operation has completed.
1716func (op *FetchErrorsOperation) Done() bool {
1717	return op.lro.Done()
1718}
1719
1720// Name returns the name of the long-running operation.
1721// The name is assigned by the server and is unique within the service from which the operation is created.
1722func (op *FetchErrorsOperation) Name() string {
1723	return op.lro.Name()
1724}
1725
1726// UpdateConnectionProfileOperation manages a long-running operation from UpdateConnectionProfile.
1727type UpdateConnectionProfileOperation struct {
1728	lro *longrunning.Operation
1729}
1730
1731// UpdateConnectionProfileOperation returns a new UpdateConnectionProfileOperation from a given name.
1732// The name must be that of a previously created UpdateConnectionProfileOperation, possibly from a different process.
1733func (c *gRPCClient) UpdateConnectionProfileOperation(name string) *UpdateConnectionProfileOperation {
1734	return &UpdateConnectionProfileOperation{
1735		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1736	}
1737}
1738
1739// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1740//
1741// See documentation of Poll for error-handling information.
1742func (op *UpdateConnectionProfileOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*datastreampb.ConnectionProfile, error) {
1743	var resp datastreampb.ConnectionProfile
1744	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1745		return nil, err
1746	}
1747	return &resp, nil
1748}
1749
1750// Poll fetches the latest state of the long-running operation.
1751//
1752// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1753//
1754// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1755// the operation has completed with failure, the error is returned and op.Done will return true.
1756// If Poll succeeds and the operation has completed successfully,
1757// op.Done will return true, and the response of the operation is returned.
1758// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1759func (op *UpdateConnectionProfileOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*datastreampb.ConnectionProfile, error) {
1760	var resp datastreampb.ConnectionProfile
1761	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1762		return nil, err
1763	}
1764	if !op.Done() {
1765		return nil, nil
1766	}
1767	return &resp, nil
1768}
1769
1770// Metadata returns metadata associated with the long-running operation.
1771// Metadata itself does not contact the server, but Poll does.
1772// To get the latest metadata, call this method after a successful call to Poll.
1773// If the metadata is not available, the returned metadata and error are both nil.
1774func (op *UpdateConnectionProfileOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1775	var meta datastreampb.OperationMetadata
1776	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1777		return nil, nil
1778	} else if err != nil {
1779		return nil, err
1780	}
1781	return &meta, nil
1782}
1783
1784// Done reports whether the long-running operation has completed.
1785func (op *UpdateConnectionProfileOperation) Done() bool {
1786	return op.lro.Done()
1787}
1788
1789// Name returns the name of the long-running operation.
1790// The name is assigned by the server and is unique within the service from which the operation is created.
1791func (op *UpdateConnectionProfileOperation) Name() string {
1792	return op.lro.Name()
1793}
1794
1795// UpdateStreamOperation manages a long-running operation from UpdateStream.
1796type UpdateStreamOperation struct {
1797	lro *longrunning.Operation
1798}
1799
1800// UpdateStreamOperation returns a new UpdateStreamOperation from a given name.
1801// The name must be that of a previously created UpdateStreamOperation, possibly from a different process.
1802func (c *gRPCClient) UpdateStreamOperation(name string) *UpdateStreamOperation {
1803	return &UpdateStreamOperation{
1804		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1805	}
1806}
1807
1808// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
1809//
1810// See documentation of Poll for error-handling information.
1811func (op *UpdateStreamOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*datastreampb.Stream, error) {
1812	var resp datastreampb.Stream
1813	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
1814		return nil, err
1815	}
1816	return &resp, nil
1817}
1818
1819// Poll fetches the latest state of the long-running operation.
1820//
1821// Poll also fetches the latest metadata, which can be retrieved by Metadata.
1822//
1823// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
1824// the operation has completed with failure, the error is returned and op.Done will return true.
1825// If Poll succeeds and the operation has completed successfully,
1826// op.Done will return true, and the response of the operation is returned.
1827// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
1828func (op *UpdateStreamOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*datastreampb.Stream, error) {
1829	var resp datastreampb.Stream
1830	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
1831		return nil, err
1832	}
1833	if !op.Done() {
1834		return nil, nil
1835	}
1836	return &resp, nil
1837}
1838
1839// Metadata returns metadata associated with the long-running operation.
1840// Metadata itself does not contact the server, but Poll does.
1841// To get the latest metadata, call this method after a successful call to Poll.
1842// If the metadata is not available, the returned metadata and error are both nil.
1843func (op *UpdateStreamOperation) Metadata() (*datastreampb.OperationMetadata, error) {
1844	var meta datastreampb.OperationMetadata
1845	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
1846		return nil, nil
1847	} else if err != nil {
1848		return nil, err
1849	}
1850	return &meta, nil
1851}
1852
1853// Done reports whether the long-running operation has completed.
1854func (op *UpdateStreamOperation) Done() bool {
1855	return op.lro.Done()
1856}
1857
1858// Name returns the name of the long-running operation.
1859// The name is assigned by the server and is unique within the service from which the operation is created.
1860func (op *UpdateStreamOperation) Name() string {
1861	return op.lro.Name()
1862}
1863
1864// ConnectionProfileIterator manages a stream of *datastreampb.ConnectionProfile.
1865type ConnectionProfileIterator struct {
1866	items    []*datastreampb.ConnectionProfile
1867	pageInfo *iterator.PageInfo
1868	nextFunc func() error
1869
1870	// Response is the raw response for the current page.
1871	// It must be cast to the RPC response type.
1872	// Calling Next() or InternalFetch() updates this value.
1873	Response interface{}
1874
1875	// InternalFetch is for use by the Google Cloud Libraries only.
1876	// It is not part of the stable interface of this package.
1877	//
1878	// InternalFetch returns results from a single call to the underlying RPC.
1879	// The number of results is no greater than pageSize.
1880	// If there are no more results, nextPageToken is empty and err is nil.
1881	InternalFetch func(pageSize int, pageToken string) (results []*datastreampb.ConnectionProfile, nextPageToken string, err error)
1882}
1883
1884// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1885func (it *ConnectionProfileIterator) PageInfo() *iterator.PageInfo {
1886	return it.pageInfo
1887}
1888
1889// Next returns the next result. Its second return value is iterator.Done if there are no more
1890// results. Once Next returns Done, all subsequent calls will return Done.
1891func (it *ConnectionProfileIterator) Next() (*datastreampb.ConnectionProfile, error) {
1892	var item *datastreampb.ConnectionProfile
1893	if err := it.nextFunc(); err != nil {
1894		return item, err
1895	}
1896	item = it.items[0]
1897	it.items = it.items[1:]
1898	return item, nil
1899}
1900
1901func (it *ConnectionProfileIterator) bufLen() int {
1902	return len(it.items)
1903}
1904
1905func (it *ConnectionProfileIterator) takeBuf() interface{} {
1906	b := it.items
1907	it.items = nil
1908	return b
1909}
1910
1911// PrivateConnectionIterator manages a stream of *datastreampb.PrivateConnection.
1912type PrivateConnectionIterator struct {
1913	items    []*datastreampb.PrivateConnection
1914	pageInfo *iterator.PageInfo
1915	nextFunc func() error
1916
1917	// Response is the raw response for the current page.
1918	// It must be cast to the RPC response type.
1919	// Calling Next() or InternalFetch() updates this value.
1920	Response interface{}
1921
1922	// InternalFetch is for use by the Google Cloud Libraries only.
1923	// It is not part of the stable interface of this package.
1924	//
1925	// InternalFetch returns results from a single call to the underlying RPC.
1926	// The number of results is no greater than pageSize.
1927	// If there are no more results, nextPageToken is empty and err is nil.
1928	InternalFetch func(pageSize int, pageToken string) (results []*datastreampb.PrivateConnection, nextPageToken string, err error)
1929}
1930
1931// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1932func (it *PrivateConnectionIterator) PageInfo() *iterator.PageInfo {
1933	return it.pageInfo
1934}
1935
1936// Next returns the next result. Its second return value is iterator.Done if there are no more
1937// results. Once Next returns Done, all subsequent calls will return Done.
1938func (it *PrivateConnectionIterator) Next() (*datastreampb.PrivateConnection, error) {
1939	var item *datastreampb.PrivateConnection
1940	if err := it.nextFunc(); err != nil {
1941		return item, err
1942	}
1943	item = it.items[0]
1944	it.items = it.items[1:]
1945	return item, nil
1946}
1947
1948func (it *PrivateConnectionIterator) bufLen() int {
1949	return len(it.items)
1950}
1951
1952func (it *PrivateConnectionIterator) takeBuf() interface{} {
1953	b := it.items
1954	it.items = nil
1955	return b
1956}
1957
1958// RouteIterator manages a stream of *datastreampb.Route.
1959type RouteIterator struct {
1960	items    []*datastreampb.Route
1961	pageInfo *iterator.PageInfo
1962	nextFunc func() error
1963
1964	// Response is the raw response for the current page.
1965	// It must be cast to the RPC response type.
1966	// Calling Next() or InternalFetch() updates this value.
1967	Response interface{}
1968
1969	// InternalFetch is for use by the Google Cloud Libraries only.
1970	// It is not part of the stable interface of this package.
1971	//
1972	// InternalFetch returns results from a single call to the underlying RPC.
1973	// The number of results is no greater than pageSize.
1974	// If there are no more results, nextPageToken is empty and err is nil.
1975	InternalFetch func(pageSize int, pageToken string) (results []*datastreampb.Route, nextPageToken string, err error)
1976}
1977
1978// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1979func (it *RouteIterator) PageInfo() *iterator.PageInfo {
1980	return it.pageInfo
1981}
1982
1983// Next returns the next result. Its second return value is iterator.Done if there are no more
1984// results. Once Next returns Done, all subsequent calls will return Done.
1985func (it *RouteIterator) Next() (*datastreampb.Route, error) {
1986	var item *datastreampb.Route
1987	if err := it.nextFunc(); err != nil {
1988		return item, err
1989	}
1990	item = it.items[0]
1991	it.items = it.items[1:]
1992	return item, nil
1993}
1994
1995func (it *RouteIterator) bufLen() int {
1996	return len(it.items)
1997}
1998
1999func (it *RouteIterator) takeBuf() interface{} {
2000	b := it.items
2001	it.items = nil
2002	return b
2003}
2004
2005// StreamIterator manages a stream of *datastreampb.Stream.
2006type StreamIterator struct {
2007	items    []*datastreampb.Stream
2008	pageInfo *iterator.PageInfo
2009	nextFunc func() error
2010
2011	// Response is the raw response for the current page.
2012	// It must be cast to the RPC response type.
2013	// Calling Next() or InternalFetch() updates this value.
2014	Response interface{}
2015
2016	// InternalFetch is for use by the Google Cloud Libraries only.
2017	// It is not part of the stable interface of this package.
2018	//
2019	// InternalFetch returns results from a single call to the underlying RPC.
2020	// The number of results is no greater than pageSize.
2021	// If there are no more results, nextPageToken is empty and err is nil.
2022	InternalFetch func(pageSize int, pageToken string) (results []*datastreampb.Stream, nextPageToken string, err error)
2023}
2024
2025// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
2026func (it *StreamIterator) PageInfo() *iterator.PageInfo {
2027	return it.pageInfo
2028}
2029
2030// Next returns the next result. Its second return value is iterator.Done if there are no more
2031// results. Once Next returns Done, all subsequent calls will return Done.
2032func (it *StreamIterator) Next() (*datastreampb.Stream, error) {
2033	var item *datastreampb.Stream
2034	if err := it.nextFunc(); err != nil {
2035		return item, err
2036	}
2037	item = it.items[0]
2038	it.items = it.items[1:]
2039	return item, nil
2040}
2041
2042func (it *StreamIterator) bufLen() int {
2043	return len(it.items)
2044}
2045
2046func (it *StreamIterator) takeBuf() interface{} {
2047	b := it.items
2048	it.items = nil
2049	return b
2050}
2051
2052// StringIterator manages a stream of string.
2053type StringIterator struct {
2054	items    []string
2055	pageInfo *iterator.PageInfo
2056	nextFunc func() error
2057
2058	// Response is the raw response for the current page.
2059	// It must be cast to the RPC response type.
2060	// Calling Next() or InternalFetch() updates this value.
2061	Response interface{}
2062
2063	// InternalFetch is for use by the Google Cloud Libraries only.
2064	// It is not part of the stable interface of this package.
2065	//
2066	// InternalFetch returns results from a single call to the underlying RPC.
2067	// The number of results is no greater than pageSize.
2068	// If there are no more results, nextPageToken is empty and err is nil.
2069	InternalFetch func(pageSize int, pageToken string) (results []string, nextPageToken string, err error)
2070}
2071
2072// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
2073func (it *StringIterator) PageInfo() *iterator.PageInfo {
2074	return it.pageInfo
2075}
2076
2077// Next returns the next result. Its second return value is iterator.Done if there are no more
2078// results. Once Next returns Done, all subsequent calls will return Done.
2079func (it *StringIterator) Next() (string, error) {
2080	var item string
2081	if err := it.nextFunc(); err != nil {
2082		return item, err
2083	}
2084	item = it.items[0]
2085	it.items = it.items[1:]
2086	return item, nil
2087}
2088
2089func (it *StringIterator) bufLen() int {
2090	return len(it.items)
2091}
2092
2093func (it *StringIterator) takeBuf() interface{} {
2094	b := it.items
2095	it.items = nil
2096	return b
2097}
2098