Debian Codegraph @

networkservices/apiv1/network_services_client_example_go123_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 //go:build go1.23
18
19 package networkservices_test
20
21 import (
22 "context"
23
24 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
25 networkservices "cloud.google.com/go/networkservices/apiv1"
26 networkservicespb "cloud.google.com/go/networkservices/apiv1/networkservicespb"
27 locationpb "google.golang.org/genproto/googleapis/cloud/location"
28 )
29
30 func ExampleClient_ListEndpointPolicies_all() {
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.NewClient(ctx)
38 if err != nil {
39 // TODO: Handle error.
40 }
41 defer c.Close()
42
43 req := &networkservicespb.ListEndpointPoliciesRequest{
44 // TODO: Fill request struct fields.
45 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListEndpointPoliciesRequest.
46 }
47 for resp, err := range c.ListEndpointPolicies(ctx, req).All() {
48 if err != nil {
49 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
50 }
51 // TODO: Use resp.
52 _ = resp
53 }
54 }
55
56 func ExampleClient_ListGatewayRouteViews_all() {
57 ctx := context.Background()
58 // This snippet has been automatically generated and should be regarded as a code template only.
59 // It will require modifications to work:
60 // - It may require correct/in-range values for request initialization.
61 // - It may require specifying regional endpoints when creating the service client as shown in:
62 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
63 c, err := networkservices.NewClient(ctx)
64 if err != nil {
65 // TODO: Handle error.
66 }
67 defer c.Close()
68
69 req := &networkservicespb.ListGatewayRouteViewsRequest{
70 // TODO: Fill request struct fields.
71 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListGatewayRouteViewsRequest.
72 }
73 for resp, err := range c.ListGatewayRouteViews(ctx, req).All() {
74 if err != nil {
75 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
76 }
77 // TODO: Use resp.
78 _ = resp
79 }
80 }
81
82 func ExampleClient_ListGateways_all() {
83 ctx := context.Background()
84 // This snippet has been automatically generated and should be regarded as a code template only.
85 // It will require modifications to work:
86 // - It may require correct/in-range values for request initialization.
87 // - It may require specifying regional endpoints when creating the service client as shown in:
88 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
89 c, err := networkservices.NewClient(ctx)
90 if err != nil {
91 // TODO: Handle error.
92 }
93 defer c.Close()
94
95 req := &networkservicespb.ListGatewaysRequest{
96 // TODO: Fill request struct fields.
97 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListGatewaysRequest.
98 }
99 for resp, err := range c.ListGateways(ctx, req).All() {
100 if err != nil {
101 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
102 }
103 // TODO: Use resp.
104 _ = resp
105 }
106 }
107
108 func ExampleClient_ListGrpcRoutes_all() {
109 ctx := context.Background()
110 // This snippet has been automatically generated and should be regarded as a code template only.
111 // It will require modifications to work:
112 // - It may require correct/in-range values for request initialization.
113 // - It may require specifying regional endpoints when creating the service client as shown in:
114 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
115 c, err := networkservices.NewClient(ctx)
116 if err != nil {
117 // TODO: Handle error.
118 }
119 defer c.Close()
120
121 req := &networkservicespb.ListGrpcRoutesRequest{
122 // TODO: Fill request struct fields.
123 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListGrpcRoutesRequest.
124 }
125 for resp, err := range c.ListGrpcRoutes(ctx, req).All() {
126 if err != nil {
127 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
128 }
129 // TODO: Use resp.
130 _ = resp
131 }
132 }
133
134 func ExampleClient_ListHttpRoutes_all() {
135 ctx := context.Background()
136 // This snippet has been automatically generated and should be regarded as a code template only.
137 // It will require modifications to work:
138 // - It may require correct/in-range values for request initialization.
139 // - It may require specifying regional endpoints when creating the service client as shown in:
140 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
141 c, err := networkservices.NewClient(ctx)
142 if err != nil {
143 // TODO: Handle error.
144 }
145 defer c.Close()
146
147 req := &networkservicespb.ListHttpRoutesRequest{
148 // TODO: Fill request struct fields.
149 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListHttpRoutesRequest.
150 }
151 for resp, err := range c.ListHttpRoutes(ctx, req).All() {
152 if err != nil {
153 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
154 }
155 // TODO: Use resp.
156 _ = resp
157 }
158 }
159
160 func ExampleClient_ListMeshRouteViews_all() {
161 ctx := context.Background()
162 // This snippet has been automatically generated and should be regarded as a code template only.
163 // It will require modifications to work:
164 // - It may require correct/in-range values for request initialization.
165 // - It may require specifying regional endpoints when creating the service client as shown in:
166 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
167 c, err := networkservices.NewClient(ctx)
168 if err != nil {
169 // TODO: Handle error.
170 }
171 defer c.Close()
172
173 req := &networkservicespb.ListMeshRouteViewsRequest{
174 // TODO: Fill request struct fields.
175 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListMeshRouteViewsRequest.
176 }
177 for resp, err := range c.ListMeshRouteViews(ctx, req).All() {
178 if err != nil {
179 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
180 }
181 // TODO: Use resp.
182 _ = resp
183 }
184 }
185
186 func ExampleClient_ListMeshes_all() {
187 ctx := context.Background()
188 // This snippet has been automatically generated and should be regarded as a code template only.
189 // It will require modifications to work:
190 // - It may require correct/in-range values for request initialization.
191 // - It may require specifying regional endpoints when creating the service client as shown in:
192 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
193 c, err := networkservices.NewClient(ctx)
194 if err != nil {
195 // TODO: Handle error.
196 }
197 defer c.Close()
198
199 req := &networkservicespb.ListMeshesRequest{
200 // TODO: Fill request struct fields.
201 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListMeshesRequest.
202 }
203 for resp, err := range c.ListMeshes(ctx, req).All() {
204 if err != nil {
205 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
206 }
207 // TODO: Use resp.
208 _ = resp
209 }
210 }
211
212 func ExampleClient_ListServiceBindings_all() {
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 := networkservices.NewClient(ctx)
220 if err != nil {
221 // TODO: Handle error.
222 }
223 defer c.Close()
224
225 req := &networkservicespb.ListServiceBindingsRequest{
226 // TODO: Fill request struct fields.
227 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListServiceBindingsRequest.
228 }
229 for resp, err := range c.ListServiceBindings(ctx, req).All() {
230 if err != nil {
231 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
232 }
233 // TODO: Use resp.
234 _ = resp
235 }
236 }
237
238 func ExampleClient_ListServiceLbPolicies_all() {
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.NewClient(ctx)
246 if err != nil {
247 // TODO: Handle error.
248 }
249 defer c.Close()
250
251 req := &networkservicespb.ListServiceLbPoliciesRequest{
252 // TODO: Fill request struct fields.
253 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListServiceLbPoliciesRequest.
254 }
255 for resp, err := range c.ListServiceLbPolicies(ctx, req).All() {
256 if err != nil {
257 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
258 }
259 // TODO: Use resp.
260 _ = resp
261 }
262 }
263
264 func ExampleClient_ListTcpRoutes_all() {
265 ctx := context.Background()
266 // This snippet has been automatically generated and should be regarded as a code template only.
267 // It will require modifications to work:
268 // - It may require correct/in-range values for request initialization.
269 // - It may require specifying regional endpoints when creating the service client as shown in:
270 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
271 c, err := networkservices.NewClient(ctx)
272 if err != nil {
273 // TODO: Handle error.
274 }
275 defer c.Close()
276
277 req := &networkservicespb.ListTcpRoutesRequest{
278 // TODO: Fill request struct fields.
279 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListTcpRoutesRequest.
280 }
281 for resp, err := range c.ListTcpRoutes(ctx, req).All() {
282 if err != nil {
283 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
284 }
285 // TODO: Use resp.
286 _ = resp
287 }
288 }
289
290 func ExampleClient_ListTlsRoutes_all() {
291 ctx := context.Background()
292 // This snippet has been automatically generated and should be regarded as a code template only.
293 // It will require modifications to work:
294 // - It may require correct/in-range values for request initialization.
295 // - It may require specifying regional endpoints when creating the service client as shown in:
296 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
297 c, err := networkservices.NewClient(ctx)
298 if err != nil {
299 // TODO: Handle error.
300 }
301 defer c.Close()
302
303 req := &networkservicespb.ListTlsRoutesRequest{
304 // TODO: Fill request struct fields.
305 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListTlsRoutesRequest.
306 }
307 for resp, err := range c.ListTlsRoutes(ctx, req).All() {
308 if err != nil {
309 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
310 }
311 // TODO: Use resp.
312 _ = resp
313 }
314 }
315
316 func ExampleClient_ListWasmPluginVersions_all() {
317 ctx := context.Background()
318 // This snippet has been automatically generated and should be regarded as a code template only.
319 // It will require modifications to work:
320 // - It may require correct/in-range values for request initialization.
321 // - It may require specifying regional endpoints when creating the service client as shown in:
322 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
323 c, err := networkservices.NewClient(ctx)
324 if err != nil {
325 // TODO: Handle error.
326 }
327 defer c.Close()
328
329 req := &networkservicespb.ListWasmPluginVersionsRequest{
330 // TODO: Fill request struct fields.
331 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListWasmPluginVersionsRequest.
332 }
333 for resp, err := range c.ListWasmPluginVersions(ctx, req).All() {
334 if err != nil {
335 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
336 }
337 // TODO: Use resp.
338 _ = resp
339 }
340 }
341
342 func ExampleClient_ListWasmPlugins_all() {
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 := networkservices.NewClient(ctx)
350 if err != nil {
351 // TODO: Handle error.
352 }
353 defer c.Close()
354
355 req := &networkservicespb.ListWasmPluginsRequest{
356 // TODO: Fill request struct fields.
357 // See https://pkg.go.dev/cloud.google.com/go/networkservices/apiv1/networkservicespb#ListWasmPluginsRequest.
358 }
359 for resp, err := range c.ListWasmPlugins(ctx, req).All() {
360 if err != nil {
361 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
362 }
363 // TODO: Use resp.
364 _ = resp
365 }
366 }
367
368 func ExampleClient_ListLocations_all() {
369 ctx := context.Background()
370 // This snippet has been automatically generated and should be regarded as a code template only.
371 // It will require modifications to work:
372 // - It may require correct/in-range values for request initialization.
373 // - It may require specifying regional endpoints when creating the service client as shown in:
374 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
375 c, err := networkservices.NewClient(ctx)
376 if err != nil {
377 // TODO: Handle error.
378 }
379 defer c.Close()
380
381 req := &locationpb.ListLocationsRequest{
382 // TODO: Fill request struct fields.
383 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
384 }
385 for resp, err := range c.ListLocations(ctx, req).All() {
386 if err != nil {
387 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
388 }
389 // TODO: Use resp.
390 _ = resp
391 }
392 }
393
394 func ExampleClient_ListOperations_all() {
395 ctx := context.Background()
396 // This snippet has been automatically generated and should be regarded as a code template only.
397 // It will require modifications to work:
398 // - It may require correct/in-range values for request initialization.
399 // - It may require specifying regional endpoints when creating the service client as shown in:
400 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
401 c, err := networkservices.NewClient(ctx)
402 if err != nil {
403 // TODO: Handle error.
404 }
405 defer c.Close()
406
407 req := &longrunningpb.ListOperationsRequest{
408 // TODO: Fill request struct fields.
409 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
410 }
411 for resp, err := range c.ListOperations(ctx, req).All() {
412 if err != nil {
413 // TODO: Handle error and break/return/continue. Iteration will stop after any error.
414 }
415 // TODO: Use resp.
416 _ = resp
417 }
418 }