Debian Codegraph @

talent/apiv4beta1/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/apiv4beta1"
24 talentpb "cloud.google.com/go/talent/apiv4beta1/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/apiv4beta1/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/apiv4beta1/talentpb#BatchDeleteJobsRequest.
108 }
109 err = c.BatchDeleteJobs(ctx, req)
110 if err != nil {
111 // TODO: Handle error.
112 }
113 }
114
115 func ExampleJobClient_BatchUpdateJobs() {
116 ctx := context.Background()
117 // This snippet has been automatically generated and should be regarded as a code template only.
118 // It will require modifications to work:
119 // - It may require correct/in-range values for request initialization.
120 // - It may require specifying regional endpoints when creating the service client as shown in:
121 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
122 c, err := talent.NewJobClient(ctx)
123 if err != nil {
124 // TODO: Handle error.
125 }
126 defer c.Close()
127
128 req := &talentpb.BatchUpdateJobsRequest{
129 // TODO: Fill request struct fields.
130 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1/talentpb#BatchUpdateJobsRequest.
131 }
132 op, err := c.BatchUpdateJobs(ctx, req)
133 if err != nil {
134 // TODO: Handle error.
135 }
136
137 resp, err := op.Wait(ctx)
138 if err != nil {
139 // TODO: Handle error.
140 }
141 // TODO: Use resp.
142 _ = resp
143 }
144
145 func ExampleJobClient_CreateJob() {
146 ctx := context.Background()
147 // This snippet has been automatically generated and should be regarded as a code template only.
148 // It will require modifications to work:
149 // - It may require correct/in-range values for request initialization.
150 // - It may require specifying regional endpoints when creating the service client as shown in:
151 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
152 c, err := talent.NewJobClient(ctx)
153 if err != nil {
154 // TODO: Handle error.
155 }
156 defer c.Close()
157
158 req := &talentpb.CreateJobRequest{
159 // TODO: Fill request struct fields.
160 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1/talentpb#CreateJobRequest.
161 }
162 resp, err := c.CreateJob(ctx, req)
163 if err != nil {
164 // TODO: Handle error.
165 }
166 // TODO: Use resp.
167 _ = resp
168 }
169
170 func ExampleJobClient_DeleteJob() {
171 ctx := context.Background()
172 // This snippet has been automatically generated and should be regarded as a code template only.
173 // It will require modifications to work:
174 // - It may require correct/in-range values for request initialization.
175 // - It may require specifying regional endpoints when creating the service client as shown in:
176 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
177 c, err := talent.NewJobClient(ctx)
178 if err != nil {
179 // TODO: Handle error.
180 }
181 defer c.Close()
182
183 req := &talentpb.DeleteJobRequest{
184 // TODO: Fill request struct fields.
185 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1/talentpb#DeleteJobRequest.
186 }
187 err = c.DeleteJob(ctx, req)
188 if err != nil {
189 // TODO: Handle error.
190 }
191 }
192
193 func ExampleJobClient_GetJob() {
194 ctx := context.Background()
195 // This snippet has been automatically generated and should be regarded as a code template only.
196 // It will require modifications to work:
197 // - It may require correct/in-range values for request initialization.
198 // - It may require specifying regional endpoints when creating the service client as shown in:
199 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
200 c, err := talent.NewJobClient(ctx)
201 if err != nil {
202 // TODO: Handle error.
203 }
204 defer c.Close()
205
206 req := &talentpb.GetJobRequest{
207 // TODO: Fill request struct fields.
208 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1/talentpb#GetJobRequest.
209 }
210 resp, err := c.GetJob(ctx, req)
211 if err != nil {
212 // TODO: Handle error.
213 }
214 // TODO: Use resp.
215 _ = resp
216 }
217
218 func ExampleJobClient_ListJobs() {
219 ctx := context.Background()
220 // This snippet has been automatically generated and should be regarded as a code template only.
221 // It will require modifications to work:
222 // - It may require correct/in-range values for request initialization.
223 // - It may require specifying regional endpoints when creating the service client as shown in:
224 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
225 c, err := talent.NewJobClient(ctx)
226 if err != nil {
227 // TODO: Handle error.
228 }
229 defer c.Close()
230
231 req := &talentpb.ListJobsRequest{
232 // TODO: Fill request struct fields.
233 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1/talentpb#ListJobsRequest.
234 }
235 it := c.ListJobs(ctx, req)
236 for {
237 resp, err := it.Next()
238 if err == iterator.Done {
239 break
240 }
241 if err != nil {
242 // TODO: Handle error.
243 }
244 // TODO: Use resp.
245 _ = resp
246
247 // If you need to access the underlying RPC response,
248 // you can do so by casting the `Response` as below.
249 // Otherwise, remove this line. Only populated after
250 // first call to Next(). Not safe for concurrent access.
251 _ = it.Response.(*talentpb.ListJobsResponse)
252 }
253 }
254
255 func ExampleJobClient_SearchJobs() {
256 ctx := context.Background()
257 // This snippet has been automatically generated and should be regarded as a code template only.
258 // It will require modifications to work:
259 // - It may require correct/in-range values for request initialization.
260 // - It may require specifying regional endpoints when creating the service client as shown in:
261 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
262 c, err := talent.NewJobClient(ctx)
263 if err != nil {
264 // TODO: Handle error.
265 }
266 defer c.Close()
267
268 req := &talentpb.SearchJobsRequest{
269 // TODO: Fill request struct fields.
270 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1/talentpb#SearchJobsRequest.
271 }
272 resp, err := c.SearchJobs(ctx, req)
273 if err != nil {
274 // TODO: Handle error.
275 }
276 // TODO: Use resp.
277 _ = resp
278 }
279
280 func ExampleJobClient_SearchJobsForAlert() {
281 ctx := context.Background()
282 // This snippet has been automatically generated and should be regarded as a code template only.
283 // It will require modifications to work:
284 // - It may require correct/in-range values for request initialization.
285 // - It may require specifying regional endpoints when creating the service client as shown in:
286 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
287 c, err := talent.NewJobClient(ctx)
288 if err != nil {
289 // TODO: Handle error.
290 }
291 defer c.Close()
292
293 req := &talentpb.SearchJobsRequest{
294 // TODO: Fill request struct fields.
295 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1/talentpb#SearchJobsRequest.
296 }
297 it := c.SearchJobsForAlert(ctx, req)
298 for {
299 resp, err := it.Next()
300 if err == iterator.Done {
301 break
302 }
303 if err != nil {
304 // TODO: Handle error.
305 }
306 // TODO: Use resp.
307 _ = resp
308
309 // If you need to access the underlying RPC response,
310 // you can do so by casting the `Response` as below.
311 // Otherwise, remove this line. Only populated after
312 // first call to Next(). Not safe for concurrent access.
313 _ = it.Response.(*talentpb.SearchJobsResponse)
314 }
315 }
316
317 func ExampleJobClient_UpdateJob() {
318 ctx := context.Background()
319 // This snippet has been automatically generated and should be regarded as a code template only.
320 // It will require modifications to work:
321 // - It may require correct/in-range values for request initialization.
322 // - It may require specifying regional endpoints when creating the service client as shown in:
323 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
324 c, err := talent.NewJobClient(ctx)
325 if err != nil {
326 // TODO: Handle error.
327 }
328 defer c.Close()
329
330 req := &talentpb.UpdateJobRequest{
331 // TODO: Fill request struct fields.
332 // See https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1/talentpb#UpdateJobRequest.
333 }
334 resp, err := c.UpdateJob(ctx, req)
335 if err != nil {
336 // TODO: Handle error.
337 }
338 // TODO: Use resp.
339 _ = resp
340 }
341
342 func ExampleJobClient_GetOperation() {
343 ctx := context.Background()
344 // This snippet has been automatically generated and should be regarded as a code template only.
345 // It will require modifications to work:
346 // - It may require correct/in-range values for request initialization.
347 // - It may require specifying regional endpoints when creating the service client as shown in:
348 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
349 c, err := talent.NewJobClient(ctx)
350 if err != nil {
351 // TODO: Handle error.
352 }
353 defer c.Close()
354
355 req := &longrunningpb.GetOperationRequest{
356 // TODO: Fill request struct fields.
357 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
358 }
359 resp, err := c.GetOperation(ctx, req)
360 if err != nil {
361 // TODO: Handle error.
362 }
363 // TODO: Use resp.
364 _ = resp
365 }