Debian Codegraph @

datacatalog/lineage/apiv1/lineage_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 lineage_test
18
19 import (
20 "context"
21
22 lineage "cloud.google.com/go/datacatalog/lineage/apiv1"
23 lineagepb "cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb"
24 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
25 "google.golang.org/api/iterator"
26 )
27
28 func ExampleNewClient() {
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 := lineage.NewClient(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 ExampleNewRESTClient() {
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 := lineage.NewRESTClient(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 ExampleClient_BatchSearchLinkProcesses() {
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 := lineage.NewClient(ctx)
70 if err != nil {
71 // TODO: Handle error.
72 }
73 defer c.Close()
74
75 req := &lineagepb.BatchSearchLinkProcessesRequest{
76 // TODO: Fill request struct fields.
77 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#BatchSearchLinkProcessesRequest.
78 }
79 it := c.BatchSearchLinkProcesses(ctx, req)
80 for {
81 resp, err := it.Next()
82 if err == iterator.Done {
83 break
84 }
85 if err != nil {
86 // TODO: Handle error.
87 }
88 // TODO: Use resp.
89 _ = resp
90
91 // If you need to access the underlying RPC response,
92 // you can do so by casting the `Response` as below.
93 // Otherwise, remove this line. Only populated after
94 // first call to Next(). Not safe for concurrent access.
95 _ = it.Response.(*lineagepb.BatchSearchLinkProcessesResponse)
96 }
97 }
98
99 func ExampleClient_CreateLineageEvent() {
100 ctx := context.Background()
101 // This snippet has been automatically generated and should be regarded as a code template only.
102 // It will require modifications to work:
103 // - It may require correct/in-range values for request initialization.
104 // - It may require specifying regional endpoints when creating the service client as shown in:
105 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
106 c, err := lineage.NewClient(ctx)
107 if err != nil {
108 // TODO: Handle error.
109 }
110 defer c.Close()
111
112 req := &lineagepb.CreateLineageEventRequest{
113 // TODO: Fill request struct fields.
114 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#CreateLineageEventRequest.
115 }
116 resp, err := c.CreateLineageEvent(ctx, req)
117 if err != nil {
118 // TODO: Handle error.
119 }
120 // TODO: Use resp.
121 _ = resp
122 }
123
124 func ExampleClient_CreateProcess() {
125 ctx := context.Background()
126 // This snippet has been automatically generated and should be regarded as a code template only.
127 // It will require modifications to work:
128 // - It may require correct/in-range values for request initialization.
129 // - It may require specifying regional endpoints when creating the service client as shown in:
130 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
131 c, err := lineage.NewClient(ctx)
132 if err != nil {
133 // TODO: Handle error.
134 }
135 defer c.Close()
136
137 req := &lineagepb.CreateProcessRequest{
138 // TODO: Fill request struct fields.
139 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#CreateProcessRequest.
140 }
141 resp, err := c.CreateProcess(ctx, req)
142 if err != nil {
143 // TODO: Handle error.
144 }
145 // TODO: Use resp.
146 _ = resp
147 }
148
149 func ExampleClient_CreateRun() {
150 ctx := context.Background()
151 // This snippet has been automatically generated and should be regarded as a code template only.
152 // It will require modifications to work:
153 // - It may require correct/in-range values for request initialization.
154 // - It may require specifying regional endpoints when creating the service client as shown in:
155 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
156 c, err := lineage.NewClient(ctx)
157 if err != nil {
158 // TODO: Handle error.
159 }
160 defer c.Close()
161
162 req := &lineagepb.CreateRunRequest{
163 // TODO: Fill request struct fields.
164 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#CreateRunRequest.
165 }
166 resp, err := c.CreateRun(ctx, req)
167 if err != nil {
168 // TODO: Handle error.
169 }
170 // TODO: Use resp.
171 _ = resp
172 }
173
174 func ExampleClient_DeleteLineageEvent() {
175 ctx := context.Background()
176 // This snippet has been automatically generated and should be regarded as a code template only.
177 // It will require modifications to work:
178 // - It may require correct/in-range values for request initialization.
179 // - It may require specifying regional endpoints when creating the service client as shown in:
180 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
181 c, err := lineage.NewClient(ctx)
182 if err != nil {
183 // TODO: Handle error.
184 }
185 defer c.Close()
186
187 req := &lineagepb.DeleteLineageEventRequest{
188 // TODO: Fill request struct fields.
189 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#DeleteLineageEventRequest.
190 }
191 err = c.DeleteLineageEvent(ctx, req)
192 if err != nil {
193 // TODO: Handle error.
194 }
195 }
196
197 func ExampleClient_DeleteProcess() {
198 ctx := context.Background()
199 // This snippet has been automatically generated and should be regarded as a code template only.
200 // It will require modifications to work:
201 // - It may require correct/in-range values for request initialization.
202 // - It may require specifying regional endpoints when creating the service client as shown in:
203 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
204 c, err := lineage.NewClient(ctx)
205 if err != nil {
206 // TODO: Handle error.
207 }
208 defer c.Close()
209
210 req := &lineagepb.DeleteProcessRequest{
211 // TODO: Fill request struct fields.
212 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#DeleteProcessRequest.
213 }
214 op, err := c.DeleteProcess(ctx, req)
215 if err != nil {
216 // TODO: Handle error.
217 }
218
219 err = op.Wait(ctx)
220 if err != nil {
221 // TODO: Handle error.
222 }
223 }
224
225 func ExampleClient_DeleteRun() {
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 := lineage.NewClient(ctx)
233 if err != nil {
234 // TODO: Handle error.
235 }
236 defer c.Close()
237
238 req := &lineagepb.DeleteRunRequest{
239 // TODO: Fill request struct fields.
240 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#DeleteRunRequest.
241 }
242 op, err := c.DeleteRun(ctx, req)
243 if err != nil {
244 // TODO: Handle error.
245 }
246
247 err = op.Wait(ctx)
248 if err != nil {
249 // TODO: Handle error.
250 }
251 }
252
253 func ExampleClient_GetLineageEvent() {
254 ctx := context.Background()
255 // This snippet has been automatically generated and should be regarded as a code template only.
256 // It will require modifications to work:
257 // - It may require correct/in-range values for request initialization.
258 // - It may require specifying regional endpoints when creating the service client as shown in:
259 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
260 c, err := lineage.NewClient(ctx)
261 if err != nil {
262 // TODO: Handle error.
263 }
264 defer c.Close()
265
266 req := &lineagepb.GetLineageEventRequest{
267 // TODO: Fill request struct fields.
268 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#GetLineageEventRequest.
269 }
270 resp, err := c.GetLineageEvent(ctx, req)
271 if err != nil {
272 // TODO: Handle error.
273 }
274 // TODO: Use resp.
275 _ = resp
276 }
277
278 func ExampleClient_GetProcess() {
279 ctx := context.Background()
280 // This snippet has been automatically generated and should be regarded as a code template only.
281 // It will require modifications to work:
282 // - It may require correct/in-range values for request initialization.
283 // - It may require specifying regional endpoints when creating the service client as shown in:
284 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
285 c, err := lineage.NewClient(ctx)
286 if err != nil {
287 // TODO: Handle error.
288 }
289 defer c.Close()
290
291 req := &lineagepb.GetProcessRequest{
292 // TODO: Fill request struct fields.
293 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#GetProcessRequest.
294 }
295 resp, err := c.GetProcess(ctx, req)
296 if err != nil {
297 // TODO: Handle error.
298 }
299 // TODO: Use resp.
300 _ = resp
301 }
302
303 func ExampleClient_GetRun() {
304 ctx := context.Background()
305 // This snippet has been automatically generated and should be regarded as a code template only.
306 // It will require modifications to work:
307 // - It may require correct/in-range values for request initialization.
308 // - It may require specifying regional endpoints when creating the service client as shown in:
309 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
310 c, err := lineage.NewClient(ctx)
311 if err != nil {
312 // TODO: Handle error.
313 }
314 defer c.Close()
315
316 req := &lineagepb.GetRunRequest{
317 // TODO: Fill request struct fields.
318 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#GetRunRequest.
319 }
320 resp, err := c.GetRun(ctx, req)
321 if err != nil {
322 // TODO: Handle error.
323 }
324 // TODO: Use resp.
325 _ = resp
326 }
327
328 func ExampleClient_ListLineageEvents() {
329 ctx := context.Background()
330 // This snippet has been automatically generated and should be regarded as a code template only.
331 // It will require modifications to work:
332 // - It may require correct/in-range values for request initialization.
333 // - It may require specifying regional endpoints when creating the service client as shown in:
334 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
335 c, err := lineage.NewClient(ctx)
336 if err != nil {
337 // TODO: Handle error.
338 }
339 defer c.Close()
340
341 req := &lineagepb.ListLineageEventsRequest{
342 // TODO: Fill request struct fields.
343 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#ListLineageEventsRequest.
344 }
345 it := c.ListLineageEvents(ctx, req)
346 for {
347 resp, err := it.Next()
348 if err == iterator.Done {
349 break
350 }
351 if err != nil {
352 // TODO: Handle error.
353 }
354 // TODO: Use resp.
355 _ = resp
356
357 // If you need to access the underlying RPC response,
358 // you can do so by casting the `Response` as below.
359 // Otherwise, remove this line. Only populated after
360 // first call to Next(). Not safe for concurrent access.
361 _ = it.Response.(*lineagepb.ListLineageEventsResponse)
362 }
363 }
364
365 func ExampleClient_ListProcesses() {
366 ctx := context.Background()
367 // This snippet has been automatically generated and should be regarded as a code template only.
368 // It will require modifications to work:
369 // - It may require correct/in-range values for request initialization.
370 // - It may require specifying regional endpoints when creating the service client as shown in:
371 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
372 c, err := lineage.NewClient(ctx)
373 if err != nil {
374 // TODO: Handle error.
375 }
376 defer c.Close()
377
378 req := &lineagepb.ListProcessesRequest{
379 // TODO: Fill request struct fields.
380 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#ListProcessesRequest.
381 }
382 it := c.ListProcesses(ctx, req)
383 for {
384 resp, err := it.Next()
385 if err == iterator.Done {
386 break
387 }
388 if err != nil {
389 // TODO: Handle error.
390 }
391 // TODO: Use resp.
392 _ = resp
393
394 // If you need to access the underlying RPC response,
395 // you can do so by casting the `Response` as below.
396 // Otherwise, remove this line. Only populated after
397 // first call to Next(). Not safe for concurrent access.
398 _ = it.Response.(*lineagepb.ListProcessesResponse)
399 }
400 }
401
402 func ExampleClient_ListRuns() {
403 ctx := context.Background()
404 // This snippet has been automatically generated and should be regarded as a code template only.
405 // It will require modifications to work:
406 // - It may require correct/in-range values for request initialization.
407 // - It may require specifying regional endpoints when creating the service client as shown in:
408 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
409 c, err := lineage.NewClient(ctx)
410 if err != nil {
411 // TODO: Handle error.
412 }
413 defer c.Close()
414
415 req := &lineagepb.ListRunsRequest{
416 // TODO: Fill request struct fields.
417 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#ListRunsRequest.
418 }
419 it := c.ListRuns(ctx, req)
420 for {
421 resp, err := it.Next()
422 if err == iterator.Done {
423 break
424 }
425 if err != nil {
426 // TODO: Handle error.
427 }
428 // TODO: Use resp.
429 _ = resp
430
431 // If you need to access the underlying RPC response,
432 // you can do so by casting the `Response` as below.
433 // Otherwise, remove this line. Only populated after
434 // first call to Next(). Not safe for concurrent access.
435 _ = it.Response.(*lineagepb.ListRunsResponse)
436 }
437 }
438
439 func ExampleClient_ProcessOpenLineageRunEvent() {
440 ctx := context.Background()
441 // This snippet has been automatically generated and should be regarded as a code template only.
442 // It will require modifications to work:
443 // - It may require correct/in-range values for request initialization.
444 // - It may require specifying regional endpoints when creating the service client as shown in:
445 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
446 c, err := lineage.NewClient(ctx)
447 if err != nil {
448 // TODO: Handle error.
449 }
450 defer c.Close()
451
452 req := &lineagepb.ProcessOpenLineageRunEventRequest{
453 // TODO: Fill request struct fields.
454 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#ProcessOpenLineageRunEventRequest.
455 }
456 resp, err := c.ProcessOpenLineageRunEvent(ctx, req)
457 if err != nil {
458 // TODO: Handle error.
459 }
460 // TODO: Use resp.
461 _ = resp
462 }
463
464 func ExampleClient_SearchLinks() {
465 ctx := context.Background()
466 // This snippet has been automatically generated and should be regarded as a code template only.
467 // It will require modifications to work:
468 // - It may require correct/in-range values for request initialization.
469 // - It may require specifying regional endpoints when creating the service client as shown in:
470 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
471 c, err := lineage.NewClient(ctx)
472 if err != nil {
473 // TODO: Handle error.
474 }
475 defer c.Close()
476
477 req := &lineagepb.SearchLinksRequest{
478 // TODO: Fill request struct fields.
479 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#SearchLinksRequest.
480 }
481 it := c.SearchLinks(ctx, req)
482 for {
483 resp, err := it.Next()
484 if err == iterator.Done {
485 break
486 }
487 if err != nil {
488 // TODO: Handle error.
489 }
490 // TODO: Use resp.
491 _ = resp
492
493 // If you need to access the underlying RPC response,
494 // you can do so by casting the `Response` as below.
495 // Otherwise, remove this line. Only populated after
496 // first call to Next(). Not safe for concurrent access.
497 _ = it.Response.(*lineagepb.SearchLinksResponse)
498 }
499 }
500
501 func ExampleClient_UpdateProcess() {
502 ctx := context.Background()
503 // This snippet has been automatically generated and should be regarded as a code template only.
504 // It will require modifications to work:
505 // - It may require correct/in-range values for request initialization.
506 // - It may require specifying regional endpoints when creating the service client as shown in:
507 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
508 c, err := lineage.NewClient(ctx)
509 if err != nil {
510 // TODO: Handle error.
511 }
512 defer c.Close()
513
514 req := &lineagepb.UpdateProcessRequest{
515 // TODO: Fill request struct fields.
516 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#UpdateProcessRequest.
517 }
518 resp, err := c.UpdateProcess(ctx, req)
519 if err != nil {
520 // TODO: Handle error.
521 }
522 // TODO: Use resp.
523 _ = resp
524 }
525
526 func ExampleClient_UpdateRun() {
527 ctx := context.Background()
528 // This snippet has been automatically generated and should be regarded as a code template only.
529 // It will require modifications to work:
530 // - It may require correct/in-range values for request initialization.
531 // - It may require specifying regional endpoints when creating the service client as shown in:
532 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
533 c, err := lineage.NewClient(ctx)
534 if err != nil {
535 // TODO: Handle error.
536 }
537 defer c.Close()
538
539 req := &lineagepb.UpdateRunRequest{
540 // TODO: Fill request struct fields.
541 // See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#UpdateRunRequest.
542 }
543 resp, err := c.UpdateRun(ctx, req)
544 if err != nil {
545 // TODO: Handle error.
546 }
547 // TODO: Use resp.
548 _ = resp
549 }
550
551 func ExampleClient_CancelOperation() {
552 ctx := context.Background()
553 // This snippet has been automatically generated and should be regarded as a code template only.
554 // It will require modifications to work:
555 // - It may require correct/in-range values for request initialization.
556 // - It may require specifying regional endpoints when creating the service client as shown in:
557 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
558 c, err := lineage.NewClient(ctx)
559 if err != nil {
560 // TODO: Handle error.
561 }
562 defer c.Close()
563
564 req := &longrunningpb.CancelOperationRequest{
565 // TODO: Fill request struct fields.
566 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
567 }
568 err = c.CancelOperation(ctx, req)
569 if err != nil {
570 // TODO: Handle error.
571 }
572 }
573
574 func ExampleClient_DeleteOperation() {
575 ctx := context.Background()
576 // This snippet has been automatically generated and should be regarded as a code template only.
577 // It will require modifications to work:
578 // - It may require correct/in-range values for request initialization.
579 // - It may require specifying regional endpoints when creating the service client as shown in:
580 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
581 c, err := lineage.NewClient(ctx)
582 if err != nil {
583 // TODO: Handle error.
584 }
585 defer c.Close()
586
587 req := &longrunningpb.DeleteOperationRequest{
588 // TODO: Fill request struct fields.
589 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
590 }
591 err = c.DeleteOperation(ctx, req)
592 if err != nil {
593 // TODO: Handle error.
594 }
595 }
596
597 func ExampleClient_GetOperation() {
598 ctx := context.Background()
599 // This snippet has been automatically generated and should be regarded as a code template only.
600 // It will require modifications to work:
601 // - It may require correct/in-range values for request initialization.
602 // - It may require specifying regional endpoints when creating the service client as shown in:
603 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
604 c, err := lineage.NewClient(ctx)
605 if err != nil {
606 // TODO: Handle error.
607 }
608 defer c.Close()
609
610 req := &longrunningpb.GetOperationRequest{
611 // TODO: Fill request struct fields.
612 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
613 }
614 resp, err := c.GetOperation(ctx, req)
615 if err != nil {
616 // TODO: Handle error.
617 }
618 // TODO: Use resp.
619 _ = resp
620 }
621
622 func ExampleClient_ListOperations() {
623 ctx := context.Background()
624 // This snippet has been automatically generated and should be regarded as a code template only.
625 // It will require modifications to work:
626 // - It may require correct/in-range values for request initialization.
627 // - It may require specifying regional endpoints when creating the service client as shown in:
628 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
629 c, err := lineage.NewClient(ctx)
630 if err != nil {
631 // TODO: Handle error.
632 }
633 defer c.Close()
634
635 req := &longrunningpb.ListOperationsRequest{
636 // TODO: Fill request struct fields.
637 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
638 }
639 it := c.ListOperations(ctx, req)
640 for {
641 resp, err := it.Next()
642 if err == iterator.Done {
643 break
644 }
645 if err != nil {
646 // TODO: Handle error.
647 }
648 // TODO: Use resp.
649 _ = resp
650
651 // If you need to access the underlying RPC response,
652 // you can do so by casting the `Response` as below.
653 // Otherwise, remove this line. Only populated after
654 // first call to Next(). Not safe for concurrent access.
655 _ = it.Response.(*longrunningpb.ListOperationsResponse)
656 }
657 }