Debian Codegraph @

iam/apiv3/principal_access_boundary_policies_client_example_test.go

raw symbols SCIP
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 iam_test
18
19 import (
20 "context"
21
22 iam "cloud.google.com/go/iam/apiv3"
23 iampb "cloud.google.com/go/iam/apiv3/iampb"
24 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
25 "google.golang.org/api/iterator"
26 )
27
28 func ExampleNewPrincipalAccessBoundaryPoliciesClient() {
29 ctx := context.Background()
30 // This snippet has been automatically generated and should be regarded as a code template only.
31 // It will require modifications to work:
32 // - It may require correct/in-range values for request initialization.
33 // - It may require specifying regional endpoints when creating the service client as shown in:
34 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
35 c, err := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
36 if err != nil {
37 // TODO: Handle error.
38 }
39 defer c.Close()
40
41 // TODO: Use client.
42 _ = c
43 }
44
45 func ExampleNewPrincipalAccessBoundaryPoliciesRESTClient() {
46 ctx := context.Background()
47 // This snippet has been automatically generated and should be regarded as a code template only.
48 // It will require modifications to work:
49 // - It may require correct/in-range values for request initialization.
50 // - It may require specifying regional endpoints when creating the service client as shown in:
51 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
52 c, err := iam.NewPrincipalAccessBoundaryPoliciesRESTClient(ctx)
53 if err != nil {
54 // TODO: Handle error.
55 }
56 defer c.Close()
57
58 // TODO: Use client.
59 _ = c
60 }
61
62 func ExamplePrincipalAccessBoundaryPoliciesClient_CreatePrincipalAccessBoundaryPolicy() {
63 ctx := context.Background()
64 // This snippet has been automatically generated and should be regarded as a code template only.
65 // It will require modifications to work:
66 // - It may require correct/in-range values for request initialization.
67 // - It may require specifying regional endpoints when creating the service client as shown in:
68 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
69 c, err := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
70 if err != nil {
71 // TODO: Handle error.
72 }
73 defer c.Close()
74
75 req := &iampb.CreatePrincipalAccessBoundaryPolicyRequest{
76 // TODO: Fill request struct fields.
77 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#CreatePrincipalAccessBoundaryPolicyRequest.
78 }
79 op, err := c.CreatePrincipalAccessBoundaryPolicy(ctx, req)
80 if err != nil {
81 // TODO: Handle error.
82 }
83
84 resp, err := op.Wait(ctx)
85 if err != nil {
86 // TODO: Handle error.
87 }
88 // TODO: Use resp.
89 _ = resp
90 }
91
92 func ExamplePrincipalAccessBoundaryPoliciesClient_DeletePrincipalAccessBoundaryPolicy() {
93 ctx := context.Background()
94 // This snippet has been automatically generated and should be regarded as a code template only.
95 // It will require modifications to work:
96 // - It may require correct/in-range values for request initialization.
97 // - It may require specifying regional endpoints when creating the service client as shown in:
98 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
99 c, err := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
100 if err != nil {
101 // TODO: Handle error.
102 }
103 defer c.Close()
104
105 req := &iampb.DeletePrincipalAccessBoundaryPolicyRequest{
106 // TODO: Fill request struct fields.
107 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#DeletePrincipalAccessBoundaryPolicyRequest.
108 }
109 op, err := c.DeletePrincipalAccessBoundaryPolicy(ctx, req)
110 if err != nil {
111 // TODO: Handle error.
112 }
113
114 err = op.Wait(ctx)
115 if err != nil {
116 // TODO: Handle error.
117 }
118 }
119
120 func ExamplePrincipalAccessBoundaryPoliciesClient_GetPrincipalAccessBoundaryPolicy() {
121 ctx := context.Background()
122 // This snippet has been automatically generated and should be regarded as a code template only.
123 // It will require modifications to work:
124 // - It may require correct/in-range values for request initialization.
125 // - It may require specifying regional endpoints when creating the service client as shown in:
126 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
127 c, err := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
128 if err != nil {
129 // TODO: Handle error.
130 }
131 defer c.Close()
132
133 req := &iampb.GetPrincipalAccessBoundaryPolicyRequest{
134 // TODO: Fill request struct fields.
135 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#GetPrincipalAccessBoundaryPolicyRequest.
136 }
137 resp, err := c.GetPrincipalAccessBoundaryPolicy(ctx, req)
138 if err != nil {
139 // TODO: Handle error.
140 }
141 // TODO: Use resp.
142 _ = resp
143 }
144
145 func ExamplePrincipalAccessBoundaryPoliciesClient_ListPrincipalAccessBoundaryPolicies() {
146 ctx := context.Background()
147 // This snippet has been automatically generated and should be regarded as a code template only.
148 // It will require modifications to work:
149 // - It may require correct/in-range values for request initialization.
150 // - It may require specifying regional endpoints when creating the service client as shown in:
151 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
152 c, err := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
153 if err != nil {
154 // TODO: Handle error.
155 }
156 defer c.Close()
157
158 req := &iampb.ListPrincipalAccessBoundaryPoliciesRequest{
159 // TODO: Fill request struct fields.
160 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#ListPrincipalAccessBoundaryPoliciesRequest.
161 }
162 it := c.ListPrincipalAccessBoundaryPolicies(ctx, req)
163 for {
164 resp, err := it.Next()
165 if err == iterator.Done {
166 break
167 }
168 if err != nil {
169 // TODO: Handle error.
170 }
171 // TODO: Use resp.
172 _ = resp
173
174 // If you need to access the underlying RPC response,
175 // you can do so by casting the `Response` as below.
176 // Otherwise, remove this line. Only populated after
177 // first call to Next(). Not safe for concurrent access.
178 _ = it.Response.(*iampb.ListPrincipalAccessBoundaryPoliciesResponse)
179 }
180 }
181
182 func ExamplePrincipalAccessBoundaryPoliciesClient_SearchPrincipalAccessBoundaryPolicyBindings() {
183 ctx := context.Background()
184 // This snippet has been automatically generated and should be regarded as a code template only.
185 // It will require modifications to work:
186 // - It may require correct/in-range values for request initialization.
187 // - It may require specifying regional endpoints when creating the service client as shown in:
188 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
189 c, err := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
190 if err != nil {
191 // TODO: Handle error.
192 }
193 defer c.Close()
194
195 req := &iampb.SearchPrincipalAccessBoundaryPolicyBindingsRequest{
196 // TODO: Fill request struct fields.
197 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#SearchPrincipalAccessBoundaryPolicyBindingsRequest.
198 }
199 it := c.SearchPrincipalAccessBoundaryPolicyBindings(ctx, req)
200 for {
201 resp, err := it.Next()
202 if err == iterator.Done {
203 break
204 }
205 if err != nil {
206 // TODO: Handle error.
207 }
208 // TODO: Use resp.
209 _ = resp
210
211 // If you need to access the underlying RPC response,
212 // you can do so by casting the `Response` as below.
213 // Otherwise, remove this line. Only populated after
214 // first call to Next(). Not safe for concurrent access.
215 _ = it.Response.(*iampb.SearchPrincipalAccessBoundaryPolicyBindingsResponse)
216 }
217 }
218
219 func ExamplePrincipalAccessBoundaryPoliciesClient_UpdatePrincipalAccessBoundaryPolicy() {
220 ctx := context.Background()
221 // This snippet has been automatically generated and should be regarded as a code template only.
222 // It will require modifications to work:
223 // - It may require correct/in-range values for request initialization.
224 // - It may require specifying regional endpoints when creating the service client as shown in:
225 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
226 c, err := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
227 if err != nil {
228 // TODO: Handle error.
229 }
230 defer c.Close()
231
232 req := &iampb.UpdatePrincipalAccessBoundaryPolicyRequest{
233 // TODO: Fill request struct fields.
234 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv3/iampb#UpdatePrincipalAccessBoundaryPolicyRequest.
235 }
236 op, err := c.UpdatePrincipalAccessBoundaryPolicy(ctx, req)
237 if err != nil {
238 // TODO: Handle error.
239 }
240
241 resp, err := op.Wait(ctx)
242 if err != nil {
243 // TODO: Handle error.
244 }
245 // TODO: Use resp.
246 _ = resp
247 }
248
249 func ExamplePrincipalAccessBoundaryPoliciesClient_GetOperation() {
250 ctx := context.Background()
251 // This snippet has been automatically generated and should be regarded as a code template only.
252 // It will require modifications to work:
253 // - It may require correct/in-range values for request initialization.
254 // - It may require specifying regional endpoints when creating the service client as shown in:
255 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
256 c, err := iam.NewPrincipalAccessBoundaryPoliciesClient(ctx)
257 if err != nil {
258 // TODO: Handle error.
259 }
260 defer c.Close()
261
262 req := &longrunningpb.GetOperationRequest{
263 // TODO: Fill request struct fields.
264 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
265 }
266 resp, err := c.GetOperation(ctx, req)
267 if err != nil {
268 // TODO: Handle error.
269 }
270 // TODO: Use resp.
271 _ = resp
272 }