Debian Codegraph @

artifactregistry/apiv1beta2/artifact_registry_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 artifactregistry_test
18
19 import (
20 "context"
21
22 artifactregistry "cloud.google.com/go/artifactregistry/apiv1beta2"
23 artifactregistrypb "cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb"
24 iampb "cloud.google.com/go/iam/apiv1/iampb"
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 := artifactregistry.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 := artifactregistry.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_CreateRepository() {
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 := artifactregistry.NewClient(ctx)
71 if err != nil {
72 // TODO: Handle error.
73 }
74 defer c.Close()
75
76 req := &artifactregistrypb.CreateRepositoryRequest{
77 // TODO: Fill request struct fields.
78 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#CreateRepositoryRequest.
79 }
80 op, err := c.CreateRepository(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_CreateTag() {
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 := artifactregistry.NewClient(ctx)
101 if err != nil {
102 // TODO: Handle error.
103 }
104 defer c.Close()
105
106 req := &artifactregistrypb.CreateTagRequest{
107 // TODO: Fill request struct fields.
108 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#CreateTagRequest.
109 }
110 resp, err := c.CreateTag(ctx, req)
111 if err != nil {
112 // TODO: Handle error.
113 }
114 // TODO: Use resp.
115 _ = resp
116 }
117
118 func ExampleClient_DeletePackage() {
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 := artifactregistry.NewClient(ctx)
126 if err != nil {
127 // TODO: Handle error.
128 }
129 defer c.Close()
130
131 req := &artifactregistrypb.DeletePackageRequest{
132 // TODO: Fill request struct fields.
133 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#DeletePackageRequest.
134 }
135 op, err := c.DeletePackage(ctx, req)
136 if err != nil {
137 // TODO: Handle error.
138 }
139
140 err = op.Wait(ctx)
141 if err != nil {
142 // TODO: Handle error.
143 }
144 }
145
146 func ExampleClient_DeleteRepository() {
147 ctx := context.Background()
148 // This snippet has been automatically generated and should be regarded as a code template only.
149 // It will require modifications to work:
150 // - It may require correct/in-range values for request initialization.
151 // - It may require specifying regional endpoints when creating the service client as shown in:
152 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
153 c, err := artifactregistry.NewClient(ctx)
154 if err != nil {
155 // TODO: Handle error.
156 }
157 defer c.Close()
158
159 req := &artifactregistrypb.DeleteRepositoryRequest{
160 // TODO: Fill request struct fields.
161 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#DeleteRepositoryRequest.
162 }
163 op, err := c.DeleteRepository(ctx, req)
164 if err != nil {
165 // TODO: Handle error.
166 }
167
168 err = op.Wait(ctx)
169 if err != nil {
170 // TODO: Handle error.
171 }
172 }
173
174 func ExampleClient_DeleteTag() {
175 ctx := context.Background()
176 // This snippet has been automatically generated and should be regarded as a code template only.
177 // It will require modifications to work:
178 // - It may require correct/in-range values for request initialization.
179 // - It may require specifying regional endpoints when creating the service client as shown in:
180 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
181 c, err := artifactregistry.NewClient(ctx)
182 if err != nil {
183 // TODO: Handle error.
184 }
185 defer c.Close()
186
187 req := &artifactregistrypb.DeleteTagRequest{
188 // TODO: Fill request struct fields.
189 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#DeleteTagRequest.
190 }
191 err = c.DeleteTag(ctx, req)
192 if err != nil {
193 // TODO: Handle error.
194 }
195 }
196
197 func ExampleClient_DeleteVersion() {
198 ctx := context.Background()
199 // This snippet has been automatically generated and should be regarded as a code template only.
200 // It will require modifications to work:
201 // - It may require correct/in-range values for request initialization.
202 // - It may require specifying regional endpoints when creating the service client as shown in:
203 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
204 c, err := artifactregistry.NewClient(ctx)
205 if err != nil {
206 // TODO: Handle error.
207 }
208 defer c.Close()
209
210 req := &artifactregistrypb.DeleteVersionRequest{
211 // TODO: Fill request struct fields.
212 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#DeleteVersionRequest.
213 }
214 op, err := c.DeleteVersion(ctx, req)
215 if err != nil {
216 // TODO: Handle error.
217 }
218
219 err = op.Wait(ctx)
220 if err != nil {
221 // TODO: Handle error.
222 }
223 }
224
225 func ExampleClient_GetFile() {
226 ctx := context.Background()
227 // This snippet has been automatically generated and should be regarded as a code template only.
228 // It will require modifications to work:
229 // - It may require correct/in-range values for request initialization.
230 // - It may require specifying regional endpoints when creating the service client as shown in:
231 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
232 c, err := artifactregistry.NewClient(ctx)
233 if err != nil {
234 // TODO: Handle error.
235 }
236 defer c.Close()
237
238 req := &artifactregistrypb.GetFileRequest{
239 // TODO: Fill request struct fields.
240 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#GetFileRequest.
241 }
242 resp, err := c.GetFile(ctx, req)
243 if err != nil {
244 // TODO: Handle error.
245 }
246 // TODO: Use resp.
247 _ = resp
248 }
249
250 func ExampleClient_GetIamPolicy() {
251 ctx := context.Background()
252 // This snippet has been automatically generated and should be regarded as a code template only.
253 // It will require modifications to work:
254 // - It may require correct/in-range values for request initialization.
255 // - It may require specifying regional endpoints when creating the service client as shown in:
256 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
257 c, err := artifactregistry.NewClient(ctx)
258 if err != nil {
259 // TODO: Handle error.
260 }
261 defer c.Close()
262
263 req := &iampb.GetIamPolicyRequest{
264 // TODO: Fill request struct fields.
265 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
266 }
267 resp, err := c.GetIamPolicy(ctx, req)
268 if err != nil {
269 // TODO: Handle error.
270 }
271 // TODO: Use resp.
272 _ = resp
273 }
274
275 func ExampleClient_GetPackage() {
276 ctx := context.Background()
277 // This snippet has been automatically generated and should be regarded as a code template only.
278 // It will require modifications to work:
279 // - It may require correct/in-range values for request initialization.
280 // - It may require specifying regional endpoints when creating the service client as shown in:
281 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
282 c, err := artifactregistry.NewClient(ctx)
283 if err != nil {
284 // TODO: Handle error.
285 }
286 defer c.Close()
287
288 req := &artifactregistrypb.GetPackageRequest{
289 // TODO: Fill request struct fields.
290 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#GetPackageRequest.
291 }
292 resp, err := c.GetPackage(ctx, req)
293 if err != nil {
294 // TODO: Handle error.
295 }
296 // TODO: Use resp.
297 _ = resp
298 }
299
300 func ExampleClient_GetProjectSettings() {
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 := artifactregistry.NewClient(ctx)
308 if err != nil {
309 // TODO: Handle error.
310 }
311 defer c.Close()
312
313 req := &artifactregistrypb.GetProjectSettingsRequest{
314 // TODO: Fill request struct fields.
315 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#GetProjectSettingsRequest.
316 }
317 resp, err := c.GetProjectSettings(ctx, req)
318 if err != nil {
319 // TODO: Handle error.
320 }
321 // TODO: Use resp.
322 _ = resp
323 }
324
325 func ExampleClient_GetRepository() {
326 ctx := context.Background()
327 // This snippet has been automatically generated and should be regarded as a code template only.
328 // It will require modifications to work:
329 // - It may require correct/in-range values for request initialization.
330 // - It may require specifying regional endpoints when creating the service client as shown in:
331 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
332 c, err := artifactregistry.NewClient(ctx)
333 if err != nil {
334 // TODO: Handle error.
335 }
336 defer c.Close()
337
338 req := &artifactregistrypb.GetRepositoryRequest{
339 // TODO: Fill request struct fields.
340 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#GetRepositoryRequest.
341 }
342 resp, err := c.GetRepository(ctx, req)
343 if err != nil {
344 // TODO: Handle error.
345 }
346 // TODO: Use resp.
347 _ = resp
348 }
349
350 func ExampleClient_GetTag() {
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 := artifactregistry.NewClient(ctx)
358 if err != nil {
359 // TODO: Handle error.
360 }
361 defer c.Close()
362
363 req := &artifactregistrypb.GetTagRequest{
364 // TODO: Fill request struct fields.
365 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#GetTagRequest.
366 }
367 resp, err := c.GetTag(ctx, req)
368 if err != nil {
369 // TODO: Handle error.
370 }
371 // TODO: Use resp.
372 _ = resp
373 }
374
375 func ExampleClient_GetVersion() {
376 ctx := context.Background()
377 // This snippet has been automatically generated and should be regarded as a code template only.
378 // It will require modifications to work:
379 // - It may require correct/in-range values for request initialization.
380 // - It may require specifying regional endpoints when creating the service client as shown in:
381 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
382 c, err := artifactregistry.NewClient(ctx)
383 if err != nil {
384 // TODO: Handle error.
385 }
386 defer c.Close()
387
388 req := &artifactregistrypb.GetVersionRequest{
389 // TODO: Fill request struct fields.
390 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#GetVersionRequest.
391 }
392 resp, err := c.GetVersion(ctx, req)
393 if err != nil {
394 // TODO: Handle error.
395 }
396 // TODO: Use resp.
397 _ = resp
398 }
399
400 func ExampleClient_ImportAptArtifacts() {
401 ctx := context.Background()
402 // This snippet has been automatically generated and should be regarded as a code template only.
403 // It will require modifications to work:
404 // - It may require correct/in-range values for request initialization.
405 // - It may require specifying regional endpoints when creating the service client as shown in:
406 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
407 c, err := artifactregistry.NewClient(ctx)
408 if err != nil {
409 // TODO: Handle error.
410 }
411 defer c.Close()
412
413 req := &artifactregistrypb.ImportAptArtifactsRequest{
414 // TODO: Fill request struct fields.
415 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#ImportAptArtifactsRequest.
416 }
417 op, err := c.ImportAptArtifacts(ctx, req)
418 if err != nil {
419 // TODO: Handle error.
420 }
421
422 resp, err := op.Wait(ctx)
423 if err != nil {
424 // TODO: Handle error.
425 }
426 // TODO: Use resp.
427 _ = resp
428 }
429
430 func ExampleClient_ImportYumArtifacts() {
431 ctx := context.Background()
432 // This snippet has been automatically generated and should be regarded as a code template only.
433 // It will require modifications to work:
434 // - It may require correct/in-range values for request initialization.
435 // - It may require specifying regional endpoints when creating the service client as shown in:
436 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
437 c, err := artifactregistry.NewClient(ctx)
438 if err != nil {
439 // TODO: Handle error.
440 }
441 defer c.Close()
442
443 req := &artifactregistrypb.ImportYumArtifactsRequest{
444 // TODO: Fill request struct fields.
445 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#ImportYumArtifactsRequest.
446 }
447 op, err := c.ImportYumArtifacts(ctx, req)
448 if err != nil {
449 // TODO: Handle error.
450 }
451
452 resp, err := op.Wait(ctx)
453 if err != nil {
454 // TODO: Handle error.
455 }
456 // TODO: Use resp.
457 _ = resp
458 }
459
460 func ExampleClient_ListFiles() {
461 ctx := context.Background()
462 // This snippet has been automatically generated and should be regarded as a code template only.
463 // It will require modifications to work:
464 // - It may require correct/in-range values for request initialization.
465 // - It may require specifying regional endpoints when creating the service client as shown in:
466 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
467 c, err := artifactregistry.NewClient(ctx)
468 if err != nil {
469 // TODO: Handle error.
470 }
471 defer c.Close()
472
473 req := &artifactregistrypb.ListFilesRequest{
474 // TODO: Fill request struct fields.
475 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#ListFilesRequest.
476 }
477 it := c.ListFiles(ctx, req)
478 for {
479 resp, err := it.Next()
480 if err == iterator.Done {
481 break
482 }
483 if err != nil {
484 // TODO: Handle error.
485 }
486 // TODO: Use resp.
487 _ = resp
488
489 // If you need to access the underlying RPC response,
490 // you can do so by casting the `Response` as below.
491 // Otherwise, remove this line. Only populated after
492 // first call to Next(). Not safe for concurrent access.
493 _ = it.Response.(*artifactregistrypb.ListFilesResponse)
494 }
495 }
496
497 func ExampleClient_ListPackages() {
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 := artifactregistry.NewClient(ctx)
505 if err != nil {
506 // TODO: Handle error.
507 }
508 defer c.Close()
509
510 req := &artifactregistrypb.ListPackagesRequest{
511 // TODO: Fill request struct fields.
512 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#ListPackagesRequest.
513 }
514 it := c.ListPackages(ctx, req)
515 for {
516 resp, err := it.Next()
517 if err == iterator.Done {
518 break
519 }
520 if err != nil {
521 // TODO: Handle error.
522 }
523 // TODO: Use resp.
524 _ = resp
525
526 // If you need to access the underlying RPC response,
527 // you can do so by casting the `Response` as below.
528 // Otherwise, remove this line. Only populated after
529 // first call to Next(). Not safe for concurrent access.
530 _ = it.Response.(*artifactregistrypb.ListPackagesResponse)
531 }
532 }
533
534 func ExampleClient_ListRepositories() {
535 ctx := context.Background()
536 // This snippet has been automatically generated and should be regarded as a code template only.
537 // It will require modifications to work:
538 // - It may require correct/in-range values for request initialization.
539 // - It may require specifying regional endpoints when creating the service client as shown in:
540 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
541 c, err := artifactregistry.NewClient(ctx)
542 if err != nil {
543 // TODO: Handle error.
544 }
545 defer c.Close()
546
547 req := &artifactregistrypb.ListRepositoriesRequest{
548 // TODO: Fill request struct fields.
549 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#ListRepositoriesRequest.
550 }
551 it := c.ListRepositories(ctx, req)
552 for {
553 resp, err := it.Next()
554 if err == iterator.Done {
555 break
556 }
557 if err != nil {
558 // TODO: Handle error.
559 }
560 // TODO: Use resp.
561 _ = resp
562
563 // If you need to access the underlying RPC response,
564 // you can do so by casting the `Response` as below.
565 // Otherwise, remove this line. Only populated after
566 // first call to Next(). Not safe for concurrent access.
567 _ = it.Response.(*artifactregistrypb.ListRepositoriesResponse)
568 }
569 }
570
571 func ExampleClient_ListTags() {
572 ctx := context.Background()
573 // This snippet has been automatically generated and should be regarded as a code template only.
574 // It will require modifications to work:
575 // - It may require correct/in-range values for request initialization.
576 // - It may require specifying regional endpoints when creating the service client as shown in:
577 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
578 c, err := artifactregistry.NewClient(ctx)
579 if err != nil {
580 // TODO: Handle error.
581 }
582 defer c.Close()
583
584 req := &artifactregistrypb.ListTagsRequest{
585 // TODO: Fill request struct fields.
586 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#ListTagsRequest.
587 }
588 it := c.ListTags(ctx, req)
589 for {
590 resp, err := it.Next()
591 if err == iterator.Done {
592 break
593 }
594 if err != nil {
595 // TODO: Handle error.
596 }
597 // TODO: Use resp.
598 _ = resp
599
600 // If you need to access the underlying RPC response,
601 // you can do so by casting the `Response` as below.
602 // Otherwise, remove this line. Only populated after
603 // first call to Next(). Not safe for concurrent access.
604 _ = it.Response.(*artifactregistrypb.ListTagsResponse)
605 }
606 }
607
608 func ExampleClient_ListVersions() {
609 ctx := context.Background()
610 // This snippet has been automatically generated and should be regarded as a code template only.
611 // It will require modifications to work:
612 // - It may require correct/in-range values for request initialization.
613 // - It may require specifying regional endpoints when creating the service client as shown in:
614 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
615 c, err := artifactregistry.NewClient(ctx)
616 if err != nil {
617 // TODO: Handle error.
618 }
619 defer c.Close()
620
621 req := &artifactregistrypb.ListVersionsRequest{
622 // TODO: Fill request struct fields.
623 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#ListVersionsRequest.
624 }
625 it := c.ListVersions(ctx, req)
626 for {
627 resp, err := it.Next()
628 if err == iterator.Done {
629 break
630 }
631 if err != nil {
632 // TODO: Handle error.
633 }
634 // TODO: Use resp.
635 _ = resp
636
637 // If you need to access the underlying RPC response,
638 // you can do so by casting the `Response` as below.
639 // Otherwise, remove this line. Only populated after
640 // first call to Next(). Not safe for concurrent access.
641 _ = it.Response.(*artifactregistrypb.ListVersionsResponse)
642 }
643 }
644
645 func ExampleClient_SetIamPolicy() {
646 ctx := context.Background()
647 // This snippet has been automatically generated and should be regarded as a code template only.
648 // It will require modifications to work:
649 // - It may require correct/in-range values for request initialization.
650 // - It may require specifying regional endpoints when creating the service client as shown in:
651 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
652 c, err := artifactregistry.NewClient(ctx)
653 if err != nil {
654 // TODO: Handle error.
655 }
656 defer c.Close()
657
658 req := &iampb.SetIamPolicyRequest{
659 // TODO: Fill request struct fields.
660 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
661 }
662 resp, err := c.SetIamPolicy(ctx, req)
663 if err != nil {
664 // TODO: Handle error.
665 }
666 // TODO: Use resp.
667 _ = resp
668 }
669
670 func ExampleClient_TestIamPermissions() {
671 ctx := context.Background()
672 // This snippet has been automatically generated and should be regarded as a code template only.
673 // It will require modifications to work:
674 // - It may require correct/in-range values for request initialization.
675 // - It may require specifying regional endpoints when creating the service client as shown in:
676 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
677 c, err := artifactregistry.NewClient(ctx)
678 if err != nil {
679 // TODO: Handle error.
680 }
681 defer c.Close()
682
683 req := &iampb.TestIamPermissionsRequest{
684 // TODO: Fill request struct fields.
685 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
686 }
687 resp, err := c.TestIamPermissions(ctx, req)
688 if err != nil {
689 // TODO: Handle error.
690 }
691 // TODO: Use resp.
692 _ = resp
693 }
694
695 func ExampleClient_UpdateProjectSettings() {
696 ctx := context.Background()
697 // This snippet has been automatically generated and should be regarded as a code template only.
698 // It will require modifications to work:
699 // - It may require correct/in-range values for request initialization.
700 // - It may require specifying regional endpoints when creating the service client as shown in:
701 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
702 c, err := artifactregistry.NewClient(ctx)
703 if err != nil {
704 // TODO: Handle error.
705 }
706 defer c.Close()
707
708 req := &artifactregistrypb.UpdateProjectSettingsRequest{
709 // TODO: Fill request struct fields.
710 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#UpdateProjectSettingsRequest.
711 }
712 resp, err := c.UpdateProjectSettings(ctx, req)
713 if err != nil {
714 // TODO: Handle error.
715 }
716 // TODO: Use resp.
717 _ = resp
718 }
719
720 func ExampleClient_UpdateRepository() {
721 ctx := context.Background()
722 // This snippet has been automatically generated and should be regarded as a code template only.
723 // It will require modifications to work:
724 // - It may require correct/in-range values for request initialization.
725 // - It may require specifying regional endpoints when creating the service client as shown in:
726 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
727 c, err := artifactregistry.NewClient(ctx)
728 if err != nil {
729 // TODO: Handle error.
730 }
731 defer c.Close()
732
733 req := &artifactregistrypb.UpdateRepositoryRequest{
734 // TODO: Fill request struct fields.
735 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#UpdateRepositoryRequest.
736 }
737 resp, err := c.UpdateRepository(ctx, req)
738 if err != nil {
739 // TODO: Handle error.
740 }
741 // TODO: Use resp.
742 _ = resp
743 }
744
745 func ExampleClient_UpdateTag() {
746 ctx := context.Background()
747 // This snippet has been automatically generated and should be regarded as a code template only.
748 // It will require modifications to work:
749 // - It may require correct/in-range values for request initialization.
750 // - It may require specifying regional endpoints when creating the service client as shown in:
751 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
752 c, err := artifactregistry.NewClient(ctx)
753 if err != nil {
754 // TODO: Handle error.
755 }
756 defer c.Close()
757
758 req := &artifactregistrypb.UpdateTagRequest{
759 // TODO: Fill request struct fields.
760 // See https://pkg.go.dev/cloud.google.com/go/artifactregistry/apiv1beta2/artifactregistrypb#UpdateTagRequest.
761 }
762 resp, err := c.UpdateTag(ctx, req)
763 if err != nil {
764 // TODO: Handle error.
765 }
766 // TODO: Use resp.
767 _ = resp
768 }
769
770 func ExampleClient_GetLocation() {
771 ctx := context.Background()
772 // This snippet has been automatically generated and should be regarded as a code template only.
773 // It will require modifications to work:
774 // - It may require correct/in-range values for request initialization.
775 // - It may require specifying regional endpoints when creating the service client as shown in:
776 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
777 c, err := artifactregistry.NewClient(ctx)
778 if err != nil {
779 // TODO: Handle error.
780 }
781 defer c.Close()
782
783 req := &locationpb.GetLocationRequest{
784 // TODO: Fill request struct fields.
785 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
786 }
787 resp, err := c.GetLocation(ctx, req)
788 if err != nil {
789 // TODO: Handle error.
790 }
791 // TODO: Use resp.
792 _ = resp
793 }
794
795 func ExampleClient_ListLocations() {
796 ctx := context.Background()
797 // This snippet has been automatically generated and should be regarded as a code template only.
798 // It will require modifications to work:
799 // - It may require correct/in-range values for request initialization.
800 // - It may require specifying regional endpoints when creating the service client as shown in:
801 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
802 c, err := artifactregistry.NewClient(ctx)
803 if err != nil {
804 // TODO: Handle error.
805 }
806 defer c.Close()
807
808 req := &locationpb.ListLocationsRequest{
809 // TODO: Fill request struct fields.
810 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
811 }
812 it := c.ListLocations(ctx, req)
813 for {
814 resp, err := it.Next()
815 if err == iterator.Done {
816 break
817 }
818 if err != nil {
819 // TODO: Handle error.
820 }
821 // TODO: Use resp.
822 _ = resp
823
824 // If you need to access the underlying RPC response,
825 // you can do so by casting the `Response` as below.
826 // Otherwise, remove this line. Only populated after
827 // first call to Next(). Not safe for concurrent access.
828 _ = it.Response.(*locationpb.ListLocationsResponse)
829 }
830 }