Debian Codegraph @

rapidmigrationassessment/apiv1/rapid_migration_assessment_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 rapidmigrationassessment_test
18
19 import (
20 "context"
21
22 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
23 rapidmigrationassessment "cloud.google.com/go/rapidmigrationassessment/apiv1"
24 rapidmigrationassessmentpb "cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb"
25 "google.golang.org/api/iterator"
26 locationpb "google.golang.org/genproto/googleapis/cloud/location"
27 )
28
29 func ExampleNewClient() {
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 := rapidmigrationassessment.NewClient(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 ExampleNewRESTClient() {
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 := rapidmigrationassessment.NewRESTClient(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 ExampleClient_CreateAnnotation() {
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 := rapidmigrationassessment.NewClient(ctx)
71 if err != nil {
72 // TODO: Handle error.
73 }
74 defer c.Close()
75
76 req := &rapidmigrationassessmentpb.CreateAnnotationRequest{
77 // TODO: Fill request struct fields.
78 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#CreateAnnotationRequest.
79 }
80 op, err := c.CreateAnnotation(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 ExampleClient_CreateCollector() {
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 := rapidmigrationassessment.NewClient(ctx)
101 if err != nil {
102 // TODO: Handle error.
103 }
104 defer c.Close()
105
106 req := &rapidmigrationassessmentpb.CreateCollectorRequest{
107 // TODO: Fill request struct fields.
108 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#CreateCollectorRequest.
109 }
110 op, err := c.CreateCollector(ctx, req)
111 if err != nil {
112 // TODO: Handle error.
113 }
114
115 resp, err := op.Wait(ctx)
116 if err != nil {
117 // TODO: Handle error.
118 }
119 // TODO: Use resp.
120 _ = resp
121 }
122
123 func ExampleClient_DeleteCollector() {
124 ctx := context.Background()
125 // This snippet has been automatically generated and should be regarded as a code template only.
126 // It will require modifications to work:
127 // - It may require correct/in-range values for request initialization.
128 // - It may require specifying regional endpoints when creating the service client as shown in:
129 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
130 c, err := rapidmigrationassessment.NewClient(ctx)
131 if err != nil {
132 // TODO: Handle error.
133 }
134 defer c.Close()
135
136 req := &rapidmigrationassessmentpb.DeleteCollectorRequest{
137 // TODO: Fill request struct fields.
138 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#DeleteCollectorRequest.
139 }
140 op, err := c.DeleteCollector(ctx, req)
141 if err != nil {
142 // TODO: Handle error.
143 }
144
145 resp, err := op.Wait(ctx)
146 if err != nil {
147 // TODO: Handle error.
148 }
149 // TODO: Use resp.
150 _ = resp
151 }
152
153 func ExampleClient_GetAnnotation() {
154 ctx := context.Background()
155 // This snippet has been automatically generated and should be regarded as a code template only.
156 // It will require modifications to work:
157 // - It may require correct/in-range values for request initialization.
158 // - It may require specifying regional endpoints when creating the service client as shown in:
159 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
160 c, err := rapidmigrationassessment.NewClient(ctx)
161 if err != nil {
162 // TODO: Handle error.
163 }
164 defer c.Close()
165
166 req := &rapidmigrationassessmentpb.GetAnnotationRequest{
167 // TODO: Fill request struct fields.
168 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#GetAnnotationRequest.
169 }
170 resp, err := c.GetAnnotation(ctx, req)
171 if err != nil {
172 // TODO: Handle error.
173 }
174 // TODO: Use resp.
175 _ = resp
176 }
177
178 func ExampleClient_GetCollector() {
179 ctx := context.Background()
180 // This snippet has been automatically generated and should be regarded as a code template only.
181 // It will require modifications to work:
182 // - It may require correct/in-range values for request initialization.
183 // - It may require specifying regional endpoints when creating the service client as shown in:
184 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
185 c, err := rapidmigrationassessment.NewClient(ctx)
186 if err != nil {
187 // TODO: Handle error.
188 }
189 defer c.Close()
190
191 req := &rapidmigrationassessmentpb.GetCollectorRequest{
192 // TODO: Fill request struct fields.
193 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#GetCollectorRequest.
194 }
195 resp, err := c.GetCollector(ctx, req)
196 if err != nil {
197 // TODO: Handle error.
198 }
199 // TODO: Use resp.
200 _ = resp
201 }
202
203 func ExampleClient_ListCollectors() {
204 ctx := context.Background()
205 // This snippet has been automatically generated and should be regarded as a code template only.
206 // It will require modifications to work:
207 // - It may require correct/in-range values for request initialization.
208 // - It may require specifying regional endpoints when creating the service client as shown in:
209 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
210 c, err := rapidmigrationassessment.NewClient(ctx)
211 if err != nil {
212 // TODO: Handle error.
213 }
214 defer c.Close()
215
216 req := &rapidmigrationassessmentpb.ListCollectorsRequest{
217 // TODO: Fill request struct fields.
218 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#ListCollectorsRequest.
219 }
220 it := c.ListCollectors(ctx, req)
221 for {
222 resp, err := it.Next()
223 if err == iterator.Done {
224 break
225 }
226 if err != nil {
227 // TODO: Handle error.
228 }
229 // TODO: Use resp.
230 _ = resp
231
232 // If you need to access the underlying RPC response,
233 // you can do so by casting the `Response` as below.
234 // Otherwise, remove this line. Only populated after
235 // first call to Next(). Not safe for concurrent access.
236 _ = it.Response.(*rapidmigrationassessmentpb.ListCollectorsResponse)
237 }
238 }
239
240 func ExampleClient_PauseCollector() {
241 ctx := context.Background()
242 // This snippet has been automatically generated and should be regarded as a code template only.
243 // It will require modifications to work:
244 // - It may require correct/in-range values for request initialization.
245 // - It may require specifying regional endpoints when creating the service client as shown in:
246 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
247 c, err := rapidmigrationassessment.NewClient(ctx)
248 if err != nil {
249 // TODO: Handle error.
250 }
251 defer c.Close()
252
253 req := &rapidmigrationassessmentpb.PauseCollectorRequest{
254 // TODO: Fill request struct fields.
255 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#PauseCollectorRequest.
256 }
257 op, err := c.PauseCollector(ctx, req)
258 if err != nil {
259 // TODO: Handle error.
260 }
261
262 resp, err := op.Wait(ctx)
263 if err != nil {
264 // TODO: Handle error.
265 }
266 // TODO: Use resp.
267 _ = resp
268 }
269
270 func ExampleClient_RegisterCollector() {
271 ctx := context.Background()
272 // This snippet has been automatically generated and should be regarded as a code template only.
273 // It will require modifications to work:
274 // - It may require correct/in-range values for request initialization.
275 // - It may require specifying regional endpoints when creating the service client as shown in:
276 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
277 c, err := rapidmigrationassessment.NewClient(ctx)
278 if err != nil {
279 // TODO: Handle error.
280 }
281 defer c.Close()
282
283 req := &rapidmigrationassessmentpb.RegisterCollectorRequest{
284 // TODO: Fill request struct fields.
285 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#RegisterCollectorRequest.
286 }
287 op, err := c.RegisterCollector(ctx, req)
288 if err != nil {
289 // TODO: Handle error.
290 }
291
292 resp, err := op.Wait(ctx)
293 if err != nil {
294 // TODO: Handle error.
295 }
296 // TODO: Use resp.
297 _ = resp
298 }
299
300 func ExampleClient_ResumeCollector() {
301 ctx := context.Background()
302 // This snippet has been automatically generated and should be regarded as a code template only.
303 // It will require modifications to work:
304 // - It may require correct/in-range values for request initialization.
305 // - It may require specifying regional endpoints when creating the service client as shown in:
306 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
307 c, err := rapidmigrationassessment.NewClient(ctx)
308 if err != nil {
309 // TODO: Handle error.
310 }
311 defer c.Close()
312
313 req := &rapidmigrationassessmentpb.ResumeCollectorRequest{
314 // TODO: Fill request struct fields.
315 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#ResumeCollectorRequest.
316 }
317 op, err := c.ResumeCollector(ctx, req)
318 if err != nil {
319 // TODO: Handle error.
320 }
321
322 resp, err := op.Wait(ctx)
323 if err != nil {
324 // TODO: Handle error.
325 }
326 // TODO: Use resp.
327 _ = resp
328 }
329
330 func ExampleClient_UpdateCollector() {
331 ctx := context.Background()
332 // This snippet has been automatically generated and should be regarded as a code template only.
333 // It will require modifications to work:
334 // - It may require correct/in-range values for request initialization.
335 // - It may require specifying regional endpoints when creating the service client as shown in:
336 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
337 c, err := rapidmigrationassessment.NewClient(ctx)
338 if err != nil {
339 // TODO: Handle error.
340 }
341 defer c.Close()
342
343 req := &rapidmigrationassessmentpb.UpdateCollectorRequest{
344 // TODO: Fill request struct fields.
345 // See https://pkg.go.dev/cloud.google.com/go/rapidmigrationassessment/apiv1/rapidmigrationassessmentpb#UpdateCollectorRequest.
346 }
347 op, err := c.UpdateCollector(ctx, req)
348 if err != nil {
349 // TODO: Handle error.
350 }
351
352 resp, err := op.Wait(ctx)
353 if err != nil {
354 // TODO: Handle error.
355 }
356 // TODO: Use resp.
357 _ = resp
358 }
359
360 func ExampleClient_GetLocation() {
361 ctx := context.Background()
362 // This snippet has been automatically generated and should be regarded as a code template only.
363 // It will require modifications to work:
364 // - It may require correct/in-range values for request initialization.
365 // - It may require specifying regional endpoints when creating the service client as shown in:
366 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
367 c, err := rapidmigrationassessment.NewClient(ctx)
368 if err != nil {
369 // TODO: Handle error.
370 }
371 defer c.Close()
372
373 req := &locationpb.GetLocationRequest{
374 // TODO: Fill request struct fields.
375 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
376 }
377 resp, err := c.GetLocation(ctx, req)
378 if err != nil {
379 // TODO: Handle error.
380 }
381 // TODO: Use resp.
382 _ = resp
383 }
384
385 func ExampleClient_ListLocations() {
386 ctx := context.Background()
387 // This snippet has been automatically generated and should be regarded as a code template only.
388 // It will require modifications to work:
389 // - It may require correct/in-range values for request initialization.
390 // - It may require specifying regional endpoints when creating the service client as shown in:
391 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
392 c, err := rapidmigrationassessment.NewClient(ctx)
393 if err != nil {
394 // TODO: Handle error.
395 }
396 defer c.Close()
397
398 req := &locationpb.ListLocationsRequest{
399 // TODO: Fill request struct fields.
400 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
401 }
402 it := c.ListLocations(ctx, req)
403 for {
404 resp, err := it.Next()
405 if err == iterator.Done {
406 break
407 }
408 if err != nil {
409 // TODO: Handle error.
410 }
411 // TODO: Use resp.
412 _ = resp
413
414 // If you need to access the underlying RPC response,
415 // you can do so by casting the `Response` as below.
416 // Otherwise, remove this line. Only populated after
417 // first call to Next(). Not safe for concurrent access.
418 _ = it.Response.(*locationpb.ListLocationsResponse)
419 }
420 }
421
422 func ExampleClient_CancelOperation() {
423 ctx := context.Background()
424 // This snippet has been automatically generated and should be regarded as a code template only.
425 // It will require modifications to work:
426 // - It may require correct/in-range values for request initialization.
427 // - It may require specifying regional endpoints when creating the service client as shown in:
428 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
429 c, err := rapidmigrationassessment.NewClient(ctx)
430 if err != nil {
431 // TODO: Handle error.
432 }
433 defer c.Close()
434
435 req := &longrunningpb.CancelOperationRequest{
436 // TODO: Fill request struct fields.
437 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
438 }
439 err = c.CancelOperation(ctx, req)
440 if err != nil {
441 // TODO: Handle error.
442 }
443 }
444
445 func ExampleClient_DeleteOperation() {
446 ctx := context.Background()
447 // This snippet has been automatically generated and should be regarded as a code template only.
448 // It will require modifications to work:
449 // - It may require correct/in-range values for request initialization.
450 // - It may require specifying regional endpoints when creating the service client as shown in:
451 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
452 c, err := rapidmigrationassessment.NewClient(ctx)
453 if err != nil {
454 // TODO: Handle error.
455 }
456 defer c.Close()
457
458 req := &longrunningpb.DeleteOperationRequest{
459 // TODO: Fill request struct fields.
460 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
461 }
462 err = c.DeleteOperation(ctx, req)
463 if err != nil {
464 // TODO: Handle error.
465 }
466 }
467
468 func ExampleClient_GetOperation() {
469 ctx := context.Background()
470 // This snippet has been automatically generated and should be regarded as a code template only.
471 // It will require modifications to work:
472 // - It may require correct/in-range values for request initialization.
473 // - It may require specifying regional endpoints when creating the service client as shown in:
474 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
475 c, err := rapidmigrationassessment.NewClient(ctx)
476 if err != nil {
477 // TODO: Handle error.
478 }
479 defer c.Close()
480
481 req := &longrunningpb.GetOperationRequest{
482 // TODO: Fill request struct fields.
483 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
484 }
485 resp, err := c.GetOperation(ctx, req)
486 if err != nil {
487 // TODO: Handle error.
488 }
489 // TODO: Use resp.
490 _ = resp
491 }
492
493 func ExampleClient_ListOperations() {
494 ctx := context.Background()
495 // This snippet has been automatically generated and should be regarded as a code template only.
496 // It will require modifications to work:
497 // - It may require correct/in-range values for request initialization.
498 // - It may require specifying regional endpoints when creating the service client as shown in:
499 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
500 c, err := rapidmigrationassessment.NewClient(ctx)
501 if err != nil {
502 // TODO: Handle error.
503 }
504 defer c.Close()
505
506 req := &longrunningpb.ListOperationsRequest{
507 // TODO: Fill request struct fields.
508 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
509 }
510 it := c.ListOperations(ctx, req)
511 for {
512 resp, err := it.Next()
513 if err == iterator.Done {
514 break
515 }
516 if err != nil {
517 // TODO: Handle error.
518 }
519 // TODO: Use resp.
520 _ = resp
521
522 // If you need to access the underlying RPC response,
523 // you can do so by casting the `Response` as below.
524 // Otherwise, remove this line. Only populated after
525 // first call to Next(). Not safe for concurrent access.
526 _ = it.Response.(*longrunningpb.ListOperationsResponse)
527 }
528 }