Debian Codegraph @

licensemanager/apiv1/license_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 licensemanager_test
18
19 import (
20 "context"
21
22 licensemanager "cloud.google.com/go/licensemanager/apiv1"
23 licensemanagerpb "cloud.google.com/go/licensemanager/apiv1/licensemanagerpb"
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 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 := licensemanager.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 := licensemanager.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_AggregateUsage() {
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 := licensemanager.NewClient(ctx)
71 if err != nil {
72 // TODO: Handle error.
73 }
74 defer c.Close()
75
76 req := &licensemanagerpb.AggregateUsageRequest{
77 // TODO: Fill request struct fields.
78 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#AggregateUsageRequest.
79 }
80 it := c.AggregateUsage(ctx, req)
81 for {
82 resp, err := it.Next()
83 if err == iterator.Done {
84 break
85 }
86 if err != nil {
87 // TODO: Handle error.
88 }
89 // TODO: Use resp.
90 _ = resp
91
92 // If you need to access the underlying RPC response,
93 // you can do so by casting the `Response` as below.
94 // Otherwise, remove this line. Only populated after
95 // first call to Next(). Not safe for concurrent access.
96 _ = it.Response.(*licensemanagerpb.AggregateUsageResponse)
97 }
98 }
99
100 func ExampleClient_CreateConfiguration() {
101 ctx := context.Background()
102 // This snippet has been automatically generated and should be regarded as a code template only.
103 // It will require modifications to work:
104 // - It may require correct/in-range values for request initialization.
105 // - It may require specifying regional endpoints when creating the service client as shown in:
106 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
107 c, err := licensemanager.NewClient(ctx)
108 if err != nil {
109 // TODO: Handle error.
110 }
111 defer c.Close()
112
113 req := &licensemanagerpb.CreateConfigurationRequest{
114 // TODO: Fill request struct fields.
115 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#CreateConfigurationRequest.
116 }
117 op, err := c.CreateConfiguration(ctx, req)
118 if err != nil {
119 // TODO: Handle error.
120 }
121
122 resp, err := op.Wait(ctx)
123 if err != nil {
124 // TODO: Handle error.
125 }
126 // TODO: Use resp.
127 _ = resp
128 }
129
130 func ExampleClient_DeactivateConfiguration() {
131 ctx := context.Background()
132 // This snippet has been automatically generated and should be regarded as a code template only.
133 // It will require modifications to work:
134 // - It may require correct/in-range values for request initialization.
135 // - It may require specifying regional endpoints when creating the service client as shown in:
136 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
137 c, err := licensemanager.NewClient(ctx)
138 if err != nil {
139 // TODO: Handle error.
140 }
141 defer c.Close()
142
143 req := &licensemanagerpb.DeactivateConfigurationRequest{
144 // TODO: Fill request struct fields.
145 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#DeactivateConfigurationRequest.
146 }
147 op, err := c.DeactivateConfiguration(ctx, req)
148 if err != nil {
149 // TODO: Handle error.
150 }
151
152 resp, err := op.Wait(ctx)
153 if err != nil {
154 // TODO: Handle error.
155 }
156 // TODO: Use resp.
157 _ = resp
158 }
159
160 func ExampleClient_DeleteConfiguration() {
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 := licensemanager.NewClient(ctx)
168 if err != nil {
169 // TODO: Handle error.
170 }
171 defer c.Close()
172
173 req := &licensemanagerpb.DeleteConfigurationRequest{
174 // TODO: Fill request struct fields.
175 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#DeleteConfigurationRequest.
176 }
177 op, err := c.DeleteConfiguration(ctx, req)
178 if err != nil {
179 // TODO: Handle error.
180 }
181
182 err = op.Wait(ctx)
183 if err != nil {
184 // TODO: Handle error.
185 }
186 }
187
188 func ExampleClient_GetConfiguration() {
189 ctx := context.Background()
190 // This snippet has been automatically generated and should be regarded as a code template only.
191 // It will require modifications to work:
192 // - It may require correct/in-range values for request initialization.
193 // - It may require specifying regional endpoints when creating the service client as shown in:
194 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
195 c, err := licensemanager.NewClient(ctx)
196 if err != nil {
197 // TODO: Handle error.
198 }
199 defer c.Close()
200
201 req := &licensemanagerpb.GetConfigurationRequest{
202 // TODO: Fill request struct fields.
203 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#GetConfigurationRequest.
204 }
205 resp, err := c.GetConfiguration(ctx, req)
206 if err != nil {
207 // TODO: Handle error.
208 }
209 // TODO: Use resp.
210 _ = resp
211 }
212
213 func ExampleClient_GetInstance() {
214 ctx := context.Background()
215 // This snippet has been automatically generated and should be regarded as a code template only.
216 // It will require modifications to work:
217 // - It may require correct/in-range values for request initialization.
218 // - It may require specifying regional endpoints when creating the service client as shown in:
219 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
220 c, err := licensemanager.NewClient(ctx)
221 if err != nil {
222 // TODO: Handle error.
223 }
224 defer c.Close()
225
226 req := &licensemanagerpb.GetInstanceRequest{
227 // TODO: Fill request struct fields.
228 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#GetInstanceRequest.
229 }
230 resp, err := c.GetInstance(ctx, req)
231 if err != nil {
232 // TODO: Handle error.
233 }
234 // TODO: Use resp.
235 _ = resp
236 }
237
238 func ExampleClient_GetProduct() {
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 := licensemanager.NewClient(ctx)
246 if err != nil {
247 // TODO: Handle error.
248 }
249 defer c.Close()
250
251 req := &licensemanagerpb.GetProductRequest{
252 // TODO: Fill request struct fields.
253 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#GetProductRequest.
254 }
255 resp, err := c.GetProduct(ctx, req)
256 if err != nil {
257 // TODO: Handle error.
258 }
259 // TODO: Use resp.
260 _ = resp
261 }
262
263 func ExampleClient_ListConfigurations() {
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 := licensemanager.NewClient(ctx)
271 if err != nil {
272 // TODO: Handle error.
273 }
274 defer c.Close()
275
276 req := &licensemanagerpb.ListConfigurationsRequest{
277 // TODO: Fill request struct fields.
278 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#ListConfigurationsRequest.
279 }
280 it := c.ListConfigurations(ctx, req)
281 for {
282 resp, err := it.Next()
283 if err == iterator.Done {
284 break
285 }
286 if err != nil {
287 // TODO: Handle error.
288 }
289 // TODO: Use resp.
290 _ = resp
291
292 // If you need to access the underlying RPC response,
293 // you can do so by casting the `Response` as below.
294 // Otherwise, remove this line. Only populated after
295 // first call to Next(). Not safe for concurrent access.
296 _ = it.Response.(*licensemanagerpb.ListConfigurationsResponse)
297 }
298 }
299
300 func ExampleClient_ListInstances() {
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 := licensemanager.NewClient(ctx)
308 if err != nil {
309 // TODO: Handle error.
310 }
311 defer c.Close()
312
313 req := &licensemanagerpb.ListInstancesRequest{
314 // TODO: Fill request struct fields.
315 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#ListInstancesRequest.
316 }
317 it := c.ListInstances(ctx, req)
318 for {
319 resp, err := it.Next()
320 if err == iterator.Done {
321 break
322 }
323 if err != nil {
324 // TODO: Handle error.
325 }
326 // TODO: Use resp.
327 _ = resp
328
329 // If you need to access the underlying RPC response,
330 // you can do so by casting the `Response` as below.
331 // Otherwise, remove this line. Only populated after
332 // first call to Next(). Not safe for concurrent access.
333 _ = it.Response.(*licensemanagerpb.ListInstancesResponse)
334 }
335 }
336
337 func ExampleClient_ListProducts() {
338 ctx := context.Background()
339 // This snippet has been automatically generated and should be regarded as a code template only.
340 // It will require modifications to work:
341 // - It may require correct/in-range values for request initialization.
342 // - It may require specifying regional endpoints when creating the service client as shown in:
343 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
344 c, err := licensemanager.NewClient(ctx)
345 if err != nil {
346 // TODO: Handle error.
347 }
348 defer c.Close()
349
350 req := &licensemanagerpb.ListProductsRequest{
351 // TODO: Fill request struct fields.
352 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#ListProductsRequest.
353 }
354 it := c.ListProducts(ctx, req)
355 for {
356 resp, err := it.Next()
357 if err == iterator.Done {
358 break
359 }
360 if err != nil {
361 // TODO: Handle error.
362 }
363 // TODO: Use resp.
364 _ = resp
365
366 // If you need to access the underlying RPC response,
367 // you can do so by casting the `Response` as below.
368 // Otherwise, remove this line. Only populated after
369 // first call to Next(). Not safe for concurrent access.
370 _ = it.Response.(*licensemanagerpb.ListProductsResponse)
371 }
372 }
373
374 func ExampleClient_QueryConfigurationLicenseUsage() {
375 ctx := context.Background()
376 // This snippet has been automatically generated and should be regarded as a code template only.
377 // It will require modifications to work:
378 // - It may require correct/in-range values for request initialization.
379 // - It may require specifying regional endpoints when creating the service client as shown in:
380 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
381 c, err := licensemanager.NewClient(ctx)
382 if err != nil {
383 // TODO: Handle error.
384 }
385 defer c.Close()
386
387 req := &licensemanagerpb.QueryConfigurationLicenseUsageRequest{
388 // TODO: Fill request struct fields.
389 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#QueryConfigurationLicenseUsageRequest.
390 }
391 resp, err := c.QueryConfigurationLicenseUsage(ctx, req)
392 if err != nil {
393 // TODO: Handle error.
394 }
395 // TODO: Use resp.
396 _ = resp
397 }
398
399 func ExampleClient_ReactivateConfiguration() {
400 ctx := context.Background()
401 // This snippet has been automatically generated and should be regarded as a code template only.
402 // It will require modifications to work:
403 // - It may require correct/in-range values for request initialization.
404 // - It may require specifying regional endpoints when creating the service client as shown in:
405 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
406 c, err := licensemanager.NewClient(ctx)
407 if err != nil {
408 // TODO: Handle error.
409 }
410 defer c.Close()
411
412 req := &licensemanagerpb.ReactivateConfigurationRequest{
413 // TODO: Fill request struct fields.
414 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#ReactivateConfigurationRequest.
415 }
416 op, err := c.ReactivateConfiguration(ctx, req)
417 if err != nil {
418 // TODO: Handle error.
419 }
420
421 resp, err := op.Wait(ctx)
422 if err != nil {
423 // TODO: Handle error.
424 }
425 // TODO: Use resp.
426 _ = resp
427 }
428
429 func ExampleClient_UpdateConfiguration() {
430 ctx := context.Background()
431 // This snippet has been automatically generated and should be regarded as a code template only.
432 // It will require modifications to work:
433 // - It may require correct/in-range values for request initialization.
434 // - It may require specifying regional endpoints when creating the service client as shown in:
435 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
436 c, err := licensemanager.NewClient(ctx)
437 if err != nil {
438 // TODO: Handle error.
439 }
440 defer c.Close()
441
442 req := &licensemanagerpb.UpdateConfigurationRequest{
443 // TODO: Fill request struct fields.
444 // See https://pkg.go.dev/cloud.google.com/go/licensemanager/apiv1/licensemanagerpb#UpdateConfigurationRequest.
445 }
446 op, err := c.UpdateConfiguration(ctx, req)
447 if err != nil {
448 // TODO: Handle error.
449 }
450
451 resp, err := op.Wait(ctx)
452 if err != nil {
453 // TODO: Handle error.
454 }
455 // TODO: Use resp.
456 _ = resp
457 }
458
459 func ExampleClient_GetLocation() {
460 ctx := context.Background()
461 // This snippet has been automatically generated and should be regarded as a code template only.
462 // It will require modifications to work:
463 // - It may require correct/in-range values for request initialization.
464 // - It may require specifying regional endpoints when creating the service client as shown in:
465 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
466 c, err := licensemanager.NewClient(ctx)
467 if err != nil {
468 // TODO: Handle error.
469 }
470 defer c.Close()
471
472 req := &locationpb.GetLocationRequest{
473 // TODO: Fill request struct fields.
474 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
475 }
476 resp, err := c.GetLocation(ctx, req)
477 if err != nil {
478 // TODO: Handle error.
479 }
480 // TODO: Use resp.
481 _ = resp
482 }
483
484 func ExampleClient_ListLocations() {
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 := licensemanager.NewClient(ctx)
492 if err != nil {
493 // TODO: Handle error.
494 }
495 defer c.Close()
496
497 req := &locationpb.ListLocationsRequest{
498 // TODO: Fill request struct fields.
499 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
500 }
501 it := c.ListLocations(ctx, req)
502 for {
503 resp, err := it.Next()
504 if err == iterator.Done {
505 break
506 }
507 if err != nil {
508 // TODO: Handle error.
509 }
510 // TODO: Use resp.
511 _ = resp
512
513 // If you need to access the underlying RPC response,
514 // you can do so by casting the `Response` as below.
515 // Otherwise, remove this line. Only populated after
516 // first call to Next(). Not safe for concurrent access.
517 _ = it.Response.(*locationpb.ListLocationsResponse)
518 }
519 }
520
521 func ExampleClient_CancelOperation() {
522 ctx := context.Background()
523 // This snippet has been automatically generated and should be regarded as a code template only.
524 // It will require modifications to work:
525 // - It may require correct/in-range values for request initialization.
526 // - It may require specifying regional endpoints when creating the service client as shown in:
527 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
528 c, err := licensemanager.NewClient(ctx)
529 if err != nil {
530 // TODO: Handle error.
531 }
532 defer c.Close()
533
534 req := &longrunningpb.CancelOperationRequest{
535 // TODO: Fill request struct fields.
536 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
537 }
538 err = c.CancelOperation(ctx, req)
539 if err != nil {
540 // TODO: Handle error.
541 }
542 }
543
544 func ExampleClient_DeleteOperation() {
545 ctx := context.Background()
546 // This snippet has been automatically generated and should be regarded as a code template only.
547 // It will require modifications to work:
548 // - It may require correct/in-range values for request initialization.
549 // - It may require specifying regional endpoints when creating the service client as shown in:
550 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
551 c, err := licensemanager.NewClient(ctx)
552 if err != nil {
553 // TODO: Handle error.
554 }
555 defer c.Close()
556
557 req := &longrunningpb.DeleteOperationRequest{
558 // TODO: Fill request struct fields.
559 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
560 }
561 err = c.DeleteOperation(ctx, req)
562 if err != nil {
563 // TODO: Handle error.
564 }
565 }
566
567 func ExampleClient_GetOperation() {
568 ctx := context.Background()
569 // This snippet has been automatically generated and should be regarded as a code template only.
570 // It will require modifications to work:
571 // - It may require correct/in-range values for request initialization.
572 // - It may require specifying regional endpoints when creating the service client as shown in:
573 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
574 c, err := licensemanager.NewClient(ctx)
575 if err != nil {
576 // TODO: Handle error.
577 }
578 defer c.Close()
579
580 req := &longrunningpb.GetOperationRequest{
581 // TODO: Fill request struct fields.
582 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
583 }
584 resp, err := c.GetOperation(ctx, req)
585 if err != nil {
586 // TODO: Handle error.
587 }
588 // TODO: Use resp.
589 _ = resp
590 }
591
592 func ExampleClient_ListOperations() {
593 ctx := context.Background()
594 // This snippet has been automatically generated and should be regarded as a code template only.
595 // It will require modifications to work:
596 // - It may require correct/in-range values for request initialization.
597 // - It may require specifying regional endpoints when creating the service client as shown in:
598 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
599 c, err := licensemanager.NewClient(ctx)
600 if err != nil {
601 // TODO: Handle error.
602 }
603 defer c.Close()
604
605 req := &longrunningpb.ListOperationsRequest{
606 // TODO: Fill request struct fields.
607 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
608 }
609 it := c.ListOperations(ctx, req)
610 for {
611 resp, err := it.Next()
612 if err == iterator.Done {
613 break
614 }
615 if err != nil {
616 // TODO: Handle error.
617 }
618 // TODO: Use resp.
619 _ = resp
620
621 // If you need to access the underlying RPC response,
622 // you can do so by casting the `Response` as below.
623 // Otherwise, remove this line. Only populated after
624 // first call to Next(). Not safe for concurrent access.
625 _ = it.Response.(*longrunningpb.ListOperationsResponse)
626 }
627 }