Debian Codegraph @

apihub/apiv1/api_hub_plugin_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 apihub_test
18
19 import (
20 "context"
21
22 apihub "cloud.google.com/go/apihub/apiv1"
23 apihubpb "cloud.google.com/go/apihub/apiv1/apihubpb"
24 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
25 "google.golang.org/api/iterator"
26 locationpb "google.golang.org/genproto/googleapis/cloud/location"
27 )
28
29 func ExampleNewApiHubPluginRESTClient() {
30 ctx := context.Background()
31 // This snippet has been automatically generated and should be regarded as a code template only.
32 // It will require modifications to work:
33 // - It may require correct/in-range values for request initialization.
34 // - It may require specifying regional endpoints when creating the service client as shown in:
35 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
36 c, err := apihub.NewApiHubPluginRESTClient(ctx)
37 if err != nil {
38 // TODO: Handle error.
39 }
40 defer c.Close()
41
42 // TODO: Use client.
43 _ = c
44 }
45
46 func ExampleApiHubPluginClient_CreatePlugin() {
47 ctx := context.Background()
48 // This snippet has been automatically generated and should be regarded as a code template only.
49 // It will require modifications to work:
50 // - It may require correct/in-range values for request initialization.
51 // - It may require specifying regional endpoints when creating the service client as shown in:
52 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
53 c, err := apihub.NewApiHubPluginRESTClient(ctx)
54 if err != nil {
55 // TODO: Handle error.
56 }
57 defer c.Close()
58
59 req := &apihubpb.CreatePluginRequest{
60 // TODO: Fill request struct fields.
61 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#CreatePluginRequest.
62 }
63 resp, err := c.CreatePlugin(ctx, req)
64 if err != nil {
65 // TODO: Handle error.
66 }
67 // TODO: Use resp.
68 _ = resp
69 }
70
71 func ExampleApiHubPluginClient_CreatePluginInstance() {
72 ctx := context.Background()
73 // This snippet has been automatically generated and should be regarded as a code template only.
74 // It will require modifications to work:
75 // - It may require correct/in-range values for request initialization.
76 // - It may require specifying regional endpoints when creating the service client as shown in:
77 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
78 c, err := apihub.NewApiHubPluginRESTClient(ctx)
79 if err != nil {
80 // TODO: Handle error.
81 }
82 defer c.Close()
83
84 req := &apihubpb.CreatePluginInstanceRequest{
85 // TODO: Fill request struct fields.
86 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#CreatePluginInstanceRequest.
87 }
88 op, err := c.CreatePluginInstance(ctx, req)
89 if err != nil {
90 // TODO: Handle error.
91 }
92
93 resp, err := op.Wait(ctx)
94 if err != nil {
95 // TODO: Handle error.
96 }
97 // TODO: Use resp.
98 _ = resp
99 }
100
101 func ExampleApiHubPluginClient_DeletePlugin() {
102 ctx := context.Background()
103 // This snippet has been automatically generated and should be regarded as a code template only.
104 // It will require modifications to work:
105 // - It may require correct/in-range values for request initialization.
106 // - It may require specifying regional endpoints when creating the service client as shown in:
107 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
108 c, err := apihub.NewApiHubPluginRESTClient(ctx)
109 if err != nil {
110 // TODO: Handle error.
111 }
112 defer c.Close()
113
114 req := &apihubpb.DeletePluginRequest{
115 // TODO: Fill request struct fields.
116 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#DeletePluginRequest.
117 }
118 op, err := c.DeletePlugin(ctx, req)
119 if err != nil {
120 // TODO: Handle error.
121 }
122
123 err = op.Wait(ctx)
124 if err != nil {
125 // TODO: Handle error.
126 }
127 }
128
129 func ExampleApiHubPluginClient_DeletePluginInstance() {
130 ctx := context.Background()
131 // This snippet has been automatically generated and should be regarded as a code template only.
132 // It will require modifications to work:
133 // - It may require correct/in-range values for request initialization.
134 // - It may require specifying regional endpoints when creating the service client as shown in:
135 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
136 c, err := apihub.NewApiHubPluginRESTClient(ctx)
137 if err != nil {
138 // TODO: Handle error.
139 }
140 defer c.Close()
141
142 req := &apihubpb.DeletePluginInstanceRequest{
143 // TODO: Fill request struct fields.
144 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#DeletePluginInstanceRequest.
145 }
146 op, err := c.DeletePluginInstance(ctx, req)
147 if err != nil {
148 // TODO: Handle error.
149 }
150
151 err = op.Wait(ctx)
152 if err != nil {
153 // TODO: Handle error.
154 }
155 }
156
157 func ExampleApiHubPluginClient_DisablePlugin() {
158 ctx := context.Background()
159 // This snippet has been automatically generated and should be regarded as a code template only.
160 // It will require modifications to work:
161 // - It may require correct/in-range values for request initialization.
162 // - It may require specifying regional endpoints when creating the service client as shown in:
163 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
164 c, err := apihub.NewApiHubPluginRESTClient(ctx)
165 if err != nil {
166 // TODO: Handle error.
167 }
168 defer c.Close()
169
170 req := &apihubpb.DisablePluginRequest{
171 // TODO: Fill request struct fields.
172 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#DisablePluginRequest.
173 }
174 resp, err := c.DisablePlugin(ctx, req)
175 if err != nil {
176 // TODO: Handle error.
177 }
178 // TODO: Use resp.
179 _ = resp
180 }
181
182 func ExampleApiHubPluginClient_DisablePluginInstanceAction() {
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 := apihub.NewApiHubPluginRESTClient(ctx)
190 if err != nil {
191 // TODO: Handle error.
192 }
193 defer c.Close()
194
195 req := &apihubpb.DisablePluginInstanceActionRequest{
196 // TODO: Fill request struct fields.
197 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#DisablePluginInstanceActionRequest.
198 }
199 op, err := c.DisablePluginInstanceAction(ctx, req)
200 if err != nil {
201 // TODO: Handle error.
202 }
203
204 resp, err := op.Wait(ctx)
205 if err != nil {
206 // TODO: Handle error.
207 }
208 // TODO: Use resp.
209 _ = resp
210 }
211
212 func ExampleApiHubPluginClient_EnablePlugin() {
213 ctx := context.Background()
214 // This snippet has been automatically generated and should be regarded as a code template only.
215 // It will require modifications to work:
216 // - It may require correct/in-range values for request initialization.
217 // - It may require specifying regional endpoints when creating the service client as shown in:
218 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
219 c, err := apihub.NewApiHubPluginRESTClient(ctx)
220 if err != nil {
221 // TODO: Handle error.
222 }
223 defer c.Close()
224
225 req := &apihubpb.EnablePluginRequest{
226 // TODO: Fill request struct fields.
227 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#EnablePluginRequest.
228 }
229 resp, err := c.EnablePlugin(ctx, req)
230 if err != nil {
231 // TODO: Handle error.
232 }
233 // TODO: Use resp.
234 _ = resp
235 }
236
237 func ExampleApiHubPluginClient_EnablePluginInstanceAction() {
238 ctx := context.Background()
239 // This snippet has been automatically generated and should be regarded as a code template only.
240 // It will require modifications to work:
241 // - It may require correct/in-range values for request initialization.
242 // - It may require specifying regional endpoints when creating the service client as shown in:
243 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
244 c, err := apihub.NewApiHubPluginRESTClient(ctx)
245 if err != nil {
246 // TODO: Handle error.
247 }
248 defer c.Close()
249
250 req := &apihubpb.EnablePluginInstanceActionRequest{
251 // TODO: Fill request struct fields.
252 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#EnablePluginInstanceActionRequest.
253 }
254 op, err := c.EnablePluginInstanceAction(ctx, req)
255 if err != nil {
256 // TODO: Handle error.
257 }
258
259 resp, err := op.Wait(ctx)
260 if err != nil {
261 // TODO: Handle error.
262 }
263 // TODO: Use resp.
264 _ = resp
265 }
266
267 func ExampleApiHubPluginClient_ExecutePluginInstanceAction() {
268 ctx := context.Background()
269 // This snippet has been automatically generated and should be regarded as a code template only.
270 // It will require modifications to work:
271 // - It may require correct/in-range values for request initialization.
272 // - It may require specifying regional endpoints when creating the service client as shown in:
273 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
274 c, err := apihub.NewApiHubPluginRESTClient(ctx)
275 if err != nil {
276 // TODO: Handle error.
277 }
278 defer c.Close()
279
280 req := &apihubpb.ExecutePluginInstanceActionRequest{
281 // TODO: Fill request struct fields.
282 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#ExecutePluginInstanceActionRequest.
283 }
284 op, err := c.ExecutePluginInstanceAction(ctx, req)
285 if err != nil {
286 // TODO: Handle error.
287 }
288
289 resp, err := op.Wait(ctx)
290 if err != nil {
291 // TODO: Handle error.
292 }
293 // TODO: Use resp.
294 _ = resp
295 }
296
297 func ExampleApiHubPluginClient_GetPlugin() {
298 ctx := context.Background()
299 // This snippet has been automatically generated and should be regarded as a code template only.
300 // It will require modifications to work:
301 // - It may require correct/in-range values for request initialization.
302 // - It may require specifying regional endpoints when creating the service client as shown in:
303 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
304 c, err := apihub.NewApiHubPluginRESTClient(ctx)
305 if err != nil {
306 // TODO: Handle error.
307 }
308 defer c.Close()
309
310 req := &apihubpb.GetPluginRequest{
311 // TODO: Fill request struct fields.
312 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#GetPluginRequest.
313 }
314 resp, err := c.GetPlugin(ctx, req)
315 if err != nil {
316 // TODO: Handle error.
317 }
318 // TODO: Use resp.
319 _ = resp
320 }
321
322 func ExampleApiHubPluginClient_GetPluginInstance() {
323 ctx := context.Background()
324 // This snippet has been automatically generated and should be regarded as a code template only.
325 // It will require modifications to work:
326 // - It may require correct/in-range values for request initialization.
327 // - It may require specifying regional endpoints when creating the service client as shown in:
328 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
329 c, err := apihub.NewApiHubPluginRESTClient(ctx)
330 if err != nil {
331 // TODO: Handle error.
332 }
333 defer c.Close()
334
335 req := &apihubpb.GetPluginInstanceRequest{
336 // TODO: Fill request struct fields.
337 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#GetPluginInstanceRequest.
338 }
339 resp, err := c.GetPluginInstance(ctx, req)
340 if err != nil {
341 // TODO: Handle error.
342 }
343 // TODO: Use resp.
344 _ = resp
345 }
346
347 func ExampleApiHubPluginClient_ListPluginInstances() {
348 ctx := context.Background()
349 // This snippet has been automatically generated and should be regarded as a code template only.
350 // It will require modifications to work:
351 // - It may require correct/in-range values for request initialization.
352 // - It may require specifying regional endpoints when creating the service client as shown in:
353 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
354 c, err := apihub.NewApiHubPluginRESTClient(ctx)
355 if err != nil {
356 // TODO: Handle error.
357 }
358 defer c.Close()
359
360 req := &apihubpb.ListPluginInstancesRequest{
361 // TODO: Fill request struct fields.
362 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#ListPluginInstancesRequest.
363 }
364 it := c.ListPluginInstances(ctx, req)
365 for {
366 resp, err := it.Next()
367 if err == iterator.Done {
368 break
369 }
370 if err != nil {
371 // TODO: Handle error.
372 }
373 // TODO: Use resp.
374 _ = resp
375
376 // If you need to access the underlying RPC response,
377 // you can do so by casting the `Response` as below.
378 // Otherwise, remove this line. Only populated after
379 // first call to Next(). Not safe for concurrent access.
380 _ = it.Response.(*apihubpb.ListPluginInstancesResponse)
381 }
382 }
383
384 func ExampleApiHubPluginClient_ListPlugins() {
385 ctx := context.Background()
386 // This snippet has been automatically generated and should be regarded as a code template only.
387 // It will require modifications to work:
388 // - It may require correct/in-range values for request initialization.
389 // - It may require specifying regional endpoints when creating the service client as shown in:
390 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
391 c, err := apihub.NewApiHubPluginRESTClient(ctx)
392 if err != nil {
393 // TODO: Handle error.
394 }
395 defer c.Close()
396
397 req := &apihubpb.ListPluginsRequest{
398 // TODO: Fill request struct fields.
399 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#ListPluginsRequest.
400 }
401 it := c.ListPlugins(ctx, req)
402 for {
403 resp, err := it.Next()
404 if err == iterator.Done {
405 break
406 }
407 if err != nil {
408 // TODO: Handle error.
409 }
410 // TODO: Use resp.
411 _ = resp
412
413 // If you need to access the underlying RPC response,
414 // you can do so by casting the `Response` as below.
415 // Otherwise, remove this line. Only populated after
416 // first call to Next(). Not safe for concurrent access.
417 _ = it.Response.(*apihubpb.ListPluginsResponse)
418 }
419 }
420
421 func ExampleApiHubPluginClient_UpdatePluginInstance() {
422 ctx := context.Background()
423 // This snippet has been automatically generated and should be regarded as a code template only.
424 // It will require modifications to work:
425 // - It may require correct/in-range values for request initialization.
426 // - It may require specifying regional endpoints when creating the service client as shown in:
427 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
428 c, err := apihub.NewApiHubPluginRESTClient(ctx)
429 if err != nil {
430 // TODO: Handle error.
431 }
432 defer c.Close()
433
434 req := &apihubpb.UpdatePluginInstanceRequest{
435 // TODO: Fill request struct fields.
436 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#UpdatePluginInstanceRequest.
437 }
438 resp, err := c.UpdatePluginInstance(ctx, req)
439 if err != nil {
440 // TODO: Handle error.
441 }
442 // TODO: Use resp.
443 _ = resp
444 }
445
446 func ExampleApiHubPluginClient_GetLocation() {
447 ctx := context.Background()
448 // This snippet has been automatically generated and should be regarded as a code template only.
449 // It will require modifications to work:
450 // - It may require correct/in-range values for request initialization.
451 // - It may require specifying regional endpoints when creating the service client as shown in:
452 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
453 c, err := apihub.NewApiHubPluginRESTClient(ctx)
454 if err != nil {
455 // TODO: Handle error.
456 }
457 defer c.Close()
458
459 req := &locationpb.GetLocationRequest{
460 // TODO: Fill request struct fields.
461 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
462 }
463 resp, err := c.GetLocation(ctx, req)
464 if err != nil {
465 // TODO: Handle error.
466 }
467 // TODO: Use resp.
468 _ = resp
469 }
470
471 func ExampleApiHubPluginClient_ListLocations() {
472 ctx := context.Background()
473 // This snippet has been automatically generated and should be regarded as a code template only.
474 // It will require modifications to work:
475 // - It may require correct/in-range values for request initialization.
476 // - It may require specifying regional endpoints when creating the service client as shown in:
477 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
478 c, err := apihub.NewApiHubPluginRESTClient(ctx)
479 if err != nil {
480 // TODO: Handle error.
481 }
482 defer c.Close()
483
484 req := &locationpb.ListLocationsRequest{
485 // TODO: Fill request struct fields.
486 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
487 }
488 it := c.ListLocations(ctx, req)
489 for {
490 resp, err := it.Next()
491 if err == iterator.Done {
492 break
493 }
494 if err != nil {
495 // TODO: Handle error.
496 }
497 // TODO: Use resp.
498 _ = resp
499
500 // If you need to access the underlying RPC response,
501 // you can do so by casting the `Response` as below.
502 // Otherwise, remove this line. Only populated after
503 // first call to Next(). Not safe for concurrent access.
504 _ = it.Response.(*locationpb.ListLocationsResponse)
505 }
506 }
507
508 func ExampleApiHubPluginClient_CancelOperation() {
509 ctx := context.Background()
510 // This snippet has been automatically generated and should be regarded as a code template only.
511 // It will require modifications to work:
512 // - It may require correct/in-range values for request initialization.
513 // - It may require specifying regional endpoints when creating the service client as shown in:
514 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
515 c, err := apihub.NewApiHubPluginRESTClient(ctx)
516 if err != nil {
517 // TODO: Handle error.
518 }
519 defer c.Close()
520
521 req := &longrunningpb.CancelOperationRequest{
522 // TODO: Fill request struct fields.
523 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
524 }
525 err = c.CancelOperation(ctx, req)
526 if err != nil {
527 // TODO: Handle error.
528 }
529 }
530
531 func ExampleApiHubPluginClient_DeleteOperation() {
532 ctx := context.Background()
533 // This snippet has been automatically generated and should be regarded as a code template only.
534 // It will require modifications to work:
535 // - It may require correct/in-range values for request initialization.
536 // - It may require specifying regional endpoints when creating the service client as shown in:
537 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
538 c, err := apihub.NewApiHubPluginRESTClient(ctx)
539 if err != nil {
540 // TODO: Handle error.
541 }
542 defer c.Close()
543
544 req := &longrunningpb.DeleteOperationRequest{
545 // TODO: Fill request struct fields.
546 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
547 }
548 err = c.DeleteOperation(ctx, req)
549 if err != nil {
550 // TODO: Handle error.
551 }
552 }
553
554 func ExampleApiHubPluginClient_GetOperation() {
555 ctx := context.Background()
556 // This snippet has been automatically generated and should be regarded as a code template only.
557 // It will require modifications to work:
558 // - It may require correct/in-range values for request initialization.
559 // - It may require specifying regional endpoints when creating the service client as shown in:
560 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
561 c, err := apihub.NewApiHubPluginRESTClient(ctx)
562 if err != nil {
563 // TODO: Handle error.
564 }
565 defer c.Close()
566
567 req := &longrunningpb.GetOperationRequest{
568 // TODO: Fill request struct fields.
569 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
570 }
571 resp, err := c.GetOperation(ctx, req)
572 if err != nil {
573 // TODO: Handle error.
574 }
575 // TODO: Use resp.
576 _ = resp
577 }
578
579 func ExampleApiHubPluginClient_ListOperations() {
580 ctx := context.Background()
581 // This snippet has been automatically generated and should be regarded as a code template only.
582 // It will require modifications to work:
583 // - It may require correct/in-range values for request initialization.
584 // - It may require specifying regional endpoints when creating the service client as shown in:
585 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
586 c, err := apihub.NewApiHubPluginRESTClient(ctx)
587 if err != nil {
588 // TODO: Handle error.
589 }
590 defer c.Close()
591
592 req := &longrunningpb.ListOperationsRequest{
593 // TODO: Fill request struct fields.
594 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
595 }
596 it := c.ListOperations(ctx, req)
597 for {
598 resp, err := it.Next()
599 if err == iterator.Done {
600 break
601 }
602 if err != nil {
603 // TODO: Handle error.
604 }
605 // TODO: Use resp.
606 _ = resp
607
608 // If you need to access the underlying RPC response,
609 // you can do so by casting the `Response` as below.
610 // Otherwise, remove this line. Only populated after
611 // first call to Next(). Not safe for concurrent access.
612 _ = it.Response.(*longrunningpb.ListOperationsResponse)
613 }
614 }