Debian Codegraph @

servicemanagement/apiv1/service_manager_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 servicemanagement_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 servicemanagement "cloud.google.com/go/servicemanagement/apiv1"
25 servicemanagementpb "cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb"
26 "google.golang.org/api/iterator"
27 )
28
29 func ExampleNewServiceManagerClient() {
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 := servicemanagement.NewServiceManagerClient(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 ExampleNewServiceManagerRESTClient() {
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 := servicemanagement.NewServiceManagerRESTClient(ctx)
54 if err != nil {
55 // TODO: Handle error.
56 }
57 defer c.Close()
58
59 // TODO: Use client.
60 _ = c
61 }
62
63 func ExampleServiceManagerClient_CreateService() {
64 ctx := context.Background()
65 // This snippet has been automatically generated and should be regarded as a code template only.
66 // It will require modifications to work:
67 // - It may require correct/in-range values for request initialization.
68 // - It may require specifying regional endpoints when creating the service client as shown in:
69 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
70 c, err := servicemanagement.NewServiceManagerClient(ctx)
71 if err != nil {
72 // TODO: Handle error.
73 }
74 defer c.Close()
75
76 req := &servicemanagementpb.CreateServiceRequest{
77 // TODO: Fill request struct fields.
78 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#CreateServiceRequest.
79 }
80 op, err := c.CreateService(ctx, req)
81 if err != nil {
82 // TODO: Handle error.
83 }
84
85 resp, err := op.Wait(ctx)
86 if err != nil {
87 // TODO: Handle error.
88 }
89 // TODO: Use resp.
90 _ = resp
91 }
92
93 func ExampleServiceManagerClient_CreateServiceConfig() {
94 ctx := context.Background()
95 // This snippet has been automatically generated and should be regarded as a code template only.
96 // It will require modifications to work:
97 // - It may require correct/in-range values for request initialization.
98 // - It may require specifying regional endpoints when creating the service client as shown in:
99 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
100 c, err := servicemanagement.NewServiceManagerClient(ctx)
101 if err != nil {
102 // TODO: Handle error.
103 }
104 defer c.Close()
105
106 req := &servicemanagementpb.CreateServiceConfigRequest{
107 // TODO: Fill request struct fields.
108 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#CreateServiceConfigRequest.
109 }
110 resp, err := c.CreateServiceConfig(ctx, req)
111 if err != nil {
112 // TODO: Handle error.
113 }
114 // TODO: Use resp.
115 _ = resp
116 }
117
118 func ExampleServiceManagerClient_CreateServiceRollout() {
119 ctx := context.Background()
120 // This snippet has been automatically generated and should be regarded as a code template only.
121 // It will require modifications to work:
122 // - It may require correct/in-range values for request initialization.
123 // - It may require specifying regional endpoints when creating the service client as shown in:
124 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
125 c, err := servicemanagement.NewServiceManagerClient(ctx)
126 if err != nil {
127 // TODO: Handle error.
128 }
129 defer c.Close()
130
131 req := &servicemanagementpb.CreateServiceRolloutRequest{
132 // TODO: Fill request struct fields.
133 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#CreateServiceRolloutRequest.
134 }
135 op, err := c.CreateServiceRollout(ctx, req)
136 if err != nil {
137 // TODO: Handle error.
138 }
139
140 resp, err := op.Wait(ctx)
141 if err != nil {
142 // TODO: Handle error.
143 }
144 // TODO: Use resp.
145 _ = resp
146 }
147
148 func ExampleServiceManagerClient_DeleteService() {
149 ctx := context.Background()
150 // This snippet has been automatically generated and should be regarded as a code template only.
151 // It will require modifications to work:
152 // - It may require correct/in-range values for request initialization.
153 // - It may require specifying regional endpoints when creating the service client as shown in:
154 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
155 c, err := servicemanagement.NewServiceManagerClient(ctx)
156 if err != nil {
157 // TODO: Handle error.
158 }
159 defer c.Close()
160
161 req := &servicemanagementpb.DeleteServiceRequest{
162 // TODO: Fill request struct fields.
163 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#DeleteServiceRequest.
164 }
165 op, err := c.DeleteService(ctx, req)
166 if err != nil {
167 // TODO: Handle error.
168 }
169
170 err = op.Wait(ctx)
171 if err != nil {
172 // TODO: Handle error.
173 }
174 }
175
176 func ExampleServiceManagerClient_GenerateConfigReport() {
177 ctx := context.Background()
178 // This snippet has been automatically generated and should be regarded as a code template only.
179 // It will require modifications to work:
180 // - It may require correct/in-range values for request initialization.
181 // - It may require specifying regional endpoints when creating the service client as shown in:
182 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
183 c, err := servicemanagement.NewServiceManagerClient(ctx)
184 if err != nil {
185 // TODO: Handle error.
186 }
187 defer c.Close()
188
189 req := &servicemanagementpb.GenerateConfigReportRequest{
190 // TODO: Fill request struct fields.
191 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#GenerateConfigReportRequest.
192 }
193 resp, err := c.GenerateConfigReport(ctx, req)
194 if err != nil {
195 // TODO: Handle error.
196 }
197 // TODO: Use resp.
198 _ = resp
199 }
200
201 func ExampleServiceManagerClient_GetService() {
202 ctx := context.Background()
203 // This snippet has been automatically generated and should be regarded as a code template only.
204 // It will require modifications to work:
205 // - It may require correct/in-range values for request initialization.
206 // - It may require specifying regional endpoints when creating the service client as shown in:
207 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
208 c, err := servicemanagement.NewServiceManagerClient(ctx)
209 if err != nil {
210 // TODO: Handle error.
211 }
212 defer c.Close()
213
214 req := &servicemanagementpb.GetServiceRequest{
215 // TODO: Fill request struct fields.
216 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#GetServiceRequest.
217 }
218 resp, err := c.GetService(ctx, req)
219 if err != nil {
220 // TODO: Handle error.
221 }
222 // TODO: Use resp.
223 _ = resp
224 }
225
226 func ExampleServiceManagerClient_GetServiceConfig() {
227 ctx := context.Background()
228 // This snippet has been automatically generated and should be regarded as a code template only.
229 // It will require modifications to work:
230 // - It may require correct/in-range values for request initialization.
231 // - It may require specifying regional endpoints when creating the service client as shown in:
232 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
233 c, err := servicemanagement.NewServiceManagerClient(ctx)
234 if err != nil {
235 // TODO: Handle error.
236 }
237 defer c.Close()
238
239 req := &servicemanagementpb.GetServiceConfigRequest{
240 // TODO: Fill request struct fields.
241 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#GetServiceConfigRequest.
242 }
243 resp, err := c.GetServiceConfig(ctx, req)
244 if err != nil {
245 // TODO: Handle error.
246 }
247 // TODO: Use resp.
248 _ = resp
249 }
250
251 func ExampleServiceManagerClient_GetServiceRollout() {
252 ctx := context.Background()
253 // This snippet has been automatically generated and should be regarded as a code template only.
254 // It will require modifications to work:
255 // - It may require correct/in-range values for request initialization.
256 // - It may require specifying regional endpoints when creating the service client as shown in:
257 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
258 c, err := servicemanagement.NewServiceManagerClient(ctx)
259 if err != nil {
260 // TODO: Handle error.
261 }
262 defer c.Close()
263
264 req := &servicemanagementpb.GetServiceRolloutRequest{
265 // TODO: Fill request struct fields.
266 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#GetServiceRolloutRequest.
267 }
268 resp, err := c.GetServiceRollout(ctx, req)
269 if err != nil {
270 // TODO: Handle error.
271 }
272 // TODO: Use resp.
273 _ = resp
274 }
275
276 func ExampleServiceManagerClient_ListServiceConfigs() {
277 ctx := context.Background()
278 // This snippet has been automatically generated and should be regarded as a code template only.
279 // It will require modifications to work:
280 // - It may require correct/in-range values for request initialization.
281 // - It may require specifying regional endpoints when creating the service client as shown in:
282 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
283 c, err := servicemanagement.NewServiceManagerClient(ctx)
284 if err != nil {
285 // TODO: Handle error.
286 }
287 defer c.Close()
288
289 req := &servicemanagementpb.ListServiceConfigsRequest{
290 // TODO: Fill request struct fields.
291 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#ListServiceConfigsRequest.
292 }
293 it := c.ListServiceConfigs(ctx, req)
294 for {
295 resp, err := it.Next()
296 if err == iterator.Done {
297 break
298 }
299 if err != nil {
300 // TODO: Handle error.
301 }
302 // TODO: Use resp.
303 _ = resp
304
305 // If you need to access the underlying RPC response,
306 // you can do so by casting the `Response` as below.
307 // Otherwise, remove this line. Only populated after
308 // first call to Next(). Not safe for concurrent access.
309 _ = it.Response.(*servicemanagementpb.ListServiceConfigsResponse)
310 }
311 }
312
313 func ExampleServiceManagerClient_ListServiceRollouts() {
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 := servicemanagement.NewServiceManagerClient(ctx)
321 if err != nil {
322 // TODO: Handle error.
323 }
324 defer c.Close()
325
326 req := &servicemanagementpb.ListServiceRolloutsRequest{
327 // TODO: Fill request struct fields.
328 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#ListServiceRolloutsRequest.
329 }
330 it := c.ListServiceRollouts(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.(*servicemanagementpb.ListServiceRolloutsResponse)
347 }
348 }
349
350 func ExampleServiceManagerClient_ListServices() {
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 := servicemanagement.NewServiceManagerClient(ctx)
358 if err != nil {
359 // TODO: Handle error.
360 }
361 defer c.Close()
362
363 req := &servicemanagementpb.ListServicesRequest{
364 // TODO: Fill request struct fields.
365 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#ListServicesRequest.
366 }
367 it := c.ListServices(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.(*servicemanagementpb.ListServicesResponse)
384 }
385 }
386
387 func ExampleServiceManagerClient_SubmitConfigSource() {
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 := servicemanagement.NewServiceManagerClient(ctx)
395 if err != nil {
396 // TODO: Handle error.
397 }
398 defer c.Close()
399
400 req := &servicemanagementpb.SubmitConfigSourceRequest{
401 // TODO: Fill request struct fields.
402 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#SubmitConfigSourceRequest.
403 }
404 op, err := c.SubmitConfigSource(ctx, req)
405 if err != nil {
406 // TODO: Handle error.
407 }
408
409 resp, err := op.Wait(ctx)
410 if err != nil {
411 // TODO: Handle error.
412 }
413 // TODO: Use resp.
414 _ = resp
415 }
416
417 func ExampleServiceManagerClient_UndeleteService() {
418 ctx := context.Background()
419 // This snippet has been automatically generated and should be regarded as a code template only.
420 // It will require modifications to work:
421 // - It may require correct/in-range values for request initialization.
422 // - It may require specifying regional endpoints when creating the service client as shown in:
423 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
424 c, err := servicemanagement.NewServiceManagerClient(ctx)
425 if err != nil {
426 // TODO: Handle error.
427 }
428 defer c.Close()
429
430 req := &servicemanagementpb.UndeleteServiceRequest{
431 // TODO: Fill request struct fields.
432 // See https://pkg.go.dev/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb#UndeleteServiceRequest.
433 }
434 op, err := c.UndeleteService(ctx, req)
435 if err != nil {
436 // TODO: Handle error.
437 }
438
439 resp, err := op.Wait(ctx)
440 if err != nil {
441 // TODO: Handle error.
442 }
443 // TODO: Use resp.
444 _ = resp
445 }
446
447 func ExampleServiceManagerClient_GetIamPolicy() {
448 ctx := context.Background()
449 // This snippet has been automatically generated and should be regarded as a code template only.
450 // It will require modifications to work:
451 // - It may require correct/in-range values for request initialization.
452 // - It may require specifying regional endpoints when creating the service client as shown in:
453 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
454 c, err := servicemanagement.NewServiceManagerClient(ctx)
455 if err != nil {
456 // TODO: Handle error.
457 }
458 defer c.Close()
459
460 req := &iampb.GetIamPolicyRequest{
461 // TODO: Fill request struct fields.
462 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
463 }
464 resp, err := c.GetIamPolicy(ctx, req)
465 if err != nil {
466 // TODO: Handle error.
467 }
468 // TODO: Use resp.
469 _ = resp
470 }
471
472 func ExampleServiceManagerClient_SetIamPolicy() {
473 ctx := context.Background()
474 // This snippet has been automatically generated and should be regarded as a code template only.
475 // It will require modifications to work:
476 // - It may require correct/in-range values for request initialization.
477 // - It may require specifying regional endpoints when creating the service client as shown in:
478 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
479 c, err := servicemanagement.NewServiceManagerClient(ctx)
480 if err != nil {
481 // TODO: Handle error.
482 }
483 defer c.Close()
484
485 req := &iampb.SetIamPolicyRequest{
486 // TODO: Fill request struct fields.
487 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
488 }
489 resp, err := c.SetIamPolicy(ctx, req)
490 if err != nil {
491 // TODO: Handle error.
492 }
493 // TODO: Use resp.
494 _ = resp
495 }
496
497 func ExampleServiceManagerClient_TestIamPermissions() {
498 ctx := context.Background()
499 // This snippet has been automatically generated and should be regarded as a code template only.
500 // It will require modifications to work:
501 // - It may require correct/in-range values for request initialization.
502 // - It may require specifying regional endpoints when creating the service client as shown in:
503 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
504 c, err := servicemanagement.NewServiceManagerClient(ctx)
505 if err != nil {
506 // TODO: Handle error.
507 }
508 defer c.Close()
509
510 req := &iampb.TestIamPermissionsRequest{
511 // TODO: Fill request struct fields.
512 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
513 }
514 resp, err := c.TestIamPermissions(ctx, req)
515 if err != nil {
516 // TODO: Handle error.
517 }
518 // TODO: Use resp.
519 _ = resp
520 }
521
522 func ExampleServiceManagerClient_ListOperations() {
523 ctx := context.Background()
524 // This snippet has been automatically generated and should be regarded as a code template only.
525 // It will require modifications to work:
526 // - It may require correct/in-range values for request initialization.
527 // - It may require specifying regional endpoints when creating the service client as shown in:
528 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
529 c, err := servicemanagement.NewServiceManagerClient(ctx)
530 if err != nil {
531 // TODO: Handle error.
532 }
533 defer c.Close()
534
535 req := &longrunningpb.ListOperationsRequest{
536 // TODO: Fill request struct fields.
537 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
538 }
539 it := c.ListOperations(ctx, req)
540 for {
541 resp, err := it.Next()
542 if err == iterator.Done {
543 break
544 }
545 if err != nil {
546 // TODO: Handle error.
547 }
548 // TODO: Use resp.
549 _ = resp
550
551 // If you need to access the underlying RPC response,
552 // you can do so by casting the `Response` as below.
553 // Otherwise, remove this line. Only populated after
554 // first call to Next(). Not safe for concurrent access.
555 _ = it.Response.(*longrunningpb.ListOperationsResponse)
556 }
557 }