Debian Codegraph @

policysimulator/apiv1/org_policy_violations_preview_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 policysimulator_test
18
19 import (
20 "context"
21
22 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
23 policysimulator "cloud.google.com/go/policysimulator/apiv1"
24 policysimulatorpb "cloud.google.com/go/policysimulator/apiv1/policysimulatorpb"
25 "google.golang.org/api/iterator"
26 )
27
28 func ExampleNewOrgPolicyViolationsPreviewClient() {
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 := policysimulator.NewOrgPolicyViolationsPreviewClient(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 ExampleNewOrgPolicyViolationsPreviewRESTClient() {
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 := policysimulator.NewOrgPolicyViolationsPreviewRESTClient(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 ExampleOrgPolicyViolationsPreviewClient_CreateOrgPolicyViolationsPreview() {
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 := policysimulator.NewOrgPolicyViolationsPreviewClient(ctx)
70 if err != nil {
71 // TODO: Handle error.
72 }
73 defer c.Close()
74
75 req := &policysimulatorpb.CreateOrgPolicyViolationsPreviewRequest{
76 // TODO: Fill request struct fields.
77 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#CreateOrgPolicyViolationsPreviewRequest.
78 }
79 op, err := c.CreateOrgPolicyViolationsPreview(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 ExampleOrgPolicyViolationsPreviewClient_GetOrgPolicyViolationsPreview() {
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 := policysimulator.NewOrgPolicyViolationsPreviewClient(ctx)
100 if err != nil {
101 // TODO: Handle error.
102 }
103 defer c.Close()
104
105 req := &policysimulatorpb.GetOrgPolicyViolationsPreviewRequest{
106 // TODO: Fill request struct fields.
107 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#GetOrgPolicyViolationsPreviewRequest.
108 }
109 resp, err := c.GetOrgPolicyViolationsPreview(ctx, req)
110 if err != nil {
111 // TODO: Handle error.
112 }
113 // TODO: Use resp.
114 _ = resp
115 }
116
117 func ExampleOrgPolicyViolationsPreviewClient_ListOrgPolicyViolations() {
118 ctx := context.Background()
119 // This snippet has been automatically generated and should be regarded as a code template only.
120 // It will require modifications to work:
121 // - It may require correct/in-range values for request initialization.
122 // - It may require specifying regional endpoints when creating the service client as shown in:
123 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
124 c, err := policysimulator.NewOrgPolicyViolationsPreviewClient(ctx)
125 if err != nil {
126 // TODO: Handle error.
127 }
128 defer c.Close()
129
130 req := &policysimulatorpb.ListOrgPolicyViolationsRequest{
131 // TODO: Fill request struct fields.
132 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#ListOrgPolicyViolationsRequest.
133 }
134 it := c.ListOrgPolicyViolations(ctx, req)
135 for {
136 resp, err := it.Next()
137 if err == iterator.Done {
138 break
139 }
140 if err != nil {
141 // TODO: Handle error.
142 }
143 // TODO: Use resp.
144 _ = resp
145
146 // If you need to access the underlying RPC response,
147 // you can do so by casting the `Response` as below.
148 // Otherwise, remove this line. Only populated after
149 // first call to Next(). Not safe for concurrent access.
150 _ = it.Response.(*policysimulatorpb.ListOrgPolicyViolationsResponse)
151 }
152 }
153
154 func ExampleOrgPolicyViolationsPreviewClient_ListOrgPolicyViolationsPreviews() {
155 ctx := context.Background()
156 // This snippet has been automatically generated and should be regarded as a code template only.
157 // It will require modifications to work:
158 // - It may require correct/in-range values for request initialization.
159 // - It may require specifying regional endpoints when creating the service client as shown in:
160 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
161 c, err := policysimulator.NewOrgPolicyViolationsPreviewClient(ctx)
162 if err != nil {
163 // TODO: Handle error.
164 }
165 defer c.Close()
166
167 req := &policysimulatorpb.ListOrgPolicyViolationsPreviewsRequest{
168 // TODO: Fill request struct fields.
169 // See https://pkg.go.dev/cloud.google.com/go/policysimulator/apiv1/policysimulatorpb#ListOrgPolicyViolationsPreviewsRequest.
170 }
171 it := c.ListOrgPolicyViolationsPreviews(ctx, req)
172 for {
173 resp, err := it.Next()
174 if err == iterator.Done {
175 break
176 }
177 if err != nil {
178 // TODO: Handle error.
179 }
180 // TODO: Use resp.
181 _ = resp
182
183 // If you need to access the underlying RPC response,
184 // you can do so by casting the `Response` as below.
185 // Otherwise, remove this line. Only populated after
186 // first call to Next(). Not safe for concurrent access.
187 _ = it.Response.(*policysimulatorpb.ListOrgPolicyViolationsPreviewsResponse)
188 }
189 }
190
191 func ExampleOrgPolicyViolationsPreviewClient_GetOperation() {
192 ctx := context.Background()
193 // This snippet has been automatically generated and should be regarded as a code template only.
194 // It will require modifications to work:
195 // - It may require correct/in-range values for request initialization.
196 // - It may require specifying regional endpoints when creating the service client as shown in:
197 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
198 c, err := policysimulator.NewOrgPolicyViolationsPreviewClient(ctx)
199 if err != nil {
200 // TODO: Handle error.
201 }
202 defer c.Close()
203
204 req := &longrunningpb.GetOperationRequest{
205 // TODO: Fill request struct fields.
206 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
207 }
208 resp, err := c.GetOperation(ctx, req)
209 if err != nil {
210 // TODO: Handle error.
211 }
212 // TODO: Use resp.
213 _ = resp
214 }
215
216 func ExampleOrgPolicyViolationsPreviewClient_ListOperations() {
217 ctx := context.Background()
218 // This snippet has been automatically generated and should be regarded as a code template only.
219 // It will require modifications to work:
220 // - It may require correct/in-range values for request initialization.
221 // - It may require specifying regional endpoints when creating the service client as shown in:
222 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
223 c, err := policysimulator.NewOrgPolicyViolationsPreviewClient(ctx)
224 if err != nil {
225 // TODO: Handle error.
226 }
227 defer c.Close()
228
229 req := &longrunningpb.ListOperationsRequest{
230 // TODO: Fill request struct fields.
231 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
232 }
233 it := c.ListOperations(ctx, req)
234 for {
235 resp, err := it.Next()
236 if err == iterator.Done {
237 break
238 }
239 if err != nil {
240 // TODO: Handle error.
241 }
242 // TODO: Use resp.
243 _ = resp
244
245 // If you need to access the underlying RPC response,
246 // you can do so by casting the `Response` as below.
247 // Otherwise, remove this line. Only populated after
248 // first call to Next(). Not safe for concurrent access.
249 _ = it.Response.(*longrunningpb.ListOperationsResponse)
250 }
251 }