Debian Codegraph @

talent/apiv4/job_client_example_test.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_test
18
19 import (
20 "context"
21
22 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
23 talent "cloud.google.com/go/talent/apiv4"
24 talentpb "cloud.google.com/go/talent/apiv4/talentpb"
25 "google.golang.org/api/iterator"
26 )
27
28 func ExampleNewJobClient() {
29 ctx := context.Background()
30 // This snippet has been automatically generated and should be regarded as a code template only.
31 // It will require modifications to work:
32 // - It may require correct/in-range values for request initialization.
33 // - It may require specifying regional endpoints when creating the service client as shown in:
34 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
35 c, err := talent.NewJobClient(ctx)
36 if err != nil {
37 // TODO: Handle error.
38 }
39 defer c.Close()
40
41 // TODO: Use client.
42 _ = c
43 }
44
45 func ExampleNewJobRESTClient() {
46 ctx := context.Background()
47 // This snippet has been automatically generated and should be regarded as a code template only.
48 // It will require modifications to work:
49 // - It may require correct/in-range values for request initialization.
50 // - It may require specifying regional endpoints when creating the service client as shown in:
51 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
52 c, err := talent.NewJobRESTClient(ctx)
53 if err != nil {
54 // TODO: Handle error.
55 }
56 defer c.Close()
57
58 // TODO: Use client.
59 _ = c
60 }
61
62 func ExampleJobClient_BatchCreateJobs() {
63 ctx := context.Background()
64 // This snippet has been automatically generated and should be regarded as a code template only.
65 // It will require modifications to work:
66 // - It may require correct/in-range values for request initialization.
67 // - It may require specifying regional endpoints when creating the service client as shown in:
68 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
69 c, err := talent.NewJobClient(ctx)
70 if err != nil {
71 // TODO: Handle error.
72 }
73 defer c.Close()
74
75 req := &talentpb.BatchCreateJobsRequest{
76 // TODO: Fill request struct fields.
77 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#BatchCreateJobsRequest.
78 }
79 op, err := c.BatchCreateJobs(ctx, req)
80 if err != nil {
81 // TODO: Handle error.
82 }
83
84 resp, err := op.Wait(ctx)
85 if err != nil {
86 // TODO: Handle error.
87 }
88 // TODO: Use resp.
89 _ = resp
90 }
91
92 func ExampleJobClient_BatchDeleteJobs() {
93 ctx := context.Background()
94 // This snippet has been automatically generated and should be regarded as a code template only.
95 // It will require modifications to work:
96 // - It may require correct/in-range values for request initialization.
97 // - It may require specifying regional endpoints when creating the service client as shown in:
98 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
99 c, err := talent.NewJobClient(ctx)
100 if err != nil {
101 // TODO: Handle error.
102 }
103 defer c.Close()
104
105 req := &talentpb.BatchDeleteJobsRequest{
106 // TODO: Fill request struct fields.
107 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#BatchDeleteJobsRequest.
108 }
109 op, err := c.BatchDeleteJobs(ctx, req)
110 if err != nil {
111 // TODO: Handle error.
112 }
113
114 resp, err := op.Wait(ctx)
115 if err != nil {
116 // TODO: Handle error.
117 }
118 // TODO: Use resp.
119 _ = resp
120 }
121
122 func ExampleJobClient_BatchUpdateJobs() {
123 ctx := context.Background()
124 // This snippet has been automatically generated and should be regarded as a code template only.
125 // It will require modifications to work:
126 // - It may require correct/in-range values for request initialization.
127 // - It may require specifying regional endpoints when creating the service client as shown in:
128 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
129 c, err := talent.NewJobClient(ctx)
130 if err != nil {
131 // TODO: Handle error.
132 }
133 defer c.Close()
134
135 req := &talentpb.BatchUpdateJobsRequest{
136 // TODO: Fill request struct fields.
137 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#BatchUpdateJobsRequest.
138 }
139 op, err := c.BatchUpdateJobs(ctx, req)
140 if err != nil {
141 // TODO: Handle error.
142 }
143
144 resp, err := op.Wait(ctx)
145 if err != nil {
146 // TODO: Handle error.
147 }
148 // TODO: Use resp.
149 _ = resp
150 }
151
152 func ExampleJobClient_CreateJob() {
153 ctx := context.Background()
154 // This snippet has been automatically generated and should be regarded as a code template only.
155 // It will require modifications to work:
156 // - It may require correct/in-range values for request initialization.
157 // - It may require specifying regional endpoints when creating the service client as shown in:
158 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
159 c, err := talent.NewJobClient(ctx)
160 if err != nil {
161 // TODO: Handle error.
162 }
163 defer c.Close()
164
165 req := &talentpb.CreateJobRequest{
166 // TODO: Fill request struct fields.
167 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#CreateJobRequest.
168 }
169 resp, err := c.CreateJob(ctx, req)
170 if err != nil {
171 // TODO: Handle error.
172 }
173 // TODO: Use resp.
174 _ = resp
175 }
176
177 func ExampleJobClient_DeleteJob() {
178 ctx := context.Background()
179 // This snippet has been automatically generated and should be regarded as a code template only.
180 // It will require modifications to work:
181 // - It may require correct/in-range values for request initialization.
182 // - It may require specifying regional endpoints when creating the service client as shown in:
183 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
184 c, err := talent.NewJobClient(ctx)
185 if err != nil {
186 // TODO: Handle error.
187 }
188 defer c.Close()
189
190 req := &talentpb.DeleteJobRequest{
191 // TODO: Fill request struct fields.
192 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#DeleteJobRequest.
193 }
194 err = c.DeleteJob(ctx, req)
195 if err != nil {
196 // TODO: Handle error.
197 }
198 }
199
200 func ExampleJobClient_GetJob() {
201 ctx := context.Background()
202 // This snippet has been automatically generated and should be regarded as a code template only.
203 // It will require modifications to work:
204 // - It may require correct/in-range values for request initialization.
205 // - It may require specifying regional endpoints when creating the service client as shown in:
206 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
207 c, err := talent.NewJobClient(ctx)
208 if err != nil {
209 // TODO: Handle error.
210 }
211 defer c.Close()
212
213 req := &talentpb.GetJobRequest{
214 // TODO: Fill request struct fields.
215 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#GetJobRequest.
216 }
217 resp, err := c.GetJob(ctx, req)
218 if err != nil {
219 // TODO: Handle error.
220 }
221 // TODO: Use resp.
222 _ = resp
223 }
224
225 func ExampleJobClient_ListJobs() {
226 ctx := context.Background()
227 // This snippet has been automatically generated and should be regarded as a code template only.
228 // It will require modifications to work:
229 // - It may require correct/in-range values for request initialization.
230 // - It may require specifying regional endpoints when creating the service client as shown in:
231 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
232 c, err := talent.NewJobClient(ctx)
233 if err != nil {
234 // TODO: Handle error.
235 }
236 defer c.Close()
237
238 req := &talentpb.ListJobsRequest{
239 // TODO: Fill request struct fields.
240 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#ListJobsRequest.
241 }
242 it := c.ListJobs(ctx, req)
243 for {
244 resp, err := it.Next()
245 if err == iterator.Done {
246 break
247 }
248 if err != nil {
249 // TODO: Handle error.
250 }
251 // TODO: Use resp.
252 _ = resp
253
254 // If you need to access the underlying RPC response,
255 // you can do so by casting the `Response` as below.
256 // Otherwise, remove this line. Only populated after
257 // first call to Next(). Not safe for concurrent access.
258 _ = it.Response.(*talentpb.ListJobsResponse)
259 }
260 }
261
262 func ExampleJobClient_SearchJobs() {
263 ctx := context.Background()
264 // This snippet has been automatically generated and should be regarded as a code template only.
265 // It will require modifications to work:
266 // - It may require correct/in-range values for request initialization.
267 // - It may require specifying regional endpoints when creating the service client as shown in:
268 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
269 c, err := talent.NewJobClient(ctx)
270 if err != nil {
271 // TODO: Handle error.
272 }
273 defer c.Close()
274
275 req := &talentpb.SearchJobsRequest{
276 // TODO: Fill request struct fields.
277 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#SearchJobsRequest.
278 }
279 resp, err := c.SearchJobs(ctx, req)
280 if err != nil {
281 // TODO: Handle error.
282 }
283 // TODO: Use resp.
284 _ = resp
285 }
286
287 func ExampleJobClient_SearchJobsForAlert() {
288 ctx := context.Background()
289 // This snippet has been automatically generated and should be regarded as a code template only.
290 // It will require modifications to work:
291 // - It may require correct/in-range values for request initialization.
292 // - It may require specifying regional endpoints when creating the service client as shown in:
293 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
294 c, err := talent.NewJobClient(ctx)
295 if err != nil {
296 // TODO: Handle error.
297 }
298 defer c.Close()
299
300 req := &talentpb.SearchJobsRequest{
301 // TODO: Fill request struct fields.
302 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#SearchJobsRequest.
303 }
304 resp, err := c.SearchJobsForAlert(ctx, req)
305 if err != nil {
306 // TODO: Handle error.
307 }
308 // TODO: Use resp.
309 _ = resp
310 }
311
312 func ExampleJobClient_UpdateJob() {
313 ctx := context.Background()
314 // This snippet has been automatically generated and should be regarded as a code template only.
315 // It will require modifications to work:
316 // - It may require correct/in-range values for request initialization.
317 // - It may require specifying regional endpoints when creating the service client as shown in:
318 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
319 c, err := talent.NewJobClient(ctx)
320 if err != nil {
321 // TODO: Handle error.
322 }
323 defer c.Close()
324
325 req := &talentpb.UpdateJobRequest{
326 // TODO: Fill request struct fields.
327 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4/talentpb#UpdateJobRequest.
328 }
329 resp, err := c.UpdateJob(ctx, req)
330 if err != nil {
331 // TODO: Handle error.
332 }
333 // TODO: Use resp.
334 _ = resp
335 }
336
337 func ExampleJobClient_GetOperation() {
338 ctx := context.Background()
339 // This snippet has been automatically generated and should be regarded as a code template only.
340 // It will require modifications to work:
341 // - It may require correct/in-range values for request initialization.
342 // - It may require specifying regional endpoints when creating the service client as shown in:
343 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
344 c, err := talent.NewJobClient(ctx)
345 if err != nil {
346 // TODO: Handle error.
347 }
348 defer c.Close()
349
350 req := &longrunningpb.GetOperationRequest{
351 // TODO: Fill request struct fields.
352 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
353 }
354 resp, err := c.GetOperation(ctx, req)
355 if err != nil {
356 // TODO: Handle error.
357 }
358 // TODO: Use resp.
359 _ = resp
360 }