Debian Codegraph @

networkservices/apiv1/dep_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 networkservices_test
18
19 import (
20 "context"
21
22 iampb "cloud.google.com/go/iam/apiv1/iampb"
23 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
24 networkservices "cloud.google.com/go/networkservices/apiv1"
25 networkservicespb "cloud.google.com/go/networkservices/apiv1/networkservicespb"
26 "google.golang.org/api/iterator"
27 locationpb "google.golang.org/genproto/googleapis/cloud/location"
28 )
29
30 func ExampleNewDepClient() {
31 ctx := context.Background()
32 // This snippet has been automatically generated and should be regarded as a code template only.
33 // It will require modifications to work:
34 // - It may require correct/in-range values for request initialization.
35 // - It may require specifying regional endpoints when creating the service client as shown in:
36 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
37 c, err := networkservices.NewDepClient(ctx)
38 if err != nil {
39 // TODO: Handle error.
40 }
41 defer c.Close()
42
43 // TODO: Use client.
44 _ = c
45 }
46
47 func ExampleNewDepRESTClient() {
48 ctx := context.Background()
49 // This snippet has been automatically generated and should be regarded as a code template only.
50 // It will require modifications to work:
51 // - It may require correct/in-range values for request initialization.
52 // - It may require specifying regional endpoints when creating the service client as shown in:
53 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
54 c, err := networkservices.NewDepRESTClient(ctx)
55 if err != nil {
56 // TODO: Handle error.
57 }
58 defer c.Close()
59
60 // TODO: Use client.
61 _ = c
62 }
63
64 func ExampleDepClient_CreateAuthzExtension() {
65 ctx := context.Background()
66 // This snippet has been automatically generated and should be regarded as a code template only.
67 // It will require modifications to work:
68 // - It may require correct/in-range values for request initialization.
69 // - It may require specifying regional endpoints when creating the service client as shown in:
70 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
71 c, err := networkservices.NewDepClient(ctx)
72 if err != nil {
73 // TODO: Handle error.
74 }
75 defer c.Close()
76
77 req := &networkservicespb.CreateAuthzExtensionRequest{
78 // TODO: Fill request struct fields.
79 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#CreateAuthzExtensionRequest.
80 }
81 op, err := c.CreateAuthzExtension(ctx, req)
82 if err != nil {
83 // TODO: Handle error.
84 }
85
86 resp, err := op.Wait(ctx)
87 if err != nil {
88 // TODO: Handle error.
89 }
90 // TODO: Use resp.
91 _ = resp
92 }
93
94 func ExampleDepClient_CreateLbRouteExtension() {
95 ctx := context.Background()
96 // This snippet has been automatically generated and should be regarded as a code template only.
97 // It will require modifications to work:
98 // - It may require correct/in-range values for request initialization.
99 // - It may require specifying regional endpoints when creating the service client as shown in:
100 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
101 c, err := networkservices.NewDepClient(ctx)
102 if err != nil {
103 // TODO: Handle error.
104 }
105 defer c.Close()
106
107 req := &networkservicespb.CreateLbRouteExtensionRequest{
108 // TODO: Fill request struct fields.
109 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#CreateLbRouteExtensionRequest.
110 }
111 op, err := c.CreateLbRouteExtension(ctx, req)
112 if err != nil {
113 // TODO: Handle error.
114 }
115
116 resp, err := op.Wait(ctx)
117 if err != nil {
118 // TODO: Handle error.
119 }
120 // TODO: Use resp.
121 _ = resp
122 }
123
124 func ExampleDepClient_CreateLbTrafficExtension() {
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 := networkservices.NewDepClient(ctx)
132 if err != nil {
133 // TODO: Handle error.
134 }
135 defer c.Close()
136
137 req := &networkservicespb.CreateLbTrafficExtensionRequest{
138 // TODO: Fill request struct fields.
139 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#CreateLbTrafficExtensionRequest.
140 }
141 op, err := c.CreateLbTrafficExtension(ctx, req)
142 if err != nil {
143 // TODO: Handle error.
144 }
145
146 resp, err := op.Wait(ctx)
147 if err != nil {
148 // TODO: Handle error.
149 }
150 // TODO: Use resp.
151 _ = resp
152 }
153
154 func ExampleDepClient_DeleteAuthzExtension() {
155 ctx := context.Background()
156 // This snippet has been automatically generated and should be regarded as a code template only.
157 // It will require modifications to work:
158 // - It may require correct/in-range values for request initialization.
159 // - It may require specifying regional endpoints when creating the service client as shown in:
160 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
161 c, err := networkservices.NewDepClient(ctx)
162 if err != nil {
163 // TODO: Handle error.
164 }
165 defer c.Close()
166
167 req := &networkservicespb.DeleteAuthzExtensionRequest{
168 // TODO: Fill request struct fields.
169 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#DeleteAuthzExtensionRequest.
170 }
171 op, err := c.DeleteAuthzExtension(ctx, req)
172 if err != nil {
173 // TODO: Handle error.
174 }
175
176 err = op.Wait(ctx)
177 if err != nil {
178 // TODO: Handle error.
179 }
180 }
181
182 func ExampleDepClient_DeleteLbRouteExtension() {
183 ctx := context.Background()
184 // This snippet has been automatically generated and should be regarded as a code template only.
185 // It will require modifications to work:
186 // - It may require correct/in-range values for request initialization.
187 // - It may require specifying regional endpoints when creating the service client as shown in:
188 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
189 c, err := networkservices.NewDepClient(ctx)
190 if err != nil {
191 // TODO: Handle error.
192 }
193 defer c.Close()
194
195 req := &networkservicespb.DeleteLbRouteExtensionRequest{
196 // TODO: Fill request struct fields.
197 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#DeleteLbRouteExtensionRequest.
198 }
199 op, err := c.DeleteLbRouteExtension(ctx, req)
200 if err != nil {
201 // TODO: Handle error.
202 }
203
204 err = op.Wait(ctx)
205 if err != nil {
206 // TODO: Handle error.
207 }
208 }
209
210 func ExampleDepClient_DeleteLbTrafficExtension() {
211 ctx := context.Background()
212 // This snippet has been automatically generated and should be regarded as a code template only.
213 // It will require modifications to work:
214 // - It may require correct/in-range values for request initialization.
215 // - It may require specifying regional endpoints when creating the service client as shown in:
216 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
217 c, err := networkservices.NewDepClient(ctx)
218 if err != nil {
219 // TODO: Handle error.
220 }
221 defer c.Close()
222
223 req := &networkservicespb.DeleteLbTrafficExtensionRequest{
224 // TODO: Fill request struct fields.
225 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#DeleteLbTrafficExtensionRequest.
226 }
227 op, err := c.DeleteLbTrafficExtension(ctx, req)
228 if err != nil {
229 // TODO: Handle error.
230 }
231
232 err = op.Wait(ctx)
233 if err != nil {
234 // TODO: Handle error.
235 }
236 }
237
238 func ExampleDepClient_GetAuthzExtension() {
239 ctx := context.Background()
240 // This snippet has been automatically generated and should be regarded as a code template only.
241 // It will require modifications to work:
242 // - It may require correct/in-range values for request initialization.
243 // - It may require specifying regional endpoints when creating the service client as shown in:
244 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
245 c, err := networkservices.NewDepClient(ctx)
246 if err != nil {
247 // TODO: Handle error.
248 }
249 defer c.Close()
250
251 req := &networkservicespb.GetAuthzExtensionRequest{
252 // TODO: Fill request struct fields.
253 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#GetAuthzExtensionRequest.
254 }
255 resp, err := c.GetAuthzExtension(ctx, req)
256 if err != nil {
257 // TODO: Handle error.
258 }
259 // TODO: Use resp.
260 _ = resp
261 }
262
263 func ExampleDepClient_GetLbRouteExtension() {
264 ctx := context.Background()
265 // This snippet has been automatically generated and should be regarded as a code template only.
266 // It will require modifications to work:
267 // - It may require correct/in-range values for request initialization.
268 // - It may require specifying regional endpoints when creating the service client as shown in:
269 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
270 c, err := networkservices.NewDepClient(ctx)
271 if err != nil {
272 // TODO: Handle error.
273 }
274 defer c.Close()
275
276 req := &networkservicespb.GetLbRouteExtensionRequest{
277 // TODO: Fill request struct fields.
278 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#GetLbRouteExtensionRequest.
279 }
280 resp, err := c.GetLbRouteExtension(ctx, req)
281 if err != nil {
282 // TODO: Handle error.
283 }
284 // TODO: Use resp.
285 _ = resp
286 }
287
288 func ExampleDepClient_GetLbTrafficExtension() {
289 ctx := context.Background()
290 // This snippet has been automatically generated and should be regarded as a code template only.
291 // It will require modifications to work:
292 // - It may require correct/in-range values for request initialization.
293 // - It may require specifying regional endpoints when creating the service client as shown in:
294 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
295 c, err := networkservices.NewDepClient(ctx)
296 if err != nil {
297 // TODO: Handle error.
298 }
299 defer c.Close()
300
301 req := &networkservicespb.GetLbTrafficExtensionRequest{
302 // TODO: Fill request struct fields.
303 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#GetLbTrafficExtensionRequest.
304 }
305 resp, err := c.GetLbTrafficExtension(ctx, req)
306 if err != nil {
307 // TODO: Handle error.
308 }
309 // TODO: Use resp.
310 _ = resp
311 }
312
313 func ExampleDepClient_ListAuthzExtensions() {
314 ctx := context.Background()
315 // This snippet has been automatically generated and should be regarded as a code template only.
316 // It will require modifications to work:
317 // - It may require correct/in-range values for request initialization.
318 // - It may require specifying regional endpoints when creating the service client as shown in:
319 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
320 c, err := networkservices.NewDepClient(ctx)
321 if err != nil {
322 // TODO: Handle error.
323 }
324 defer c.Close()
325
326 req := &networkservicespb.ListAuthzExtensionsRequest{
327 // TODO: Fill request struct fields.
328 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListAuthzExtensionsRequest.
329 }
330 it := c.ListAuthzExtensions(ctx, req)
331 for {
332 resp, err := it.Next()
333 if err == iterator.Done {
334 break
335 }
336 if err != nil {
337 // TODO: Handle error.
338 }
339 // TODO: Use resp.
340 _ = resp
341
342 // If you need to access the underlying RPC response,
343 // you can do so by casting the `Response` as below.
344 // Otherwise, remove this line. Only populated after
345 // first call to Next(). Not safe for concurrent access.
346 _ = it.Response.(*networkservicespb.ListAuthzExtensionsResponse)
347 }
348 }
349
350 func ExampleDepClient_ListLbRouteExtensions() {
351 ctx := context.Background()
352 // This snippet has been automatically generated and should be regarded as a code template only.
353 // It will require modifications to work:
354 // - It may require correct/in-range values for request initialization.
355 // - It may require specifying regional endpoints when creating the service client as shown in:
356 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
357 c, err := networkservices.NewDepClient(ctx)
358 if err != nil {
359 // TODO: Handle error.
360 }
361 defer c.Close()
362
363 req := &networkservicespb.ListLbRouteExtensionsRequest{
364 // TODO: Fill request struct fields.
365 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListLbRouteExtensionsRequest.
366 }
367 it := c.ListLbRouteExtensions(ctx, req)
368 for {
369 resp, err := it.Next()
370 if err == iterator.Done {
371 break
372 }
373 if err != nil {
374 // TODO: Handle error.
375 }
376 // TODO: Use resp.
377 _ = resp
378
379 // If you need to access the underlying RPC response,
380 // you can do so by casting the `Response` as below.
381 // Otherwise, remove this line. Only populated after
382 // first call to Next(). Not safe for concurrent access.
383 _ = it.Response.(*networkservicespb.ListLbRouteExtensionsResponse)
384 }
385 }
386
387 func ExampleDepClient_ListLbTrafficExtensions() {
388 ctx := context.Background()
389 // This snippet has been automatically generated and should be regarded as a code template only.
390 // It will require modifications to work:
391 // - It may require correct/in-range values for request initialization.
392 // - It may require specifying regional endpoints when creating the service client as shown in:
393 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
394 c, err := networkservices.NewDepClient(ctx)
395 if err != nil {
396 // TODO: Handle error.
397 }
398 defer c.Close()
399
400 req := &networkservicespb.ListLbTrafficExtensionsRequest{
401 // TODO: Fill request struct fields.
402 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListLbTrafficExtensionsRequest.
403 }
404 it := c.ListLbTrafficExtensions(ctx, req)
405 for {
406 resp, err := it.Next()
407 if err == iterator.Done {
408 break
409 }
410 if err != nil {
411 // TODO: Handle error.
412 }
413 // TODO: Use resp.
414 _ = resp
415
416 // If you need to access the underlying RPC response,
417 // you can do so by casting the `Response` as below.
418 // Otherwise, remove this line. Only populated after
419 // first call to Next(). Not safe for concurrent access.
420 _ = it.Response.(*networkservicespb.ListLbTrafficExtensionsResponse)
421 }
422 }
423
424 func ExampleDepClient_UpdateAuthzExtension() {
425 ctx := context.Background()
426 // This snippet has been automatically generated and should be regarded as a code template only.
427 // It will require modifications to work:
428 // - It may require correct/in-range values for request initialization.
429 // - It may require specifying regional endpoints when creating the service client as shown in:
430 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
431 c, err := networkservices.NewDepClient(ctx)
432 if err != nil {
433 // TODO: Handle error.
434 }
435 defer c.Close()
436
437 req := &networkservicespb.UpdateAuthzExtensionRequest{
438 // TODO: Fill request struct fields.
439 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#UpdateAuthzExtensionRequest.
440 }
441 op, err := c.UpdateAuthzExtension(ctx, req)
442 if err != nil {
443 // TODO: Handle error.
444 }
445
446 resp, err := op.Wait(ctx)
447 if err != nil {
448 // TODO: Handle error.
449 }
450 // TODO: Use resp.
451 _ = resp
452 }
453
454 func ExampleDepClient_UpdateLbRouteExtension() {
455 ctx := context.Background()
456 // This snippet has been automatically generated and should be regarded as a code template only.
457 // It will require modifications to work:
458 // - It may require correct/in-range values for request initialization.
459 // - It may require specifying regional endpoints when creating the service client as shown in:
460 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
461 c, err := networkservices.NewDepClient(ctx)
462 if err != nil {
463 // TODO: Handle error.
464 }
465 defer c.Close()
466
467 req := &networkservicespb.UpdateLbRouteExtensionRequest{
468 // TODO: Fill request struct fields.
469 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#UpdateLbRouteExtensionRequest.
470 }
471 op, err := c.UpdateLbRouteExtension(ctx, req)
472 if err != nil {
473 // TODO: Handle error.
474 }
475
476 resp, err := op.Wait(ctx)
477 if err != nil {
478 // TODO: Handle error.
479 }
480 // TODO: Use resp.
481 _ = resp
482 }
483
484 func ExampleDepClient_UpdateLbTrafficExtension() {
485 ctx := context.Background()
486 // This snippet has been automatically generated and should be regarded as a code template only.
487 // It will require modifications to work:
488 // - It may require correct/in-range values for request initialization.
489 // - It may require specifying regional endpoints when creating the service client as shown in:
490 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
491 c, err := networkservices.NewDepClient(ctx)
492 if err != nil {
493 // TODO: Handle error.
494 }
495 defer c.Close()
496
497 req := &networkservicespb.UpdateLbTrafficExtensionRequest{
498 // TODO: Fill request struct fields.
499 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#UpdateLbTrafficExtensionRequest.
500 }
501 op, err := c.UpdateLbTrafficExtension(ctx, req)
502 if err != nil {
503 // TODO: Handle error.
504 }
505
506 resp, err := op.Wait(ctx)
507 if err != nil {
508 // TODO: Handle error.
509 }
510 // TODO: Use resp.
511 _ = resp
512 }
513
514 func ExampleDepClient_GetLocation() {
515 ctx := context.Background()
516 // This snippet has been automatically generated and should be regarded as a code template only.
517 // It will require modifications to work:
518 // - It may require correct/in-range values for request initialization.
519 // - It may require specifying regional endpoints when creating the service client as shown in:
520 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
521 c, err := networkservices.NewDepClient(ctx)
522 if err != nil {
523 // TODO: Handle error.
524 }
525 defer c.Close()
526
527 req := &locationpb.GetLocationRequest{
528 // TODO: Fill request struct fields.
529 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
530 }
531 resp, err := c.GetLocation(ctx, req)
532 if err != nil {
533 // TODO: Handle error.
534 }
535 // TODO: Use resp.
536 _ = resp
537 }
538
539 func ExampleDepClient_ListLocations() {
540 ctx := context.Background()
541 // This snippet has been automatically generated and should be regarded as a code template only.
542 // It will require modifications to work:
543 // - It may require correct/in-range values for request initialization.
544 // - It may require specifying regional endpoints when creating the service client as shown in:
545 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
546 c, err := networkservices.NewDepClient(ctx)
547 if err != nil {
548 // TODO: Handle error.
549 }
550 defer c.Close()
551
552 req := &locationpb.ListLocationsRequest{
553 // TODO: Fill request struct fields.
554 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
555 }
556 it := c.ListLocations(ctx, req)
557 for {
558 resp, err := it.Next()
559 if err == iterator.Done {
560 break
561 }
562 if err != nil {
563 // TODO: Handle error.
564 }
565 // TODO: Use resp.
566 _ = resp
567
568 // If you need to access the underlying RPC response,
569 // you can do so by casting the `Response` as below.
570 // Otherwise, remove this line. Only populated after
571 // first call to Next(). Not safe for concurrent access.
572 _ = it.Response.(*locationpb.ListLocationsResponse)
573 }
574 }
575
576 func ExampleDepClient_GetIamPolicy() {
577 ctx := context.Background()
578 // This snippet has been automatically generated and should be regarded as a code template only.
579 // It will require modifications to work:
580 // - It may require correct/in-range values for request initialization.
581 // - It may require specifying regional endpoints when creating the service client as shown in:
582 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
583 c, err := networkservices.NewDepClient(ctx)
584 if err != nil {
585 // TODO: Handle error.
586 }
587 defer c.Close()
588
589 req := &iampb.GetIamPolicyRequest{
590 // TODO: Fill request struct fields.
591 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
592 }
593 resp, err := c.GetIamPolicy(ctx, req)
594 if err != nil {
595 // TODO: Handle error.
596 }
597 // TODO: Use resp.
598 _ = resp
599 }
600
601 func ExampleDepClient_SetIamPolicy() {
602 ctx := context.Background()
603 // This snippet has been automatically generated and should be regarded as a code template only.
604 // It will require modifications to work:
605 // - It may require correct/in-range values for request initialization.
606 // - It may require specifying regional endpoints when creating the service client as shown in:
607 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
608 c, err := networkservices.NewDepClient(ctx)
609 if err != nil {
610 // TODO: Handle error.
611 }
612 defer c.Close()
613
614 req := &iampb.SetIamPolicyRequest{
615 // TODO: Fill request struct fields.
616 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
617 }
618 resp, err := c.SetIamPolicy(ctx, req)
619 if err != nil {
620 // TODO: Handle error.
621 }
622 // TODO: Use resp.
623 _ = resp
624 }
625
626 func ExampleDepClient_TestIamPermissions() {
627 ctx := context.Background()
628 // This snippet has been automatically generated and should be regarded as a code template only.
629 // It will require modifications to work:
630 // - It may require correct/in-range values for request initialization.
631 // - It may require specifying regional endpoints when creating the service client as shown in:
632 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
633 c, err := networkservices.NewDepClient(ctx)
634 if err != nil {
635 // TODO: Handle error.
636 }
637 defer c.Close()
638
639 req := &iampb.TestIamPermissionsRequest{
640 // TODO: Fill request struct fields.
641 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
642 }
643 resp, err := c.TestIamPermissions(ctx, req)
644 if err != nil {
645 // TODO: Handle error.
646 }
647 // TODO: Use resp.
648 _ = resp
649 }
650
651 func ExampleDepClient_CancelOperation() {
652 ctx := context.Background()
653 // This snippet has been automatically generated and should be regarded as a code template only.
654 // It will require modifications to work:
655 // - It may require correct/in-range values for request initialization.
656 // - It may require specifying regional endpoints when creating the service client as shown in:
657 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
658 c, err := networkservices.NewDepClient(ctx)
659 if err != nil {
660 // TODO: Handle error.
661 }
662 defer c.Close()
663
664 req := &longrunningpb.CancelOperationRequest{
665 // TODO: Fill request struct fields.
666 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
667 }
668 err = c.CancelOperation(ctx, req)
669 if err != nil {
670 // TODO: Handle error.
671 }
672 }
673
674 func ExampleDepClient_DeleteOperation() {
675 ctx := context.Background()
676 // This snippet has been automatically generated and should be regarded as a code template only.
677 // It will require modifications to work:
678 // - It may require correct/in-range values for request initialization.
679 // - It may require specifying regional endpoints when creating the service client as shown in:
680 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
681 c, err := networkservices.NewDepClient(ctx)
682 if err != nil {
683 // TODO: Handle error.
684 }
685 defer c.Close()
686
687 req := &longrunningpb.DeleteOperationRequest{
688 // TODO: Fill request struct fields.
689 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
690 }
691 err = c.DeleteOperation(ctx, req)
692 if err != nil {
693 // TODO: Handle error.
694 }
695 }
696
697 func ExampleDepClient_GetOperation() {
698 ctx := context.Background()
699 // This snippet has been automatically generated and should be regarded as a code template only.
700 // It will require modifications to work:
701 // - It may require correct/in-range values for request initialization.
702 // - It may require specifying regional endpoints when creating the service client as shown in:
703 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
704 c, err := networkservices.NewDepClient(ctx)
705 if err != nil {
706 // TODO: Handle error.
707 }
708 defer c.Close()
709
710 req := &longrunningpb.GetOperationRequest{
711 // TODO: Fill request struct fields.
712 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
713 }
714 resp, err := c.GetOperation(ctx, req)
715 if err != nil {
716 // TODO: Handle error.
717 }
718 // TODO: Use resp.
719 _ = resp
720 }
721
722 func ExampleDepClient_ListOperations() {
723 ctx := context.Background()
724 // This snippet has been automatically generated and should be regarded as a code template only.
725 // It will require modifications to work:
726 // - It may require correct/in-range values for request initialization.
727 // - It may require specifying regional endpoints when creating the service client as shown in:
728 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
729 c, err := networkservices.NewDepClient(ctx)
730 if err != nil {
731 // TODO: Handle error.
732 }
733 defer c.Close()
734
735 req := &longrunningpb.ListOperationsRequest{
736 // TODO: Fill request struct fields.
737 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
738 }
739 it := c.ListOperations(ctx, req)
740 for {
741 resp, err := it.Next()
742 if err == iterator.Done {
743 break
744 }
745 if err != nil {
746 // TODO: Handle error.
747 }
748 // TODO: Use resp.
749 _ = resp
750
751 // If you need to access the underlying RPC response,
752 // you can do so by casting the `Response` as below.
753 // Otherwise, remove this line. Only populated after
754 // first call to Next(). Not safe for concurrent access.
755 _ = it.Response.(*longrunningpb.ListOperationsResponse)
756 }
757 }