Debian Codegraph @

automl/apiv1/auto_ml_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 automl_test
18
19 import (
20 "context"
21
22 automl "cloud.google.com/go/automl/apiv1"
23 automlpb "cloud.google.com/go/automl/apiv1/automlpb"
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 := automl.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 := automl.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_CreateDataset() {
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 := automl.NewClient(ctx)
69 if err != nil {
70 // TODO: Handle error.
71 }
72 defer c.Close()
73
74 req := &automlpb.CreateDatasetRequest{
75 // TODO: Fill request struct fields.
76 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#CreateDatasetRequest.
77 }
78 op, err := c.CreateDataset(ctx, req)
79 if err != nil {
80 // TODO: Handle error.
81 }
82
83 resp, err := op.Wait(ctx)
84 if err != nil {
85 // TODO: Handle error.
86 }
87 // TODO: Use resp.
88 _ = resp
89 }
90
91 func ExampleClient_CreateModel() {
92 ctx := context.Background()
93 // This snippet has been automatically generated and should be regarded as a code template only.
94 // It will require modifications to work:
95 // - It may require correct/in-range values for request initialization.
96 // - It may require specifying regional endpoints when creating the service client as shown in:
97 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
98 c, err := automl.NewClient(ctx)
99 if err != nil {
100 // TODO: Handle error.
101 }
102 defer c.Close()
103
104 req := &automlpb.CreateModelRequest{
105 // TODO: Fill request struct fields.
106 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#CreateModelRequest.
107 }
108 op, err := c.CreateModel(ctx, req)
109 if err != nil {
110 // TODO: Handle error.
111 }
112
113 resp, err := op.Wait(ctx)
114 if err != nil {
115 // TODO: Handle error.
116 }
117 // TODO: Use resp.
118 _ = resp
119 }
120
121 func ExampleClient_DeleteDataset() {
122 ctx := context.Background()
123 // This snippet has been automatically generated and should be regarded as a code template only.
124 // It will require modifications to work:
125 // - It may require correct/in-range values for request initialization.
126 // - It may require specifying regional endpoints when creating the service client as shown in:
127 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
128 c, err := automl.NewClient(ctx)
129 if err != nil {
130 // TODO: Handle error.
131 }
132 defer c.Close()
133
134 req := &automlpb.DeleteDatasetRequest{
135 // TODO: Fill request struct fields.
136 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#DeleteDatasetRequest.
137 }
138 op, err := c.DeleteDataset(ctx, req)
139 if err != nil {
140 // TODO: Handle error.
141 }
142
143 err = op.Wait(ctx)
144 if err != nil {
145 // TODO: Handle error.
146 }
147 }
148
149 func ExampleClient_DeleteModel() {
150 ctx := context.Background()
151 // This snippet has been automatically generated and should be regarded as a code template only.
152 // It will require modifications to work:
153 // - It may require correct/in-range values for request initialization.
154 // - It may require specifying regional endpoints when creating the service client as shown in:
155 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
156 c, err := automl.NewClient(ctx)
157 if err != nil {
158 // TODO: Handle error.
159 }
160 defer c.Close()
161
162 req := &automlpb.DeleteModelRequest{
163 // TODO: Fill request struct fields.
164 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#DeleteModelRequest.
165 }
166 op, err := c.DeleteModel(ctx, req)
167 if err != nil {
168 // TODO: Handle error.
169 }
170
171 err = op.Wait(ctx)
172 if err != nil {
173 // TODO: Handle error.
174 }
175 }
176
177 func ExampleClient_DeployModel() {
178 ctx := context.Background()
179 // This snippet has been automatically generated and should be regarded as a code template only.
180 // It will require modifications to work:
181 // - It may require correct/in-range values for request initialization.
182 // - It may require specifying regional endpoints when creating the service client as shown in:
183 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
184 c, err := automl.NewClient(ctx)
185 if err != nil {
186 // TODO: Handle error.
187 }
188 defer c.Close()
189
190 req := &automlpb.DeployModelRequest{
191 // TODO: Fill request struct fields.
192 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#DeployModelRequest.
193 }
194 op, err := c.DeployModel(ctx, req)
195 if err != nil {
196 // TODO: Handle error.
197 }
198
199 err = op.Wait(ctx)
200 if err != nil {
201 // TODO: Handle error.
202 }
203 }
204
205 func ExampleClient_ExportData() {
206 ctx := context.Background()
207 // This snippet has been automatically generated and should be regarded as a code template only.
208 // It will require modifications to work:
209 // - It may require correct/in-range values for request initialization.
210 // - It may require specifying regional endpoints when creating the service client as shown in:
211 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
212 c, err := automl.NewClient(ctx)
213 if err != nil {
214 // TODO: Handle error.
215 }
216 defer c.Close()
217
218 req := &automlpb.ExportDataRequest{
219 // TODO: Fill request struct fields.
220 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#ExportDataRequest.
221 }
222 op, err := c.ExportData(ctx, req)
223 if err != nil {
224 // TODO: Handle error.
225 }
226
227 err = op.Wait(ctx)
228 if err != nil {
229 // TODO: Handle error.
230 }
231 }
232
233 func ExampleClient_ExportModel() {
234 ctx := context.Background()
235 // This snippet has been automatically generated and should be regarded as a code template only.
236 // It will require modifications to work:
237 // - It may require correct/in-range values for request initialization.
238 // - It may require specifying regional endpoints when creating the service client as shown in:
239 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
240 c, err := automl.NewClient(ctx)
241 if err != nil {
242 // TODO: Handle error.
243 }
244 defer c.Close()
245
246 req := &automlpb.ExportModelRequest{
247 // TODO: Fill request struct fields.
248 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#ExportModelRequest.
249 }
250 op, err := c.ExportModel(ctx, req)
251 if err != nil {
252 // TODO: Handle error.
253 }
254
255 err = op.Wait(ctx)
256 if err != nil {
257 // TODO: Handle error.
258 }
259 }
260
261 func ExampleClient_GetAnnotationSpec() {
262 ctx := context.Background()
263 // This snippet has been automatically generated and should be regarded as a code template only.
264 // It will require modifications to work:
265 // - It may require correct/in-range values for request initialization.
266 // - It may require specifying regional endpoints when creating the service client as shown in:
267 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
268 c, err := automl.NewClient(ctx)
269 if err != nil {
270 // TODO: Handle error.
271 }
272 defer c.Close()
273
274 req := &automlpb.GetAnnotationSpecRequest{
275 // TODO: Fill request struct fields.
276 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#GetAnnotationSpecRequest.
277 }
278 resp, err := c.GetAnnotationSpec(ctx, req)
279 if err != nil {
280 // TODO: Handle error.
281 }
282 // TODO: Use resp.
283 _ = resp
284 }
285
286 func ExampleClient_GetDataset() {
287 ctx := context.Background()
288 // This snippet has been automatically generated and should be regarded as a code template only.
289 // It will require modifications to work:
290 // - It may require correct/in-range values for request initialization.
291 // - It may require specifying regional endpoints when creating the service client as shown in:
292 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
293 c, err := automl.NewClient(ctx)
294 if err != nil {
295 // TODO: Handle error.
296 }
297 defer c.Close()
298
299 req := &automlpb.GetDatasetRequest{
300 // TODO: Fill request struct fields.
301 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#GetDatasetRequest.
302 }
303 resp, err := c.GetDataset(ctx, req)
304 if err != nil {
305 // TODO: Handle error.
306 }
307 // TODO: Use resp.
308 _ = resp
309 }
310
311 func ExampleClient_GetModel() {
312 ctx := context.Background()
313 // This snippet has been automatically generated and should be regarded as a code template only.
314 // It will require modifications to work:
315 // - It may require correct/in-range values for request initialization.
316 // - It may require specifying regional endpoints when creating the service client as shown in:
317 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
318 c, err := automl.NewClient(ctx)
319 if err != nil {
320 // TODO: Handle error.
321 }
322 defer c.Close()
323
324 req := &automlpb.GetModelRequest{
325 // TODO: Fill request struct fields.
326 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#GetModelRequest.
327 }
328 resp, err := c.GetModel(ctx, req)
329 if err != nil {
330 // TODO: Handle error.
331 }
332 // TODO: Use resp.
333 _ = resp
334 }
335
336 func ExampleClient_GetModelEvaluation() {
337 ctx := context.Background()
338 // This snippet has been automatically generated and should be regarded as a code template only.
339 // It will require modifications to work:
340 // - It may require correct/in-range values for request initialization.
341 // - It may require specifying regional endpoints when creating the service client as shown in:
342 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
343 c, err := automl.NewClient(ctx)
344 if err != nil {
345 // TODO: Handle error.
346 }
347 defer c.Close()
348
349 req := &automlpb.GetModelEvaluationRequest{
350 // TODO: Fill request struct fields.
351 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#GetModelEvaluationRequest.
352 }
353 resp, err := c.GetModelEvaluation(ctx, req)
354 if err != nil {
355 // TODO: Handle error.
356 }
357 // TODO: Use resp.
358 _ = resp
359 }
360
361 func ExampleClient_ImportData() {
362 ctx := context.Background()
363 // This snippet has been automatically generated and should be regarded as a code template only.
364 // It will require modifications to work:
365 // - It may require correct/in-range values for request initialization.
366 // - It may require specifying regional endpoints when creating the service client as shown in:
367 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
368 c, err := automl.NewClient(ctx)
369 if err != nil {
370 // TODO: Handle error.
371 }
372 defer c.Close()
373
374 req := &automlpb.ImportDataRequest{
375 // TODO: Fill request struct fields.
376 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#ImportDataRequest.
377 }
378 op, err := c.ImportData(ctx, req)
379 if err != nil {
380 // TODO: Handle error.
381 }
382
383 err = op.Wait(ctx)
384 if err != nil {
385 // TODO: Handle error.
386 }
387 }
388
389 func ExampleClient_ListDatasets() {
390 ctx := context.Background()
391 // This snippet has been automatically generated and should be regarded as a code template only.
392 // It will require modifications to work:
393 // - It may require correct/in-range values for request initialization.
394 // - It may require specifying regional endpoints when creating the service client as shown in:
395 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
396 c, err := automl.NewClient(ctx)
397 if err != nil {
398 // TODO: Handle error.
399 }
400 defer c.Close()
401
402 req := &automlpb.ListDatasetsRequest{
403 // TODO: Fill request struct fields.
404 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#ListDatasetsRequest.
405 }
406 it := c.ListDatasets(ctx, req)
407 for {
408 resp, err := it.Next()
409 if err == iterator.Done {
410 break
411 }
412 if err != nil {
413 // TODO: Handle error.
414 }
415 // TODO: Use resp.
416 _ = resp
417
418 // If you need to access the underlying RPC response,
419 // you can do so by casting the `Response` as below.
420 // Otherwise, remove this line. Only populated after
421 // first call to Next(). Not safe for concurrent access.
422 _ = it.Response.(*automlpb.ListDatasetsResponse)
423 }
424 }
425
426 func ExampleClient_ListModelEvaluations() {
427 ctx := context.Background()
428 // This snippet has been automatically generated and should be regarded as a code template only.
429 // It will require modifications to work:
430 // - It may require correct/in-range values for request initialization.
431 // - It may require specifying regional endpoints when creating the service client as shown in:
432 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
433 c, err := automl.NewClient(ctx)
434 if err != nil {
435 // TODO: Handle error.
436 }
437 defer c.Close()
438
439 req := &automlpb.ListModelEvaluationsRequest{
440 // TODO: Fill request struct fields.
441 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#ListModelEvaluationsRequest.
442 }
443 it := c.ListModelEvaluations(ctx, req)
444 for {
445 resp, err := it.Next()
446 if err == iterator.Done {
447 break
448 }
449 if err != nil {
450 // TODO: Handle error.
451 }
452 // TODO: Use resp.
453 _ = resp
454
455 // If you need to access the underlying RPC response,
456 // you can do so by casting the `Response` as below.
457 // Otherwise, remove this line. Only populated after
458 // first call to Next(). Not safe for concurrent access.
459 _ = it.Response.(*automlpb.ListModelEvaluationsResponse)
460 }
461 }
462
463 func ExampleClient_ListModels() {
464 ctx := context.Background()
465 // This snippet has been automatically generated and should be regarded as a code template only.
466 // It will require modifications to work:
467 // - It may require correct/in-range values for request initialization.
468 // - It may require specifying regional endpoints when creating the service client as shown in:
469 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
470 c, err := automl.NewClient(ctx)
471 if err != nil {
472 // TODO: Handle error.
473 }
474 defer c.Close()
475
476 req := &automlpb.ListModelsRequest{
477 // TODO: Fill request struct fields.
478 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#ListModelsRequest.
479 }
480 it := c.ListModels(ctx, req)
481 for {
482 resp, err := it.Next()
483 if err == iterator.Done {
484 break
485 }
486 if err != nil {
487 // TODO: Handle error.
488 }
489 // TODO: Use resp.
490 _ = resp
491
492 // If you need to access the underlying RPC response,
493 // you can do so by casting the `Response` as below.
494 // Otherwise, remove this line. Only populated after
495 // first call to Next(). Not safe for concurrent access.
496 _ = it.Response.(*automlpb.ListModelsResponse)
497 }
498 }
499
500 func ExampleClient_UndeployModel() {
501 ctx := context.Background()
502 // This snippet has been automatically generated and should be regarded as a code template only.
503 // It will require modifications to work:
504 // - It may require correct/in-range values for request initialization.
505 // - It may require specifying regional endpoints when creating the service client as shown in:
506 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
507 c, err := automl.NewClient(ctx)
508 if err != nil {
509 // TODO: Handle error.
510 }
511 defer c.Close()
512
513 req := &automlpb.UndeployModelRequest{
514 // TODO: Fill request struct fields.
515 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#UndeployModelRequest.
516 }
517 op, err := c.UndeployModel(ctx, req)
518 if err != nil {
519 // TODO: Handle error.
520 }
521
522 err = op.Wait(ctx)
523 if err != nil {
524 // TODO: Handle error.
525 }
526 }
527
528 func ExampleClient_UpdateDataset() {
529 ctx := context.Background()
530 // This snippet has been automatically generated and should be regarded as a code template only.
531 // It will require modifications to work:
532 // - It may require correct/in-range values for request initialization.
533 // - It may require specifying regional endpoints when creating the service client as shown in:
534 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
535 c, err := automl.NewClient(ctx)
536 if err != nil {
537 // TODO: Handle error.
538 }
539 defer c.Close()
540
541 req := &automlpb.UpdateDatasetRequest{
542 // TODO: Fill request struct fields.
543 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#UpdateDatasetRequest.
544 }
545 resp, err := c.UpdateDataset(ctx, req)
546 if err != nil {
547 // TODO: Handle error.
548 }
549 // TODO: Use resp.
550 _ = resp
551 }
552
553 func ExampleClient_UpdateModel() {
554 ctx := context.Background()
555 // This snippet has been automatically generated and should be regarded as a code template only.
556 // It will require modifications to work:
557 // - It may require correct/in-range values for request initialization.
558 // - It may require specifying regional endpoints when creating the service client as shown in:
559 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
560 c, err := automl.NewClient(ctx)
561 if err != nil {
562 // TODO: Handle error.
563 }
564 defer c.Close()
565
566 req := &automlpb.UpdateModelRequest{
567 // TODO: Fill request struct fields.
568 // See https://pkg.go.dev/cloud.google.com/go/automl/apiv1/automlpb#UpdateModelRequest.
569 }
570 resp, err := c.UpdateModel(ctx, req)
571 if err != nil {
572 // TODO: Handle error.
573 }
574 // TODO: Use resp.
575 _ = resp
576 }