Debian Codegraph @

talent/apiv4/auxiliary.go

raw
1 // Copyright 2025 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
17 package talent
18
19 import (
20 "context"
21 "time"
22
23 "cloud.google.com/go/longrunning"
24 talentpb "cloud.google.com/go/talent/apiv4/talentpb"
25 gax "github.com/googleapis/gax-go/v2"
26 "google.golang.org/api/iterator"
27 )
28
29 // BatchCreateJobsOperation manages a long-running operation from BatchCreateJobs.
30 type BatchCreateJobsOperation struct {
31 lro *longrunning.Operation
32 pollPath string
33 }
34
35 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
36 //
37 // See documentation of Poll for error-handling information.
38 func (op *BatchCreateJobsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*talentpb.BatchCreateJobsResponse, error) {
39 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
40 var resp talentpb.BatchCreateJobsResponse
41 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
42 return nil, err
43 }
44 return &resp, nil
45 }
46
47 // Poll fetches the latest state of the long-running operation.
48 //
49 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
50 //
51 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
52 // the operation has completed with failure, the error is returned and op.Done will return true.
53 // If Poll succeeds and the operation has completed successfully,
54 // op.Done will return true, and the response of the operation is returned.
55 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
56 func (op *BatchCreateJobsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*talentpb.BatchCreateJobsResponse, error) {
57 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
58 var resp talentpb.BatchCreateJobsResponse
59 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
60 return nil, err
61 }
62 if !op.Done() {
63 return nil, nil
64 }
65 return &resp, nil
66 }
67
68 // Metadata returns metadata associated with the long-running operation.
69 // Metadata itself does not contact the server, but Poll does.
70 // To get the latest metadata, call this method after a successful call to Poll.
71 // If the metadata is not available, the returned metadata and error are both nil.
72 func (op *BatchCreateJobsOperation) Metadata() (*talentpb.BatchOperationMetadata, error) {
73 var meta talentpb.BatchOperationMetadata
74 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
75 return nil, nil
76 } else if err != nil {
77 return nil, err
78 }
79 return &meta, nil
80 }
81
82 // Done reports whether the long-running operation has completed.
83 func (op *BatchCreateJobsOperation) Done() bool {
84 return op.lro.Done()
85 }
86
87 // Name returns the name of the long-running operation.
88 // The name is assigned by the server and is unique within the service from which the operation is created.
89 func (op *BatchCreateJobsOperation) Name() string {
90 return op.lro.Name()
91 }
92
93 // BatchDeleteJobsOperation manages a long-running operation from BatchDeleteJobs.
94 type BatchDeleteJobsOperation struct {
95 lro *longrunning.Operation
96 pollPath string
97 }
98
99 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
100 //
101 // See documentation of Poll for error-handling information.
102 func (op *BatchDeleteJobsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*talentpb.BatchDeleteJobsResponse, error) {
103 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
104 var resp talentpb.BatchDeleteJobsResponse
105 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
106 return nil, err
107 }
108 return &resp, nil
109 }
110
111 // Poll fetches the latest state of the long-running operation.
112 //
113 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
114 //
115 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
116 // the operation has completed with failure, the error is returned and op.Done will return true.
117 // If Poll succeeds and the operation has completed successfully,
118 // op.Done will return true, and the response of the operation is returned.
119 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
120 func (op *BatchDeleteJobsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*talentpb.BatchDeleteJobsResponse, error) {
121 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
122 var resp talentpb.BatchDeleteJobsResponse
123 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
124 return nil, err
125 }
126 if !op.Done() {
127 return nil, nil
128 }
129 return &resp, nil
130 }
131
132 // Metadata returns metadata associated with the long-running operation.
133 // Metadata itself does not contact the server, but Poll does.
134 // To get the latest metadata, call this method after a successful call to Poll.
135 // If the metadata is not available, the returned metadata and error are both nil.
136 func (op *BatchDeleteJobsOperation) Metadata() (*talentpb.BatchOperationMetadata, error) {
137 var meta talentpb.BatchOperationMetadata
138 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
139 return nil, nil
140 } else if err != nil {
141 return nil, err
142 }
143 return &meta, nil
144 }
145
146 // Done reports whether the long-running operation has completed.
147 func (op *BatchDeleteJobsOperation) Done() bool {
148 return op.lro.Done()
149 }
150
151 // Name returns the name of the long-running operation.
152 // The name is assigned by the server and is unique within the service from which the operation is created.
153 func (op *BatchDeleteJobsOperation) Name() string {
154 return op.lro.Name()
155 }
156
157 // BatchUpdateJobsOperation manages a long-running operation from BatchUpdateJobs.
158 type BatchUpdateJobsOperation struct {
159 lro *longrunning.Operation
160 pollPath string
161 }
162
163 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
164 //
165 // See documentation of Poll for error-handling information.
166 func (op *BatchUpdateJobsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*talentpb.BatchUpdateJobsResponse, error) {
167 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
168 var resp talentpb.BatchUpdateJobsResponse
169 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
170 return nil, err
171 }
172 return &resp, nil
173 }
174
175 // Poll fetches the latest state of the long-running operation.
176 //
177 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
178 //
179 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
180 // the operation has completed with failure, the error is returned and op.Done will return true.
181 // If Poll succeeds and the operation has completed successfully,
182 // op.Done will return true, and the response of the operation is returned.
183 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
184 func (op *BatchUpdateJobsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*talentpb.BatchUpdateJobsResponse, error) {
185 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
186 var resp talentpb.BatchUpdateJobsResponse
187 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
188 return nil, err
189 }
190 if !op.Done() {
191 return nil, nil
192 }
193 return &resp, nil
194 }
195
196 // Metadata returns metadata associated with the long-running operation.
197 // Metadata itself does not contact the server, but Poll does.
198 // To get the latest metadata, call this method after a successful call to Poll.
199 // If the metadata is not available, the returned metadata and error are both nil.
200 func (op *BatchUpdateJobsOperation) Metadata() (*talentpb.BatchOperationMetadata, error) {
201 var meta talentpb.BatchOperationMetadata
202 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
203 return nil, nil
204 } else if err != nil {
205 return nil, err
206 }
207 return &meta, nil
208 }
209
210 // Done reports whether the long-running operation has completed.
211 func (op *BatchUpdateJobsOperation) Done() bool {
212 return op.lro.Done()
213 }
214
215 // Name returns the name of the long-running operation.
216 // The name is assigned by the server and is unique within the service from which the operation is created.
217 func (op *BatchUpdateJobsOperation) Name() string {
218 return op.lro.Name()
219 }
220
221 // CompanyIterator manages a stream of *talentpb.Company.
222 type CompanyIterator struct {
223 items []*talentpb.Company
224 pageInfo *iterator.PageInfo
225 nextFunc func() error
226
227 // Response is the raw response for the current page.
228 // It must be cast to the RPC response type.
229 // Calling Next() or InternalFetch() updates this value.
230 Response interface{}
231
232 // InternalFetch is for use by the Google Cloud Libraries only.
233 // It is not part of the stable interface of this package.
234 //
235 // InternalFetch returns results from a single call to the underlying RPC.
236 // The number of results is no greater than pageSize.
237 // If there are no more results, nextPageToken is empty and err is nil.
238 InternalFetch func(pageSize int, pageToken string) (results []*talentpb.Company, nextPageToken string, err error)
239 }
240
241 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
242 func (it *CompanyIterator) PageInfo() *iterator.PageInfo {
243 return it.pageInfo
244 }
245
246 // Next returns the next result. Its second return value is iterator.Done if there are no more
247 // results. Once Next returns Done, all subsequent calls will return Done.
248 func (it *CompanyIterator) Next() (*talentpb.Company, error) {
249 var item *talentpb.Company
250 if err := it.nextFunc(); err != nil {
251 return item, err
252 }
253 item = it.items[0]
254 it.items = it.items[1:]
255 return item, nil
256 }
257
258 func (it *CompanyIterator) bufLen() int {
259 return len(it.items)
260 }
261
262 func (it *CompanyIterator) takeBuf() interface{} {
263 b := it.items
264 it.items = nil
265 return b
266 }
267
268 // JobIterator manages a stream of *talentpb.Job.
269 type JobIterator struct {
270 items []*talentpb.Job
271 pageInfo *iterator.PageInfo
272 nextFunc func() error
273
274 // Response is the raw response for the current page.
275 // It must be cast to the RPC response type.
276 // Calling Next() or InternalFetch() updates this value.
277 Response interface{}
278
279 // InternalFetch is for use by the Google Cloud Libraries only.
280 // It is not part of the stable interface of this package.
281 //
282 // InternalFetch returns results from a single call to the underlying RPC.
283 // The number of results is no greater than pageSize.
284 // If there are no more results, nextPageToken is empty and err is nil.
285 InternalFetch func(pageSize int, pageToken string) (results []*talentpb.Job, nextPageToken string, err error)
286 }
287
288 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
289 func (it *JobIterator) PageInfo() *iterator.PageInfo {
290 return it.pageInfo
291 }
292
293 // Next returns the next result. Its second return value is iterator.Done if there are no more
294 // results. Once Next returns Done, all subsequent calls will return Done.
295 func (it *JobIterator) Next() (*talentpb.Job, error) {
296 var item *talentpb.Job
297 if err := it.nextFunc(); err != nil {
298 return item, err
299 }
300 item = it.items[0]
301 it.items = it.items[1:]
302 return item, nil
303 }
304
305 func (it *JobIterator) bufLen() int {
306 return len(it.items)
307 }
308
309 func (it *JobIterator) takeBuf() interface{} {
310 b := it.items
311 it.items = nil
312 return b
313 }
314
315 // TenantIterator manages a stream of *talentpb.Tenant.
316 type TenantIterator struct {
317 items []*talentpb.Tenant
318 pageInfo *iterator.PageInfo
319 nextFunc func() error
320
321 // Response is the raw response for the current page.
322 // It must be cast to the RPC response type.
323 // Calling Next() or InternalFetch() updates this value.
324 Response interface{}
325
326 // InternalFetch is for use by the Google Cloud Libraries only.
327 // It is not part of the stable interface of this package.
328 //
329 // InternalFetch returns results from a single call to the underlying RPC.
330 // The number of results is no greater than pageSize.
331 // If there are no more results, nextPageToken is empty and err is nil.
332 InternalFetch func(pageSize int, pageToken string) (results []*talentpb.Tenant, nextPageToken string, err error)
333 }
334
335 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
336 func (it *TenantIterator) PageInfo() *iterator.PageInfo {
337 return it.pageInfo
338 }
339
340 // Next returns the next result. Its second return value is iterator.Done if there are no more
341 // results. Once Next returns Done, all subsequent calls will return Done.
342 func (it *TenantIterator) Next() (*talentpb.Tenant, error) {
343 var item *talentpb.Tenant
344 if err := it.nextFunc(); err != nil {
345 return item, err
346 }
347 item = it.items[0]
348 it.items = it.items[1:]
349 return item, nil
350 }
351
352 func (it *TenantIterator) bufLen() int {
353 return len(it.items)
354 }
355
356 func (it *TenantIterator) takeBuf() interface{} {
357 b := it.items
358 it.items = nil
359 return b
360 }