Debian Codegraph @

area120/tables/apiv1alpha1/tables_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 tables_test
18
19 import (
20 "context"
21
22 tables "cloud.google.com/go/area120/tables/apiv1alpha1"
23 tablespb "cloud.google.com/go/area120/tables/apiv1alpha1/tablespb"
24 "google.golang.org/api/iterator"
25 )
26
27 func ExampleNewClient() {
28 ctx := context.Background()
29 // This snippet has been automatically generated and should be regarded as a code template only.
30 // It will require modifications to work:
31 // - It may require correct/in-range values for request initialization.
32 // - It may require specifying regional endpoints when creating the service client as shown in:
33 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
34 c, err := tables.NewClient(ctx)
35 if err != nil {
36 // TODO: Handle error.
37 }
38 defer c.Close()
39
40 // TODO: Use client.
41 _ = c
42 }
43
44 func ExampleNewRESTClient() {
45 ctx := context.Background()
46 // This snippet has been automatically generated and should be regarded as a code template only.
47 // It will require modifications to work:
48 // - It may require correct/in-range values for request initialization.
49 // - It may require specifying regional endpoints when creating the service client as shown in:
50 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
51 c, err := tables.NewRESTClient(ctx)
52 if err != nil {
53 // TODO: Handle error.
54 }
55 defer c.Close()
56
57 // TODO: Use client.
58 _ = c
59 }
60
61 func ExampleClient_BatchCreateRows() {
62 ctx := context.Background()
63 // This snippet has been automatically generated and should be regarded as a code template only.
64 // It will require modifications to work:
65 // - It may require correct/in-range values for request initialization.
66 // - It may require specifying regional endpoints when creating the service client as shown in:
67 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
68 c, err := tables.NewClient(ctx)
69 if err != nil {
70 // TODO: Handle error.
71 }
72 defer c.Close()
73
74 req := &tablespb.BatchCreateRowsRequest{
75 // TODO: Fill request struct fields.
76 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#BatchCreateRowsRequest.
77 }
78 resp, err := c.BatchCreateRows(ctx, req)
79 if err != nil {
80 // TODO: Handle error.
81 }
82 // TODO: Use resp.
83 _ = resp
84 }
85
86 func ExampleClient_BatchDeleteRows() {
87 ctx := context.Background()
88 // This snippet has been automatically generated and should be regarded as a code template only.
89 // It will require modifications to work:
90 // - It may require correct/in-range values for request initialization.
91 // - It may require specifying regional endpoints when creating the service client as shown in:
92 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
93 c, err := tables.NewClient(ctx)
94 if err != nil {
95 // TODO: Handle error.
96 }
97 defer c.Close()
98
99 req := &tablespb.BatchDeleteRowsRequest{
100 // TODO: Fill request struct fields.
101 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#BatchDeleteRowsRequest.
102 }
103 err = c.BatchDeleteRows(ctx, req)
104 if err != nil {
105 // TODO: Handle error.
106 }
107 }
108
109 func ExampleClient_BatchUpdateRows() {
110 ctx := context.Background()
111 // This snippet has been automatically generated and should be regarded as a code template only.
112 // It will require modifications to work:
113 // - It may require correct/in-range values for request initialization.
114 // - It may require specifying regional endpoints when creating the service client as shown in:
115 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
116 c, err := tables.NewClient(ctx)
117 if err != nil {
118 // TODO: Handle error.
119 }
120 defer c.Close()
121
122 req := &tablespb.BatchUpdateRowsRequest{
123 // TODO: Fill request struct fields.
124 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#BatchUpdateRowsRequest.
125 }
126 resp, err := c.BatchUpdateRows(ctx, req)
127 if err != nil {
128 // TODO: Handle error.
129 }
130 // TODO: Use resp.
131 _ = resp
132 }
133
134 func ExampleClient_CreateRow() {
135 ctx := context.Background()
136 // This snippet has been automatically generated and should be regarded as a code template only.
137 // It will require modifications to work:
138 // - It may require correct/in-range values for request initialization.
139 // - It may require specifying regional endpoints when creating the service client as shown in:
140 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
141 c, err := tables.NewClient(ctx)
142 if err != nil {
143 // TODO: Handle error.
144 }
145 defer c.Close()
146
147 req := &tablespb.CreateRowRequest{
148 // TODO: Fill request struct fields.
149 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#CreateRowRequest.
150 }
151 resp, err := c.CreateRow(ctx, req)
152 if err != nil {
153 // TODO: Handle error.
154 }
155 // TODO: Use resp.
156 _ = resp
157 }
158
159 func ExampleClient_DeleteRow() {
160 ctx := context.Background()
161 // This snippet has been automatically generated and should be regarded as a code template only.
162 // It will require modifications to work:
163 // - It may require correct/in-range values for request initialization.
164 // - It may require specifying regional endpoints when creating the service client as shown in:
165 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
166 c, err := tables.NewClient(ctx)
167 if err != nil {
168 // TODO: Handle error.
169 }
170 defer c.Close()
171
172 req := &tablespb.DeleteRowRequest{
173 // TODO: Fill request struct fields.
174 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#DeleteRowRequest.
175 }
176 err = c.DeleteRow(ctx, req)
177 if err != nil {
178 // TODO: Handle error.
179 }
180 }
181
182 func ExampleClient_GetRow() {
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 := tables.NewClient(ctx)
190 if err != nil {
191 // TODO: Handle error.
192 }
193 defer c.Close()
194
195 req := &tablespb.GetRowRequest{
196 // TODO: Fill request struct fields.
197 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#GetRowRequest.
198 }
199 resp, err := c.GetRow(ctx, req)
200 if err != nil {
201 // TODO: Handle error.
202 }
203 // TODO: Use resp.
204 _ = resp
205 }
206
207 func ExampleClient_GetTable() {
208 ctx := context.Background()
209 // This snippet has been automatically generated and should be regarded as a code template only.
210 // It will require modifications to work:
211 // - It may require correct/in-range values for request initialization.
212 // - It may require specifying regional endpoints when creating the service client as shown in:
213 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
214 c, err := tables.NewClient(ctx)
215 if err != nil {
216 // TODO: Handle error.
217 }
218 defer c.Close()
219
220 req := &tablespb.GetTableRequest{
221 // TODO: Fill request struct fields.
222 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#GetTableRequest.
223 }
224 resp, err := c.GetTable(ctx, req)
225 if err != nil {
226 // TODO: Handle error.
227 }
228 // TODO: Use resp.
229 _ = resp
230 }
231
232 func ExampleClient_GetWorkspace() {
233 ctx := context.Background()
234 // This snippet has been automatically generated and should be regarded as a code template only.
235 // It will require modifications to work:
236 // - It may require correct/in-range values for request initialization.
237 // - It may require specifying regional endpoints when creating the service client as shown in:
238 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
239 c, err := tables.NewClient(ctx)
240 if err != nil {
241 // TODO: Handle error.
242 }
243 defer c.Close()
244
245 req := &tablespb.GetWorkspaceRequest{
246 // TODO: Fill request struct fields.
247 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#GetWorkspaceRequest.
248 }
249 resp, err := c.GetWorkspace(ctx, req)
250 if err != nil {
251 // TODO: Handle error.
252 }
253 // TODO: Use resp.
254 _ = resp
255 }
256
257 func ExampleClient_ListRows() {
258 ctx := context.Background()
259 // This snippet has been automatically generated and should be regarded as a code template only.
260 // It will require modifications to work:
261 // - It may require correct/in-range values for request initialization.
262 // - It may require specifying regional endpoints when creating the service client as shown in:
263 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
264 c, err := tables.NewClient(ctx)
265 if err != nil {
266 // TODO: Handle error.
267 }
268 defer c.Close()
269
270 req := &tablespb.ListRowsRequest{
271 // TODO: Fill request struct fields.
272 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#ListRowsRequest.
273 }
274 it := c.ListRows(ctx, req)
275 for {
276 resp, err := it.Next()
277 if err == iterator.Done {
278 break
279 }
280 if err != nil {
281 // TODO: Handle error.
282 }
283 // TODO: Use resp.
284 _ = resp
285
286 // If you need to access the underlying RPC response,
287 // you can do so by casting the `Response` as below.
288 // Otherwise, remove this line. Only populated after
289 // first call to Next(). Not safe for concurrent access.
290 _ = it.Response.(*tablespb.ListRowsResponse)
291 }
292 }
293
294 func ExampleClient_ListTables() {
295 ctx := context.Background()
296 // This snippet has been automatically generated and should be regarded as a code template only.
297 // It will require modifications to work:
298 // - It may require correct/in-range values for request initialization.
299 // - It may require specifying regional endpoints when creating the service client as shown in:
300 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
301 c, err := tables.NewClient(ctx)
302 if err != nil {
303 // TODO: Handle error.
304 }
305 defer c.Close()
306
307 req := &tablespb.ListTablesRequest{
308 // TODO: Fill request struct fields.
309 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#ListTablesRequest.
310 }
311 it := c.ListTables(ctx, req)
312 for {
313 resp, err := it.Next()
314 if err == iterator.Done {
315 break
316 }
317 if err != nil {
318 // TODO: Handle error.
319 }
320 // TODO: Use resp.
321 _ = resp
322
323 // If you need to access the underlying RPC response,
324 // you can do so by casting the `Response` as below.
325 // Otherwise, remove this line. Only populated after
326 // first call to Next(). Not safe for concurrent access.
327 _ = it.Response.(*tablespb.ListTablesResponse)
328 }
329 }
330
331 func ExampleClient_ListWorkspaces() {
332 ctx := context.Background()
333 // This snippet has been automatically generated and should be regarded as a code template only.
334 // It will require modifications to work:
335 // - It may require correct/in-range values for request initialization.
336 // - It may require specifying regional endpoints when creating the service client as shown in:
337 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
338 c, err := tables.NewClient(ctx)
339 if err != nil {
340 // TODO: Handle error.
341 }
342 defer c.Close()
343
344 req := &tablespb.ListWorkspacesRequest{
345 // TODO: Fill request struct fields.
346 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#ListWorkspacesRequest.
347 }
348 it := c.ListWorkspaces(ctx, req)
349 for {
350 resp, err := it.Next()
351 if err == iterator.Done {
352 break
353 }
354 if err != nil {
355 // TODO: Handle error.
356 }
357 // TODO: Use resp.
358 _ = resp
359
360 // If you need to access the underlying RPC response,
361 // you can do so by casting the `Response` as below.
362 // Otherwise, remove this line. Only populated after
363 // first call to Next(). Not safe for concurrent access.
364 _ = it.Response.(*tablespb.ListWorkspacesResponse)
365 }
366 }
367
368 func ExampleClient_UpdateRow() {
369 ctx := context.Background()
370 // This snippet has been automatically generated and should be regarded as a code template only.
371 // It will require modifications to work:
372 // - It may require correct/in-range values for request initialization.
373 // - It may require specifying regional endpoints when creating the service client as shown in:
374 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
375 c, err := tables.NewClient(ctx)
376 if err != nil {
377 // TODO: Handle error.
378 }
379 defer c.Close()
380
381 req := &tablespb.UpdateRowRequest{
382 // TODO: Fill request struct fields.
383 // See https://pkg.go.dev/cloud.google.com/go/area120/tables/apiv1alpha1/tablespb#UpdateRowRequest.
384 }
385 resp, err := c.UpdateRow(ctx, req)
386 if err != nil {
387 // TODO: Handle error.
388 }
389 // TODO: Use resp.
390 _ = resp
391 }