1// Copyright 2019 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 gapic-generator. DO NOT EDIT.
16
17package translate
18
19import (
20	"context"
21	"fmt"
22	"math"
23	"net/url"
24	"time"
25
26	"cloud.google.com/go/longrunning"
27	lroauto "cloud.google.com/go/longrunning/autogen"
28	"github.com/golang/protobuf/proto"
29	gax "github.com/googleapis/gax-go/v2"
30	"google.golang.org/api/iterator"
31	"google.golang.org/api/option"
32	"google.golang.org/api/transport"
33	translatepb "google.golang.org/genproto/googleapis/cloud/translate/v3"
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)
39
40// TranslationCallOptions contains the retry settings for each method of TranslationClient.
41type TranslationCallOptions struct {
42	TranslateText         []gax.CallOption
43	DetectLanguage        []gax.CallOption
44	GetSupportedLanguages []gax.CallOption
45	BatchTranslateText    []gax.CallOption
46	CreateGlossary        []gax.CallOption
47	ListGlossaries        []gax.CallOption
48	GetGlossary           []gax.CallOption
49	DeleteGlossary        []gax.CallOption
50}
51
52func defaultTranslationClientOptions() []option.ClientOption {
53	return []option.ClientOption{
54		option.WithEndpoint("translate.googleapis.com:443"),
55		option.WithScopes(DefaultAuthScopes()...),
56		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
57			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
58	}
59}
60
61func defaultTranslationCallOptions() *TranslationCallOptions {
62	retry := map[[2]string][]gax.CallOption{
63		{"default", "idempotent"}: {
64			gax.WithRetry(func() gax.Retryer {
65				return gax.OnCodes([]codes.Code{
66					codes.DeadlineExceeded,
67					codes.Unavailable,
68				}, gax.Backoff{
69					Initial:    100 * time.Millisecond,
70					Max:        60000 * time.Millisecond,
71					Multiplier: 1.3,
72				})
73			}),
74		},
75	}
76	return &TranslationCallOptions{
77		TranslateText:         retry[[2]string{"default", "non_idempotent"}],
78		DetectLanguage:        retry[[2]string{"default", "non_idempotent"}],
79		GetSupportedLanguages: retry[[2]string{"default", "idempotent"}],
80		BatchTranslateText:    retry[[2]string{"default", "non_idempotent"}],
81		CreateGlossary:        retry[[2]string{"default", "non_idempotent"}],
82		ListGlossaries:        retry[[2]string{"default", "idempotent"}],
83		GetGlossary:           retry[[2]string{"default", "idempotent"}],
84		DeleteGlossary:        retry[[2]string{"default", "non_idempotent"}],
85	}
86}
87
88// TranslationClient is a client for interacting with Cloud Translation API.
89//
90// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
91type TranslationClient struct {
92	// The connection to the service.
93	conn *grpc.ClientConn
94
95	// The gRPC API client.
96	translationClient translatepb.TranslationServiceClient
97
98	// LROClient is used internally to handle longrunning operations.
99	// It is exposed so that its CallOptions can be modified if required.
100	// Users should not Close this client.
101	LROClient *lroauto.OperationsClient
102
103	// The call options for this service.
104	CallOptions *TranslationCallOptions
105
106	// The x-goog-* metadata to be sent with each request.
107	xGoogMetadata metadata.MD
108}
109
110// NewTranslationClient creates a new translation service client.
111//
112// Provides natural language translation operations.
113func NewTranslationClient(ctx context.Context, opts ...option.ClientOption) (*TranslationClient, error) {
114	conn, err := transport.DialGRPC(ctx, append(defaultTranslationClientOptions(), opts...)...)
115	if err != nil {
116		return nil, err
117	}
118	c := &TranslationClient{
119		conn:        conn,
120		CallOptions: defaultTranslationCallOptions(),
121
122		translationClient: translatepb.NewTranslationServiceClient(conn),
123	}
124	c.setGoogleClientInfo()
125
126	c.LROClient, err = lroauto.NewOperationsClient(ctx, option.WithGRPCConn(conn))
127	if err != nil {
128		// This error "should not happen", since we are just reusing old connection
129		// and never actually need to dial.
130		// If this does happen, we could leak conn. However, we cannot close conn:
131		// If the user invoked the function with option.WithGRPCConn,
132		// we would close a connection that's still in use.
133		// TODO(pongad): investigate error conditions.
134		return nil, err
135	}
136	return c, nil
137}
138
139// Connection returns the client's connection to the API service.
140func (c *TranslationClient) Connection() *grpc.ClientConn {
141	return c.conn
142}
143
144// Close closes the connection to the API service. The user should invoke this when
145// the client is no longer required.
146func (c *TranslationClient) Close() error {
147	return c.conn.Close()
148}
149
150// setGoogleClientInfo sets the name and version of the application in
151// the `x-goog-api-client` header passed on each request. Intended for
152// use by Google-written clients.
153func (c *TranslationClient) setGoogleClientInfo(keyval ...string) {
154	kv := append([]string{"gl-go", versionGo()}, keyval...)
155	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
156	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
157}
158
159// TranslateText translates input text and returns translated text.
160func (c *TranslationClient) TranslateText(ctx context.Context, req *translatepb.TranslateTextRequest, opts ...gax.CallOption) (*translatepb.TranslateTextResponse, error) {
161	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
162	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
163	opts = append(c.CallOptions.TranslateText[0:len(c.CallOptions.TranslateText):len(c.CallOptions.TranslateText)], opts...)
164	var resp *translatepb.TranslateTextResponse
165	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
166		var err error
167		resp, err = c.translationClient.TranslateText(ctx, req, settings.GRPC...)
168		return err
169	}, opts...)
170	if err != nil {
171		return nil, err
172	}
173	return resp, nil
174}
175
176// DetectLanguage detects the language of text within a request.
177func (c *TranslationClient) DetectLanguage(ctx context.Context, req *translatepb.DetectLanguageRequest, opts ...gax.CallOption) (*translatepb.DetectLanguageResponse, error) {
178	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
179	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
180	opts = append(c.CallOptions.DetectLanguage[0:len(c.CallOptions.DetectLanguage):len(c.CallOptions.DetectLanguage)], opts...)
181	var resp *translatepb.DetectLanguageResponse
182	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
183		var err error
184		resp, err = c.translationClient.DetectLanguage(ctx, req, settings.GRPC...)
185		return err
186	}, opts...)
187	if err != nil {
188		return nil, err
189	}
190	return resp, nil
191}
192
193// GetSupportedLanguages returns a list of supported languages for translation.
194func (c *TranslationClient) GetSupportedLanguages(ctx context.Context, req *translatepb.GetSupportedLanguagesRequest, opts ...gax.CallOption) (*translatepb.SupportedLanguages, error) {
195	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
196	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
197	opts = append(c.CallOptions.GetSupportedLanguages[0:len(c.CallOptions.GetSupportedLanguages):len(c.CallOptions.GetSupportedLanguages)], opts...)
198	var resp *translatepb.SupportedLanguages
199	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
200		var err error
201		resp, err = c.translationClient.GetSupportedLanguages(ctx, req, settings.GRPC...)
202		return err
203	}, opts...)
204	if err != nil {
205		return nil, err
206	}
207	return resp, nil
208}
209
210// BatchTranslateText translates a large volume of text in asynchronous batch mode.
211// This function provides real-time output as the inputs are being processed.
212// If caller cancels a request, the partial results (for an input file, it's
213// all or nothing) may still be available on the specified output location.
214//
215// This call returns immediately and you can
216// use google.longrunning.Operation.name to poll the status of the call.
217func (c *TranslationClient) BatchTranslateText(ctx context.Context, req *translatepb.BatchTranslateTextRequest, opts ...gax.CallOption) (*BatchTranslateTextOperation, error) {
218	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
219	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
220	opts = append(c.CallOptions.BatchTranslateText[0:len(c.CallOptions.BatchTranslateText):len(c.CallOptions.BatchTranslateText)], opts...)
221	var resp *longrunningpb.Operation
222	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
223		var err error
224		resp, err = c.translationClient.BatchTranslateText(ctx, req, settings.GRPC...)
225		return err
226	}, opts...)
227	if err != nil {
228		return nil, err
229	}
230	return &BatchTranslateTextOperation{
231		lro: longrunning.InternalNewOperation(c.LROClient, resp),
232	}, nil
233}
234
235// CreateGlossary creates a glossary and returns the long-running operation. Returns
236// NOT_FOUND, if the project doesn't exist.
237func (c *TranslationClient) CreateGlossary(ctx context.Context, req *translatepb.CreateGlossaryRequest, opts ...gax.CallOption) (*CreateGlossaryOperation, error) {
238	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
239	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
240	opts = append(c.CallOptions.CreateGlossary[0:len(c.CallOptions.CreateGlossary):len(c.CallOptions.CreateGlossary)], opts...)
241	var resp *longrunningpb.Operation
242	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
243		var err error
244		resp, err = c.translationClient.CreateGlossary(ctx, req, settings.GRPC...)
245		return err
246	}, opts...)
247	if err != nil {
248		return nil, err
249	}
250	return &CreateGlossaryOperation{
251		lro: longrunning.InternalNewOperation(c.LROClient, resp),
252	}, nil
253}
254
255// ListGlossaries lists glossaries in a project. Returns NOT_FOUND, if the project doesn't
256// exist.
257func (c *TranslationClient) ListGlossaries(ctx context.Context, req *translatepb.ListGlossariesRequest, opts ...gax.CallOption) *GlossaryIterator {
258	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
259	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
260	opts = append(c.CallOptions.ListGlossaries[0:len(c.CallOptions.ListGlossaries):len(c.CallOptions.ListGlossaries)], opts...)
261	it := &GlossaryIterator{}
262	req = proto.Clone(req).(*translatepb.ListGlossariesRequest)
263	it.InternalFetch = func(pageSize int, pageToken string) ([]*translatepb.Glossary, string, error) {
264		var resp *translatepb.ListGlossariesResponse
265		req.PageToken = pageToken
266		if pageSize > math.MaxInt32 {
267			req.PageSize = math.MaxInt32
268		} else {
269			req.PageSize = int32(pageSize)
270		}
271		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
272			var err error
273			resp, err = c.translationClient.ListGlossaries(ctx, req, settings.GRPC...)
274			return err
275		}, opts...)
276		if err != nil {
277			return nil, "", err
278		}
279		return resp.Glossaries, resp.NextPageToken, nil
280	}
281	fetch := func(pageSize int, pageToken string) (string, error) {
282		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
283		if err != nil {
284			return "", err
285		}
286		it.items = append(it.items, items...)
287		return nextPageToken, nil
288	}
289	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
290	it.pageInfo.MaxSize = int(req.PageSize)
291	it.pageInfo.Token = req.PageToken
292	return it
293}
294
295// GetGlossary gets a glossary. Returns NOT_FOUND, if the glossary doesn't
296// exist.
297func (c *TranslationClient) GetGlossary(ctx context.Context, req *translatepb.GetGlossaryRequest, opts ...gax.CallOption) (*translatepb.Glossary, error) {
298	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
299	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
300	opts = append(c.CallOptions.GetGlossary[0:len(c.CallOptions.GetGlossary):len(c.CallOptions.GetGlossary)], opts...)
301	var resp *translatepb.Glossary
302	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
303		var err error
304		resp, err = c.translationClient.GetGlossary(ctx, req, settings.GRPC...)
305		return err
306	}, opts...)
307	if err != nil {
308		return nil, err
309	}
310	return resp, nil
311}
312
313// DeleteGlossary deletes a glossary, or cancels glossary construction
314// if the glossary isn't created yet.
315// Returns NOT_FOUND, if the glossary doesn't exist.
316func (c *TranslationClient) DeleteGlossary(ctx context.Context, req *translatepb.DeleteGlossaryRequest, opts ...gax.CallOption) (*DeleteGlossaryOperation, error) {
317	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
318	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
319	opts = append(c.CallOptions.DeleteGlossary[0:len(c.CallOptions.DeleteGlossary):len(c.CallOptions.DeleteGlossary)], opts...)
320	var resp *longrunningpb.Operation
321	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
322		var err error
323		resp, err = c.translationClient.DeleteGlossary(ctx, req, settings.GRPC...)
324		return err
325	}, opts...)
326	if err != nil {
327		return nil, err
328	}
329	return &DeleteGlossaryOperation{
330		lro: longrunning.InternalNewOperation(c.LROClient, resp),
331	}, nil
332}
333
334// GlossaryIterator manages a stream of *translatepb.Glossary.
335type GlossaryIterator struct {
336	items    []*translatepb.Glossary
337	pageInfo *iterator.PageInfo
338	nextFunc func() error
339
340	// InternalFetch is for use by the Google Cloud Libraries only.
341	// It is not part of the stable interface of this package.
342	//
343	// InternalFetch returns results from a single call to the underlying RPC.
344	// The number of results is no greater than pageSize.
345	// If there are no more results, nextPageToken is empty and err is nil.
346	InternalFetch func(pageSize int, pageToken string) (results []*translatepb.Glossary, nextPageToken string, err error)
347}
348
349// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
350func (it *GlossaryIterator) PageInfo() *iterator.PageInfo {
351	return it.pageInfo
352}
353
354// Next returns the next result. Its second return value is iterator.Done if there are no more
355// results. Once Next returns Done, all subsequent calls will return Done.
356func (it *GlossaryIterator) Next() (*translatepb.Glossary, error) {
357	var item *translatepb.Glossary
358	if err := it.nextFunc(); err != nil {
359		return item, err
360	}
361	item = it.items[0]
362	it.items = it.items[1:]
363	return item, nil
364}
365
366func (it *GlossaryIterator) bufLen() int {
367	return len(it.items)
368}
369
370func (it *GlossaryIterator) takeBuf() interface{} {
371	b := it.items
372	it.items = nil
373	return b
374}
375
376// BatchTranslateTextOperation manages a long-running operation from BatchTranslateText.
377type BatchTranslateTextOperation struct {
378	lro *longrunning.Operation
379}
380
381// BatchTranslateTextOperation returns a new BatchTranslateTextOperation from a given name.
382// The name must be that of a previously created BatchTranslateTextOperation, possibly from a different process.
383func (c *TranslationClient) BatchTranslateTextOperation(name string) *BatchTranslateTextOperation {
384	return &BatchTranslateTextOperation{
385		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
386	}
387}
388
389// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
390//
391// See documentation of Poll for error-handling information.
392func (op *BatchTranslateTextOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.BatchTranslateResponse, error) {
393	var resp translatepb.BatchTranslateResponse
394	if err := op.lro.WaitWithInterval(ctx, &resp, 5000*time.Millisecond, opts...); err != nil {
395		return nil, err
396	}
397	return &resp, nil
398}
399
400// Poll fetches the latest state of the long-running operation.
401//
402// Poll also fetches the latest metadata, which can be retrieved by Metadata.
403//
404// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
405// the operation has completed with failure, the error is returned and op.Done will return true.
406// If Poll succeeds and the operation has completed successfully,
407// op.Done will return true, and the response of the operation is returned.
408// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
409func (op *BatchTranslateTextOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.BatchTranslateResponse, error) {
410	var resp translatepb.BatchTranslateResponse
411	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
412		return nil, err
413	}
414	if !op.Done() {
415		return nil, nil
416	}
417	return &resp, nil
418}
419
420// Metadata returns metadata associated with the long-running operation.
421// Metadata itself does not contact the server, but Poll does.
422// To get the latest metadata, call this method after a successful call to Poll.
423// If the metadata is not available, the returned metadata and error are both nil.
424func (op *BatchTranslateTextOperation) Metadata() (*translatepb.BatchTranslateMetadata, error) {
425	var meta translatepb.BatchTranslateMetadata
426	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
427		return nil, nil
428	} else if err != nil {
429		return nil, err
430	}
431	return &meta, nil
432}
433
434// Done reports whether the long-running operation has completed.
435func (op *BatchTranslateTextOperation) Done() bool {
436	return op.lro.Done()
437}
438
439// Name returns the name of the long-running operation.
440// The name is assigned by the server and is unique within the service from which the operation is created.
441func (op *BatchTranslateTextOperation) Name() string {
442	return op.lro.Name()
443}
444
445// CreateGlossaryOperation manages a long-running operation from CreateGlossary.
446type CreateGlossaryOperation struct {
447	lro *longrunning.Operation
448}
449
450// CreateGlossaryOperation returns a new CreateGlossaryOperation from a given name.
451// The name must be that of a previously created CreateGlossaryOperation, possibly from a different process.
452func (c *TranslationClient) CreateGlossaryOperation(name string) *CreateGlossaryOperation {
453	return &CreateGlossaryOperation{
454		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
455	}
456}
457
458// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
459//
460// See documentation of Poll for error-handling information.
461func (op *CreateGlossaryOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.Glossary, error) {
462	var resp translatepb.Glossary
463	if err := op.lro.WaitWithInterval(ctx, &resp, 5000*time.Millisecond, opts...); err != nil {
464		return nil, err
465	}
466	return &resp, nil
467}
468
469// Poll fetches the latest state of the long-running operation.
470//
471// Poll also fetches the latest metadata, which can be retrieved by Metadata.
472//
473// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
474// the operation has completed with failure, the error is returned and op.Done will return true.
475// If Poll succeeds and the operation has completed successfully,
476// op.Done will return true, and the response of the operation is returned.
477// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
478func (op *CreateGlossaryOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.Glossary, error) {
479	var resp translatepb.Glossary
480	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
481		return nil, err
482	}
483	if !op.Done() {
484		return nil, nil
485	}
486	return &resp, nil
487}
488
489// Metadata returns metadata associated with the long-running operation.
490// Metadata itself does not contact the server, but Poll does.
491// To get the latest metadata, call this method after a successful call to Poll.
492// If the metadata is not available, the returned metadata and error are both nil.
493func (op *CreateGlossaryOperation) Metadata() (*translatepb.CreateGlossaryMetadata, error) {
494	var meta translatepb.CreateGlossaryMetadata
495	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
496		return nil, nil
497	} else if err != nil {
498		return nil, err
499	}
500	return &meta, nil
501}
502
503// Done reports whether the long-running operation has completed.
504func (op *CreateGlossaryOperation) Done() bool {
505	return op.lro.Done()
506}
507
508// Name returns the name of the long-running operation.
509// The name is assigned by the server and is unique within the service from which the operation is created.
510func (op *CreateGlossaryOperation) Name() string {
511	return op.lro.Name()
512}
513
514// DeleteGlossaryOperation manages a long-running operation from DeleteGlossary.
515type DeleteGlossaryOperation struct {
516	lro *longrunning.Operation
517}
518
519// DeleteGlossaryOperation returns a new DeleteGlossaryOperation from a given name.
520// The name must be that of a previously created DeleteGlossaryOperation, possibly from a different process.
521func (c *TranslationClient) DeleteGlossaryOperation(name string) *DeleteGlossaryOperation {
522	return &DeleteGlossaryOperation{
523		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
524	}
525}
526
527// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
528//
529// See documentation of Poll for error-handling information.
530func (op *DeleteGlossaryOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.DeleteGlossaryResponse, error) {
531	var resp translatepb.DeleteGlossaryResponse
532	if err := op.lro.WaitWithInterval(ctx, &resp, 5000*time.Millisecond, opts...); err != nil {
533		return nil, err
534	}
535	return &resp, nil
536}
537
538// Poll fetches the latest state of the long-running operation.
539//
540// Poll also fetches the latest metadata, which can be retrieved by Metadata.
541//
542// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
543// the operation has completed with failure, the error is returned and op.Done will return true.
544// If Poll succeeds and the operation has completed successfully,
545// op.Done will return true, and the response of the operation is returned.
546// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
547func (op *DeleteGlossaryOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.DeleteGlossaryResponse, error) {
548	var resp translatepb.DeleteGlossaryResponse
549	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
550		return nil, err
551	}
552	if !op.Done() {
553		return nil, nil
554	}
555	return &resp, nil
556}
557
558// Metadata returns metadata associated with the long-running operation.
559// Metadata itself does not contact the server, but Poll does.
560// To get the latest metadata, call this method after a successful call to Poll.
561// If the metadata is not available, the returned metadata and error are both nil.
562func (op *DeleteGlossaryOperation) Metadata() (*translatepb.DeleteGlossaryMetadata, error) {
563	var meta translatepb.DeleteGlossaryMetadata
564	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
565		return nil, nil
566	} else if err != nil {
567		return nil, err
568	}
569	return &meta, nil
570}
571
572// Done reports whether the long-running operation has completed.
573func (op *DeleteGlossaryOperation) Done() bool {
574	return op.lro.Done()
575}
576
577// Name returns the name of the long-running operation.
578// The name is assigned by the server and is unique within the service from which the operation is created.
579func (op *DeleteGlossaryOperation) Name() string {
580	return op.lro.Name()
581}
582