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