1// Copyright 2020 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17package talent
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	gtransport "google.golang.org/api/transport/grpc"
33	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
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
40var newJobClientHook clientHook
41
42// JobCallOptions contains the retry settings for each method of JobClient.
43type JobCallOptions struct {
44	CreateJob          []gax.CallOption
45	BatchCreateJobs    []gax.CallOption
46	GetJob             []gax.CallOption
47	UpdateJob          []gax.CallOption
48	BatchUpdateJobs    []gax.CallOption
49	DeleteJob          []gax.CallOption
50	BatchDeleteJobs    []gax.CallOption
51	ListJobs           []gax.CallOption
52	SearchJobs         []gax.CallOption
53	SearchJobsForAlert []gax.CallOption
54}
55
56func defaultJobClientOptions() []option.ClientOption {
57	return []option.ClientOption{
58		option.WithEndpoint("jobs.googleapis.com:443"),
59		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
60		option.WithScopes(DefaultAuthScopes()...),
61		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
62			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
63	}
64}
65
66func defaultJobCallOptions() *JobCallOptions {
67	return &JobCallOptions{
68		CreateJob:       []gax.CallOption{},
69		BatchCreateJobs: []gax.CallOption{},
70		GetJob: []gax.CallOption{
71			gax.WithRetry(func() gax.Retryer {
72				return gax.OnCodes([]codes.Code{
73					codes.DeadlineExceeded,
74					codes.Unavailable,
75				}, gax.Backoff{
76					Initial:    100 * time.Millisecond,
77					Max:        60000 * time.Millisecond,
78					Multiplier: 1.30,
79				})
80			}),
81		},
82		UpdateJob:       []gax.CallOption{},
83		BatchUpdateJobs: []gax.CallOption{},
84		DeleteJob: []gax.CallOption{
85			gax.WithRetry(func() gax.Retryer {
86				return gax.OnCodes([]codes.Code{
87					codes.DeadlineExceeded,
88					codes.Unavailable,
89				}, gax.Backoff{
90					Initial:    100 * time.Millisecond,
91					Max:        60000 * time.Millisecond,
92					Multiplier: 1.30,
93				})
94			}),
95		},
96		BatchDeleteJobs: []gax.CallOption{},
97		ListJobs: []gax.CallOption{
98			gax.WithRetry(func() gax.Retryer {
99				return gax.OnCodes([]codes.Code{
100					codes.DeadlineExceeded,
101					codes.Unavailable,
102				}, gax.Backoff{
103					Initial:    100 * time.Millisecond,
104					Max:        60000 * time.Millisecond,
105					Multiplier: 1.30,
106				})
107			}),
108		},
109		SearchJobs:         []gax.CallOption{},
110		SearchJobsForAlert: []gax.CallOption{},
111	}
112}
113
114// JobClient is a client for interacting with Cloud Talent Solution API.
115//
116// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
117type JobClient struct {
118	// Connection pool of gRPC connections to the service.
119	connPool gtransport.ConnPool
120
121	// The gRPC API client.
122	jobClient talentpb.JobServiceClient
123
124	// LROClient is used internally to handle longrunning operations.
125	// It is exposed so that its CallOptions can be modified if required.
126	// Users should not Close this client.
127	LROClient *lroauto.OperationsClient
128
129	// The call options for this service.
130	CallOptions *JobCallOptions
131
132	// The x-goog-* metadata to be sent with each request.
133	xGoogMetadata metadata.MD
134}
135
136// NewJobClient creates a new job service client.
137//
138// A service handles job management, including job CRUD, enumeration and search.
139func NewJobClient(ctx context.Context, opts ...option.ClientOption) (*JobClient, error) {
140	clientOpts := defaultJobClientOptions()
141
142	if newJobClientHook != nil {
143		hookOpts, err := newJobClientHook(ctx, clientHookParams{})
144		if err != nil {
145			return nil, err
146		}
147		clientOpts = append(clientOpts, hookOpts...)
148	}
149
150	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
151	if err != nil {
152		return nil, err
153	}
154	c := &JobClient{
155		connPool:    connPool,
156		CallOptions: defaultJobCallOptions(),
157
158		jobClient: talentpb.NewJobServiceClient(connPool),
159	}
160	c.setGoogleClientInfo()
161
162	c.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
163	if err != nil {
164		// This error "should not happen", since we are just reusing old connection pool
165		// and never actually need to dial.
166		// If this does happen, we could leak connp. However, we cannot close conn:
167		// If the user invoked the constructor with option.WithGRPCConn,
168		// we would close a connection that's still in use.
169		// TODO: investigate error conditions.
170		return nil, err
171	}
172	return c, nil
173}
174
175// Connection returns a connection to the API service.
176//
177// Deprecated.
178func (c *JobClient) Connection() *grpc.ClientConn {
179	return c.connPool.Conn()
180}
181
182// Close closes the connection to the API service. The user should invoke this when
183// the client is no longer required.
184func (c *JobClient) Close() error {
185	return c.connPool.Close()
186}
187
188// setGoogleClientInfo sets the name and version of the application in
189// the `x-goog-api-client` header passed on each request. Intended for
190// use by Google-written clients.
191func (c *JobClient) setGoogleClientInfo(keyval ...string) {
192	kv := append([]string{"gl-go", versionGo()}, keyval...)
193	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
194	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
195}
196
197// CreateJob creates a new job.
198//
199// Typically, the job becomes searchable within 10 seconds, but it may take
200// up to 5 minutes.
201func (c *JobClient) CreateJob(ctx context.Context, req *talentpb.CreateJobRequest, opts ...gax.CallOption) (*talentpb.Job, error) {
202	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
203	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
204	opts = append(c.CallOptions.CreateJob[0:len(c.CallOptions.CreateJob):len(c.CallOptions.CreateJob)], opts...)
205	var resp *talentpb.Job
206	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
207		var err error
208		resp, err = c.jobClient.CreateJob(ctx, req, settings.GRPC...)
209		return err
210	}, opts...)
211	if err != nil {
212		return nil, err
213	}
214	return resp, nil
215}
216
217// BatchCreateJobs begins executing a batch create jobs operation.
218func (c *JobClient) BatchCreateJobs(ctx context.Context, req *talentpb.BatchCreateJobsRequest, opts ...gax.CallOption) (*BatchCreateJobsOperation, error) {
219	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
220	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
221	opts = append(c.CallOptions.BatchCreateJobs[0:len(c.CallOptions.BatchCreateJobs):len(c.CallOptions.BatchCreateJobs)], opts...)
222	var resp *longrunningpb.Operation
223	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
224		var err error
225		resp, err = c.jobClient.BatchCreateJobs(ctx, req, settings.GRPC...)
226		return err
227	}, opts...)
228	if err != nil {
229		return nil, err
230	}
231	return &BatchCreateJobsOperation{
232		lro: longrunning.InternalNewOperation(c.LROClient, resp),
233	}, nil
234}
235
236// GetJob retrieves the specified job, whose status is OPEN or recently EXPIRED
237// within the last 90 days.
238func (c *JobClient) GetJob(ctx context.Context, req *talentpb.GetJobRequest, opts ...gax.CallOption) (*talentpb.Job, error) {
239	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
240	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
241	opts = append(c.CallOptions.GetJob[0:len(c.CallOptions.GetJob):len(c.CallOptions.GetJob)], opts...)
242	var resp *talentpb.Job
243	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
244		var err error
245		resp, err = c.jobClient.GetJob(ctx, req, settings.GRPC...)
246		return err
247	}, opts...)
248	if err != nil {
249		return nil, err
250	}
251	return resp, nil
252}
253
254// UpdateJob updates specified job.
255//
256// Typically, updated contents become visible in search results within 10
257// seconds, but it may take up to 5 minutes.
258func (c *JobClient) UpdateJob(ctx context.Context, req *talentpb.UpdateJobRequest, opts ...gax.CallOption) (*talentpb.Job, error) {
259	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "job.name", url.QueryEscape(req.GetJob().GetName())))
260	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
261	opts = append(c.CallOptions.UpdateJob[0:len(c.CallOptions.UpdateJob):len(c.CallOptions.UpdateJob)], opts...)
262	var resp *talentpb.Job
263	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
264		var err error
265		resp, err = c.jobClient.UpdateJob(ctx, req, settings.GRPC...)
266		return err
267	}, opts...)
268	if err != nil {
269		return nil, err
270	}
271	return resp, nil
272}
273
274// BatchUpdateJobs begins executing a batch update jobs operation.
275func (c *JobClient) BatchUpdateJobs(ctx context.Context, req *talentpb.BatchUpdateJobsRequest, opts ...gax.CallOption) (*BatchUpdateJobsOperation, error) {
276	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
277	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
278	opts = append(c.CallOptions.BatchUpdateJobs[0:len(c.CallOptions.BatchUpdateJobs):len(c.CallOptions.BatchUpdateJobs)], opts...)
279	var resp *longrunningpb.Operation
280	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
281		var err error
282		resp, err = c.jobClient.BatchUpdateJobs(ctx, req, settings.GRPC...)
283		return err
284	}, opts...)
285	if err != nil {
286		return nil, err
287	}
288	return &BatchUpdateJobsOperation{
289		lro: longrunning.InternalNewOperation(c.LROClient, resp),
290	}, nil
291}
292
293// DeleteJob deletes the specified job.
294//
295// Typically, the job becomes unsearchable within 10 seconds, but it may take
296// up to 5 minutes.
297func (c *JobClient) DeleteJob(ctx context.Context, req *talentpb.DeleteJobRequest, opts ...gax.CallOption) 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.DeleteJob[0:len(c.CallOptions.DeleteJob):len(c.CallOptions.DeleteJob)], opts...)
301	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
302		var err error
303		_, err = c.jobClient.DeleteJob(ctx, req, settings.GRPC...)
304		return err
305	}, opts...)
306	return err
307}
308
309// BatchDeleteJobs deletes a list of Jobs by filter.
310func (c *JobClient) BatchDeleteJobs(ctx context.Context, req *talentpb.BatchDeleteJobsRequest, opts ...gax.CallOption) error {
311	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
312	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
313	opts = append(c.CallOptions.BatchDeleteJobs[0:len(c.CallOptions.BatchDeleteJobs):len(c.CallOptions.BatchDeleteJobs)], opts...)
314	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
315		var err error
316		_, err = c.jobClient.BatchDeleteJobs(ctx, req, settings.GRPC...)
317		return err
318	}, opts...)
319	return err
320}
321
322// ListJobs lists jobs by filter.
323func (c *JobClient) ListJobs(ctx context.Context, req *talentpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator {
324	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
325	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
326	opts = append(c.CallOptions.ListJobs[0:len(c.CallOptions.ListJobs):len(c.CallOptions.ListJobs)], opts...)
327	it := &JobIterator{}
328	req = proto.Clone(req).(*talentpb.ListJobsRequest)
329	it.InternalFetch = func(pageSize int, pageToken string) ([]*talentpb.Job, string, error) {
330		var resp *talentpb.ListJobsResponse
331		req.PageToken = pageToken
332		if pageSize > math.MaxInt32 {
333			req.PageSize = math.MaxInt32
334		} else {
335			req.PageSize = int32(pageSize)
336		}
337		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
338			var err error
339			resp, err = c.jobClient.ListJobs(ctx, req, settings.GRPC...)
340			return err
341		}, opts...)
342		if err != nil {
343			return nil, "", err
344		}
345
346		it.Response = resp
347		return resp.Jobs, resp.NextPageToken, nil
348	}
349	fetch := func(pageSize int, pageToken string) (string, error) {
350		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
351		if err != nil {
352			return "", err
353		}
354		it.items = append(it.items, items...)
355		return nextPageToken, nil
356	}
357	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
358	it.pageInfo.MaxSize = int(req.PageSize)
359	it.pageInfo.Token = req.PageToken
360	return it
361}
362
363// SearchJobs searches for jobs using the provided SearchJobsRequest.
364//
365// This call constrains the visibility of jobs
366// present in the database, and only returns jobs that the caller has
367// permission to search against.
368func (c *JobClient) SearchJobs(ctx context.Context, req *talentpb.SearchJobsRequest, opts ...gax.CallOption) (*talentpb.SearchJobsResponse, error) {
369	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
370	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
371	opts = append(c.CallOptions.SearchJobs[0:len(c.CallOptions.SearchJobs):len(c.CallOptions.SearchJobs)], opts...)
372	var resp *talentpb.SearchJobsResponse
373	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
374		var err error
375		resp, err = c.jobClient.SearchJobs(ctx, req, settings.GRPC...)
376		return err
377	}, opts...)
378	if err != nil {
379		return nil, err
380	}
381	return resp, nil
382}
383
384// SearchJobsForAlert searches for jobs using the provided SearchJobsRequest.
385//
386// This API call is intended for the use case of targeting passive job
387// seekers (for example, job seekers who have signed up to receive email
388// alerts about potential job opportunities), and has different algorithmic
389// adjustments that are targeted to passive job seekers.
390//
391// This call constrains the visibility of jobs
392// present in the database, and only returns jobs the caller has
393// permission to search against.
394func (c *JobClient) SearchJobsForAlert(ctx context.Context, req *talentpb.SearchJobsRequest, opts ...gax.CallOption) *SearchJobsResponse_MatchingJobIterator {
395	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
396	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
397	opts = append(c.CallOptions.SearchJobsForAlert[0:len(c.CallOptions.SearchJobsForAlert):len(c.CallOptions.SearchJobsForAlert)], opts...)
398	it := &SearchJobsResponse_MatchingJobIterator{}
399	req = proto.Clone(req).(*talentpb.SearchJobsRequest)
400	it.InternalFetch = func(pageSize int, pageToken string) ([]*talentpb.SearchJobsResponse_MatchingJob, string, error) {
401		var resp *talentpb.SearchJobsResponse
402		req.PageToken = pageToken
403		if pageSize > math.MaxInt32 {
404			req.PageSize = math.MaxInt32
405		} else {
406			req.PageSize = int32(pageSize)
407		}
408		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
409			var err error
410			resp, err = c.jobClient.SearchJobsForAlert(ctx, req, settings.GRPC...)
411			return err
412		}, opts...)
413		if err != nil {
414			return nil, "", err
415		}
416
417		it.Response = resp
418		return resp.MatchingJobs, resp.NextPageToken, nil
419	}
420	fetch := func(pageSize int, pageToken string) (string, error) {
421		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
422		if err != nil {
423			return "", err
424		}
425		it.items = append(it.items, items...)
426		return nextPageToken, nil
427	}
428	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
429	it.pageInfo.MaxSize = int(req.PageSize)
430	it.pageInfo.Token = req.PageToken
431	return it
432}
433
434// BatchCreateJobsOperation manages a long-running operation from BatchCreateJobs.
435type BatchCreateJobsOperation struct {
436	lro *longrunning.Operation
437}
438
439// BatchCreateJobsOperation returns a new BatchCreateJobsOperation from a given name.
440// The name must be that of a previously created BatchCreateJobsOperation, possibly from a different process.
441func (c *JobClient) BatchCreateJobsOperation(name string) *BatchCreateJobsOperation {
442	return &BatchCreateJobsOperation{
443		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
444	}
445}
446
447// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
448//
449// See documentation of Poll for error-handling information.
450func (op *BatchCreateJobsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*talentpb.JobOperationResult, error) {
451	var resp talentpb.JobOperationResult
452	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
453		return nil, err
454	}
455	return &resp, nil
456}
457
458// Poll fetches the latest state of the long-running operation.
459//
460// Poll also fetches the latest metadata, which can be retrieved by Metadata.
461//
462// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
463// the operation has completed with failure, the error is returned and op.Done will return true.
464// If Poll succeeds and the operation has completed successfully,
465// op.Done will return true, and the response of the operation is returned.
466// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
467func (op *BatchCreateJobsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*talentpb.JobOperationResult, error) {
468	var resp talentpb.JobOperationResult
469	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
470		return nil, err
471	}
472	if !op.Done() {
473		return nil, nil
474	}
475	return &resp, nil
476}
477
478// Metadata returns metadata associated with the long-running operation.
479// Metadata itself does not contact the server, but Poll does.
480// To get the latest metadata, call this method after a successful call to Poll.
481// If the metadata is not available, the returned metadata and error are both nil.
482func (op *BatchCreateJobsOperation) Metadata() (*talentpb.BatchOperationMetadata, error) {
483	var meta talentpb.BatchOperationMetadata
484	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
485		return nil, nil
486	} else if err != nil {
487		return nil, err
488	}
489	return &meta, nil
490}
491
492// Done reports whether the long-running operation has completed.
493func (op *BatchCreateJobsOperation) Done() bool {
494	return op.lro.Done()
495}
496
497// Name returns the name of the long-running operation.
498// The name is assigned by the server and is unique within the service from which the operation is created.
499func (op *BatchCreateJobsOperation) Name() string {
500	return op.lro.Name()
501}
502
503// BatchUpdateJobsOperation manages a long-running operation from BatchUpdateJobs.
504type BatchUpdateJobsOperation struct {
505	lro *longrunning.Operation
506}
507
508// BatchUpdateJobsOperation returns a new BatchUpdateJobsOperation from a given name.
509// The name must be that of a previously created BatchUpdateJobsOperation, possibly from a different process.
510func (c *JobClient) BatchUpdateJobsOperation(name string) *BatchUpdateJobsOperation {
511	return &BatchUpdateJobsOperation{
512		lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
513	}
514}
515
516// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
517//
518// See documentation of Poll for error-handling information.
519func (op *BatchUpdateJobsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*talentpb.JobOperationResult, error) {
520	var resp talentpb.JobOperationResult
521	if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
522		return nil, err
523	}
524	return &resp, nil
525}
526
527// Poll fetches the latest state of the long-running operation.
528//
529// Poll also fetches the latest metadata, which can be retrieved by Metadata.
530//
531// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
532// the operation has completed with failure, the error is returned and op.Done will return true.
533// If Poll succeeds and the operation has completed successfully,
534// op.Done will return true, and the response of the operation is returned.
535// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
536func (op *BatchUpdateJobsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*talentpb.JobOperationResult, error) {
537	var resp talentpb.JobOperationResult
538	if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
539		return nil, err
540	}
541	if !op.Done() {
542		return nil, nil
543	}
544	return &resp, nil
545}
546
547// Metadata returns metadata associated with the long-running operation.
548// Metadata itself does not contact the server, but Poll does.
549// To get the latest metadata, call this method after a successful call to Poll.
550// If the metadata is not available, the returned metadata and error are both nil.
551func (op *BatchUpdateJobsOperation) Metadata() (*talentpb.BatchOperationMetadata, error) {
552	var meta talentpb.BatchOperationMetadata
553	if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
554		return nil, nil
555	} else if err != nil {
556		return nil, err
557	}
558	return &meta, nil
559}
560
561// Done reports whether the long-running operation has completed.
562func (op *BatchUpdateJobsOperation) Done() bool {
563	return op.lro.Done()
564}
565
566// Name returns the name of the long-running operation.
567// The name is assigned by the server and is unique within the service from which the operation is created.
568func (op *BatchUpdateJobsOperation) Name() string {
569	return op.lro.Name()
570}
571
572// JobIterator manages a stream of *talentpb.Job.
573type JobIterator struct {
574	items    []*talentpb.Job
575	pageInfo *iterator.PageInfo
576	nextFunc func() error
577
578	// Response is the raw response for the current page.
579	// It must be cast to the RPC response type.
580	// Calling Next() or InternalFetch() updates this value.
581	Response interface{}
582
583	// InternalFetch is for use by the Google Cloud Libraries only.
584	// It is not part of the stable interface of this package.
585	//
586	// InternalFetch returns results from a single call to the underlying RPC.
587	// The number of results is no greater than pageSize.
588	// If there are no more results, nextPageToken is empty and err is nil.
589	InternalFetch func(pageSize int, pageToken string) (results []*talentpb.Job, nextPageToken string, err error)
590}
591
592// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
593func (it *JobIterator) PageInfo() *iterator.PageInfo {
594	return it.pageInfo
595}
596
597// Next returns the next result. Its second return value is iterator.Done if there are no more
598// results. Once Next returns Done, all subsequent calls will return Done.
599func (it *JobIterator) Next() (*talentpb.Job, error) {
600	var item *talentpb.Job
601	if err := it.nextFunc(); err != nil {
602		return item, err
603	}
604	item = it.items[0]
605	it.items = it.items[1:]
606	return item, nil
607}
608
609func (it *JobIterator) bufLen() int {
610	return len(it.items)
611}
612
613func (it *JobIterator) takeBuf() interface{} {
614	b := it.items
615	it.items = nil
616	return b
617}
618
619// SearchJobsResponse_MatchingJobIterator manages a stream of *talentpb.SearchJobsResponse_MatchingJob.
620type SearchJobsResponse_MatchingJobIterator struct {
621	items    []*talentpb.SearchJobsResponse_MatchingJob
622	pageInfo *iterator.PageInfo
623	nextFunc func() error
624
625	// Response is the raw response for the current page.
626	// It must be cast to the RPC response type.
627	// Calling Next() or InternalFetch() updates this value.
628	Response interface{}
629
630	// InternalFetch is for use by the Google Cloud Libraries only.
631	// It is not part of the stable interface of this package.
632	//
633	// InternalFetch returns results from a single call to the underlying RPC.
634	// The number of results is no greater than pageSize.
635	// If there are no more results, nextPageToken is empty and err is nil.
636	InternalFetch func(pageSize int, pageToken string) (results []*talentpb.SearchJobsResponse_MatchingJob, nextPageToken string, err error)
637}
638
639// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
640func (it *SearchJobsResponse_MatchingJobIterator) PageInfo() *iterator.PageInfo {
641	return it.pageInfo
642}
643
644// Next returns the next result. Its second return value is iterator.Done if there are no more
645// results. Once Next returns Done, all subsequent calls will return Done.
646func (it *SearchJobsResponse_MatchingJobIterator) Next() (*talentpb.SearchJobsResponse_MatchingJob, error) {
647	var item *talentpb.SearchJobsResponse_MatchingJob
648	if err := it.nextFunc(); err != nil {
649		return item, err
650	}
651	item = it.items[0]
652	it.items = it.items[1:]
653	return item, nil
654}
655
656func (it *SearchJobsResponse_MatchingJobIterator) bufLen() int {
657	return len(it.items)
658}
659
660func (it *SearchJobsResponse_MatchingJobIterator) takeBuf() interface{} {
661	b := it.items
662	it.items = nil
663	return b
664}
665