Debian Codegraph @

automl/apiv1beta1/auto_ml_client.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
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 automlpb "cloud.google.com/go/automl/apiv1beta1/automlpb"
30 "cloud.google.com/go/longrunning"
31 lroauto "cloud.google.com/go/longrunning/autogen"
32 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
33 gax "github.com/googleapis/gax-go/v2"
34 "google.golang.org/api/iterator"
35 "google.golang.org/api/option"
36 "google.golang.org/api/option/internaloption"
37 gtransport "google.golang.org/api/transport/grpc"
38 httptransport "google.golang.org/api/transport/http"
39 "google.golang.org/grpc"
40 "google.golang.org/grpc/codes"
41 "google.golang.org/protobuf/encoding/protojson"
42 "google.golang.org/protobuf/proto"
43 )
44
45 var newClientHook clientHook
46
47 // CallOptions contains the retry settings for each method of Client.
48 type CallOptions struct {
49 CreateDataset []gax.CallOption
50 GetDataset []gax.CallOption
51 ListDatasets []gax.CallOption
52 UpdateDataset []gax.CallOption
53 DeleteDataset []gax.CallOption
54 ImportData []gax.CallOption
55 ExportData []gax.CallOption
56 GetAnnotationSpec []gax.CallOption
57 GetTableSpec []gax.CallOption
58 ListTableSpecs []gax.CallOption
59 UpdateTableSpec []gax.CallOption
60 GetColumnSpec []gax.CallOption
61 ListColumnSpecs []gax.CallOption
62 UpdateColumnSpec []gax.CallOption
63 CreateModel []gax.CallOption
64 GetModel []gax.CallOption
65 ListModels []gax.CallOption
66 DeleteModel []gax.CallOption
67 DeployModel []gax.CallOption
68 UndeployModel []gax.CallOption
69 ExportModel []gax.CallOption
70 ExportEvaluatedExamples []gax.CallOption
71 GetModelEvaluation []gax.CallOption
72 ListModelEvaluations []gax.CallOption
73 }
74
75 func defaultGRPCClientOptions() []option.ClientOption {
76 return []option.ClientOption{
77 internaloption.WithDefaultEndpoint("automl.googleapis.com:443"),
78 internaloption.WithDefaultEndpointTemplate("automl.UNIVERSE_DOMAIN:443"),
79 internaloption.WithDefaultMTLSEndpoint("automl.mtls.googleapis.com:443"),
80 internaloption.WithDefaultUniverseDomain("googleapis.com"),
81 internaloption.WithDefaultAudience("https://automl.googleapis.com/"),
82 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
83 internaloption.EnableJwtWithScope(),
84 internaloption.EnableNewAuthLibrary(),
85 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
86 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
87 }
88 }
89
90 func defaultCallOptions() *CallOptions {
91 return &CallOptions{
92 CreateDataset: []gax.CallOption{
93 gax.WithTimeout(5000 * time.Millisecond),
94 },
95 GetDataset: []gax.CallOption{
96 gax.WithTimeout(5000 * time.Millisecond),
97 gax.WithRetry(func() gax.Retryer {
98 return gax.OnCodes([]codes.Code{
99 codes.Unavailable,
100 codes.DeadlineExceeded,
101 }, gax.Backoff{
102 Initial: 100 * time.Millisecond,
103 Max: 60000 * time.Millisecond,
104 Multiplier: 1.30,
105 })
106 }),
107 },
108 ListDatasets: []gax.CallOption{
109 gax.WithTimeout(5000 * time.Millisecond),
110 gax.WithRetry(func() gax.Retryer {
111 return gax.OnCodes([]codes.Code{
112 codes.Unavailable,
113 codes.DeadlineExceeded,
114 }, gax.Backoff{
115 Initial: 100 * time.Millisecond,
116 Max: 60000 * time.Millisecond,
117 Multiplier: 1.30,
118 })
119 }),
120 },
121 UpdateDataset: []gax.CallOption{
122 gax.WithTimeout(5000 * time.Millisecond),
123 },
124 DeleteDataset: []gax.CallOption{
125 gax.WithTimeout(5000 * time.Millisecond),
126 gax.WithRetry(func() gax.Retryer {
127 return gax.OnCodes([]codes.Code{
128 codes.Unavailable,
129 codes.DeadlineExceeded,
130 }, gax.Backoff{
131 Initial: 100 * time.Millisecond,
132 Max: 60000 * time.Millisecond,
133 Multiplier: 1.30,
134 })
135 }),
136 },
137 ImportData: []gax.CallOption{
138 gax.WithTimeout(5000 * time.Millisecond),
139 },
140 ExportData: []gax.CallOption{
141 gax.WithTimeout(5000 * time.Millisecond),
142 },
143 GetAnnotationSpec: []gax.CallOption{
144 gax.WithTimeout(5000 * time.Millisecond),
145 gax.WithRetry(func() gax.Retryer {
146 return gax.OnCodes([]codes.Code{
147 codes.Unavailable,
148 codes.DeadlineExceeded,
149 }, gax.Backoff{
150 Initial: 100 * time.Millisecond,
151 Max: 60000 * time.Millisecond,
152 Multiplier: 1.30,
153 })
154 }),
155 },
156 GetTableSpec: []gax.CallOption{
157 gax.WithTimeout(5000 * time.Millisecond),
158 gax.WithRetry(func() gax.Retryer {
159 return gax.OnCodes([]codes.Code{
160 codes.Unavailable,
161 codes.DeadlineExceeded,
162 }, gax.Backoff{
163 Initial: 100 * time.Millisecond,
164 Max: 60000 * time.Millisecond,
165 Multiplier: 1.30,
166 })
167 }),
168 },
169 ListTableSpecs: []gax.CallOption{
170 gax.WithTimeout(5000 * time.Millisecond),
171 gax.WithRetry(func() gax.Retryer {
172 return gax.OnCodes([]codes.Code{
173 codes.Unavailable,
174 codes.DeadlineExceeded,
175 }, gax.Backoff{
176 Initial: 100 * time.Millisecond,
177 Max: 60000 * time.Millisecond,
178 Multiplier: 1.30,
179 })
180 }),
181 },
182 UpdateTableSpec: []gax.CallOption{
183 gax.WithTimeout(5000 * time.Millisecond),
184 },
185 GetColumnSpec: []gax.CallOption{
186 gax.WithTimeout(5000 * time.Millisecond),
187 gax.WithRetry(func() gax.Retryer {
188 return gax.OnCodes([]codes.Code{
189 codes.Unavailable,
190 codes.DeadlineExceeded,
191 }, gax.Backoff{
192 Initial: 100 * time.Millisecond,
193 Max: 60000 * time.Millisecond,
194 Multiplier: 1.30,
195 })
196 }),
197 },
198 ListColumnSpecs: []gax.CallOption{
199 gax.WithTimeout(5000 * time.Millisecond),
200 gax.WithRetry(func() gax.Retryer {
201 return gax.OnCodes([]codes.Code{
202 codes.Unavailable,
203 codes.DeadlineExceeded,
204 }, gax.Backoff{
205 Initial: 100 * time.Millisecond,
206 Max: 60000 * time.Millisecond,
207 Multiplier: 1.30,
208 })
209 }),
210 },
211 UpdateColumnSpec: []gax.CallOption{
212 gax.WithTimeout(5000 * time.Millisecond),
213 },
214 CreateModel: []gax.CallOption{
215 gax.WithTimeout(5000 * time.Millisecond),
216 },
217 GetModel: []gax.CallOption{
218 gax.WithTimeout(5000 * time.Millisecond),
219 gax.WithRetry(func() gax.Retryer {
220 return gax.OnCodes([]codes.Code{
221 codes.Unavailable,
222 codes.DeadlineExceeded,
223 }, gax.Backoff{
224 Initial: 100 * time.Millisecond,
225 Max: 60000 * time.Millisecond,
226 Multiplier: 1.30,
227 })
228 }),
229 },
230 ListModels: []gax.CallOption{
231 gax.WithTimeout(5000 * time.Millisecond),
232 gax.WithRetry(func() gax.Retryer {
233 return gax.OnCodes([]codes.Code{
234 codes.Unavailable,
235 codes.DeadlineExceeded,
236 }, gax.Backoff{
237 Initial: 100 * time.Millisecond,
238 Max: 60000 * time.Millisecond,
239 Multiplier: 1.30,
240 })
241 }),
242 },
243 DeleteModel: []gax.CallOption{
244 gax.WithTimeout(5000 * time.Millisecond),
245 gax.WithRetry(func() gax.Retryer {
246 return gax.OnCodes([]codes.Code{
247 codes.Unavailable,
248 codes.DeadlineExceeded,
249 }, gax.Backoff{
250 Initial: 100 * time.Millisecond,
251 Max: 60000 * time.Millisecond,
252 Multiplier: 1.30,
253 })
254 }),
255 },
256 DeployModel: []gax.CallOption{
257 gax.WithTimeout(5000 * time.Millisecond),
258 },
259 UndeployModel: []gax.CallOption{
260 gax.WithTimeout(5000 * time.Millisecond),
261 },
262 ExportModel: []gax.CallOption{
263 gax.WithTimeout(5000 * time.Millisecond),
264 },
265 ExportEvaluatedExamples: []gax.CallOption{
266 gax.WithTimeout(5000 * time.Millisecond),
267 },
268 GetModelEvaluation: []gax.CallOption{
269 gax.WithTimeout(5000 * time.Millisecond),
270 gax.WithRetry(func() gax.Retryer {
271 return gax.OnCodes([]codes.Code{
272 codes.Unavailable,
273 codes.DeadlineExceeded,
274 }, gax.Backoff{
275 Initial: 100 * time.Millisecond,
276 Max: 60000 * time.Millisecond,
277 Multiplier: 1.30,
278 })
279 }),
280 },
281 ListModelEvaluations: []gax.CallOption{
282 gax.WithTimeout(5000 * time.Millisecond),
283 },
284 }
285 }
286
287 func defaultRESTCallOptions() *CallOptions {
288 return &CallOptions{
289 CreateDataset: []gax.CallOption{
290 gax.WithTimeout(5000 * time.Millisecond),
291 },
292 GetDataset: []gax.CallOption{
293 gax.WithTimeout(5000 * time.Millisecond),
294 gax.WithRetry(func() gax.Retryer {
295 return gax.OnHTTPCodes(gax.Backoff{
296 Initial: 100 * time.Millisecond,
297 Max: 60000 * time.Millisecond,
298 Multiplier: 1.30,
299 },
300 http.StatusServiceUnavailable,
301 http.StatusGatewayTimeout)
302 }),
303 },
304 ListDatasets: []gax.CallOption{
305 gax.WithTimeout(5000 * time.Millisecond),
306 gax.WithRetry(func() gax.Retryer {
307 return gax.OnHTTPCodes(gax.Backoff{
308 Initial: 100 * time.Millisecond,
309 Max: 60000 * time.Millisecond,
310 Multiplier: 1.30,
311 },
312 http.StatusServiceUnavailable,
313 http.StatusGatewayTimeout)
314 }),
315 },
316 UpdateDataset: []gax.CallOption{
317 gax.WithTimeout(5000 * time.Millisecond),
318 },
319 DeleteDataset: []gax.CallOption{
320 gax.WithTimeout(5000 * time.Millisecond),
321 gax.WithRetry(func() gax.Retryer {
322 return gax.OnHTTPCodes(gax.Backoff{
323 Initial: 100 * time.Millisecond,
324 Max: 60000 * time.Millisecond,
325 Multiplier: 1.30,
326 },
327 http.StatusServiceUnavailable,
328 http.StatusGatewayTimeout)
329 }),
330 },
331 ImportData: []gax.CallOption{
332 gax.WithTimeout(5000 * time.Millisecond),
333 },
334 ExportData: []gax.CallOption{
335 gax.WithTimeout(5000 * time.Millisecond),
336 },
337 GetAnnotationSpec: []gax.CallOption{
338 gax.WithTimeout(5000 * time.Millisecond),
339 gax.WithRetry(func() gax.Retryer {
340 return gax.OnHTTPCodes(gax.Backoff{
341 Initial: 100 * time.Millisecond,
342 Max: 60000 * time.Millisecond,
343 Multiplier: 1.30,
344 },
345 http.StatusServiceUnavailable,
346 http.StatusGatewayTimeout)
347 }),
348 },
349 GetTableSpec: []gax.CallOption{
350 gax.WithTimeout(5000 * time.Millisecond),
351 gax.WithRetry(func() gax.Retryer {
352 return gax.OnHTTPCodes(gax.Backoff{
353 Initial: 100 * time.Millisecond,
354 Max: 60000 * time.Millisecond,
355 Multiplier: 1.30,
356 },
357 http.StatusServiceUnavailable,
358 http.StatusGatewayTimeout)
359 }),
360 },
361 ListTableSpecs: []gax.CallOption{
362 gax.WithTimeout(5000 * time.Millisecond),
363 gax.WithRetry(func() gax.Retryer {
364 return gax.OnHTTPCodes(gax.Backoff{
365 Initial: 100 * time.Millisecond,
366 Max: 60000 * time.Millisecond,
367 Multiplier: 1.30,
368 },
369 http.StatusServiceUnavailable,
370 http.StatusGatewayTimeout)
371 }),
372 },
373 UpdateTableSpec: []gax.CallOption{
374 gax.WithTimeout(5000 * time.Millisecond),
375 },
376 GetColumnSpec: []gax.CallOption{
377 gax.WithTimeout(5000 * time.Millisecond),
378 gax.WithRetry(func() gax.Retryer {
379 return gax.OnHTTPCodes(gax.Backoff{
380 Initial: 100 * time.Millisecond,
381 Max: 60000 * time.Millisecond,
382 Multiplier: 1.30,
383 },
384 http.StatusServiceUnavailable,
385 http.StatusGatewayTimeout)
386 }),
387 },
388 ListColumnSpecs: []gax.CallOption{
389 gax.WithTimeout(5000 * time.Millisecond),
390 gax.WithRetry(func() gax.Retryer {
391 return gax.OnHTTPCodes(gax.Backoff{
392 Initial: 100 * time.Millisecond,
393 Max: 60000 * time.Millisecond,
394 Multiplier: 1.30,
395 },
396 http.StatusServiceUnavailable,
397 http.StatusGatewayTimeout)
398 }),
399 },
400 UpdateColumnSpec: []gax.CallOption{
401 gax.WithTimeout(5000 * time.Millisecond),
402 },
403 CreateModel: []gax.CallOption{
404 gax.WithTimeout(5000 * time.Millisecond),
405 },
406 GetModel: []gax.CallOption{
407 gax.WithTimeout(5000 * time.Millisecond),
408 gax.WithRetry(func() gax.Retryer {
409 return gax.OnHTTPCodes(gax.Backoff{
410 Initial: 100 * time.Millisecond,
411 Max: 60000 * time.Millisecond,
412 Multiplier: 1.30,
413 },
414 http.StatusServiceUnavailable,
415 http.StatusGatewayTimeout)
416 }),
417 },
418 ListModels: []gax.CallOption{
419 gax.WithTimeout(5000 * time.Millisecond),
420 gax.WithRetry(func() gax.Retryer {
421 return gax.OnHTTPCodes(gax.Backoff{
422 Initial: 100 * time.Millisecond,
423 Max: 60000 * time.Millisecond,
424 Multiplier: 1.30,
425 },
426 http.StatusServiceUnavailable,
427 http.StatusGatewayTimeout)
428 }),
429 },
430 DeleteModel: []gax.CallOption{
431 gax.WithTimeout(5000 * time.Millisecond),
432 gax.WithRetry(func() gax.Retryer {
433 return gax.OnHTTPCodes(gax.Backoff{
434 Initial: 100 * time.Millisecond,
435 Max: 60000 * time.Millisecond,
436 Multiplier: 1.30,
437 },
438 http.StatusServiceUnavailable,
439 http.StatusGatewayTimeout)
440 }),
441 },
442 DeployModel: []gax.CallOption{
443 gax.WithTimeout(5000 * time.Millisecond),
444 },
445 UndeployModel: []gax.CallOption{
446 gax.WithTimeout(5000 * time.Millisecond),
447 },
448 ExportModel: []gax.CallOption{
449 gax.WithTimeout(5000 * time.Millisecond),
450 },
451 ExportEvaluatedExamples: []gax.CallOption{
452 gax.WithTimeout(5000 * time.Millisecond),
453 },
454 GetModelEvaluation: []gax.CallOption{
455 gax.WithTimeout(5000 * time.Millisecond),
456 gax.WithRetry(func() gax.Retryer {
457 return gax.OnHTTPCodes(gax.Backoff{
458 Initial: 100 * time.Millisecond,
459 Max: 60000 * time.Millisecond,
460 Multiplier: 1.30,
461 },
462 http.StatusServiceUnavailable,
463 http.StatusGatewayTimeout)
464 }),
465 },
466 ListModelEvaluations: []gax.CallOption{
467 gax.WithTimeout(5000 * time.Millisecond),
468 },
469 }
470 }
471
472 // internalClient is an interface that defines the methods available from Cloud AutoML API.
473 type internalClient interface {
474 Close() error
475 setGoogleClientInfo(...string)
476 Connection() *grpc.ClientConn
477 CreateDataset(context.Context, *automlpb.CreateDatasetRequest, ...gax.CallOption) (*automlpb.Dataset, error)
478 GetDataset(context.Context, *automlpb.GetDatasetRequest, ...gax.CallOption) (*automlpb.Dataset, error)
479 ListDatasets(context.Context, *automlpb.ListDatasetsRequest, ...gax.CallOption) *DatasetIterator
480 UpdateDataset(context.Context, *automlpb.UpdateDatasetRequest, ...gax.CallOption) (*automlpb.Dataset, error)
481 DeleteDataset(context.Context, *automlpb.DeleteDatasetRequest, ...gax.CallOption) (*DeleteDatasetOperation, error)
482 DeleteDatasetOperation(name string) *DeleteDatasetOperation
483 ImportData(context.Context, *automlpb.ImportDataRequest, ...gax.CallOption) (*ImportDataOperation, error)
484 ImportDataOperation(name string) *ImportDataOperation
485 ExportData(context.Context, *automlpb.ExportDataRequest, ...gax.CallOption) (*ExportDataOperation, error)
486 ExportDataOperation(name string) *ExportDataOperation
487 GetAnnotationSpec(context.Context, *automlpb.GetAnnotationSpecRequest, ...gax.CallOption) (*automlpb.AnnotationSpec, error)
488 GetTableSpec(context.Context, *automlpb.GetTableSpecRequest, ...gax.CallOption) (*automlpb.TableSpec, error)
489 ListTableSpecs(context.Context, *automlpb.ListTableSpecsRequest, ...gax.CallOption) *TableSpecIterator
490 UpdateTableSpec(context.Context, *automlpb.UpdateTableSpecRequest, ...gax.CallOption) (*automlpb.TableSpec, error)
491 GetColumnSpec(context.Context, *automlpb.GetColumnSpecRequest, ...gax.CallOption) (*automlpb.ColumnSpec, error)
492 ListColumnSpecs(context.Context, *automlpb.ListColumnSpecsRequest, ...gax.CallOption) *ColumnSpecIterator
493 UpdateColumnSpec(context.Context, *automlpb.UpdateColumnSpecRequest, ...gax.CallOption) (*automlpb.ColumnSpec, error)
494 CreateModel(context.Context, *automlpb.CreateModelRequest, ...gax.CallOption) (*CreateModelOperation, error)
495 CreateModelOperation(name string) *CreateModelOperation
496 GetModel(context.Context, *automlpb.GetModelRequest, ...gax.CallOption) (*automlpb.Model, error)
497 ListModels(context.Context, *automlpb.ListModelsRequest, ...gax.CallOption) *ModelIterator
498 DeleteModel(context.Context, *automlpb.DeleteModelRequest, ...gax.CallOption) (*DeleteModelOperation, error)
499 DeleteModelOperation(name string) *DeleteModelOperation
500 DeployModel(context.Context, *automlpb.DeployModelRequest, ...gax.CallOption) (*DeployModelOperation, error)
501 DeployModelOperation(name string) *DeployModelOperation
502 UndeployModel(context.Context, *automlpb.UndeployModelRequest, ...gax.CallOption) (*UndeployModelOperation, error)
503 UndeployModelOperation(name string) *UndeployModelOperation
504 ExportModel(context.Context, *automlpb.ExportModelRequest, ...gax.CallOption) (*ExportModelOperation, error)
505 ExportModelOperation(name string) *ExportModelOperation
506 ExportEvaluatedExamples(context.Context, *automlpb.ExportEvaluatedExamplesRequest, ...gax.CallOption) (*ExportEvaluatedExamplesOperation, error)
507 ExportEvaluatedExamplesOperation(name string) *ExportEvaluatedExamplesOperation
508 GetModelEvaluation(context.Context, *automlpb.GetModelEvaluationRequest, ...gax.CallOption) (*automlpb.ModelEvaluation, error)
509 ListModelEvaluations(context.Context, *automlpb.ListModelEvaluationsRequest, ...gax.CallOption) *ModelEvaluationIterator
510 }
511
512 // Client is a client for interacting with Cloud AutoML API.
513 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
514 //
515 // AutoML Server API.
516 //
517 // The resource names are assigned by the server.
518 // The server never reuses names that it has created after the resources with
519 // those names are deleted.
520 //
521 // An ID of a resource is the last element of the item’s resource name. For
522 // projects/{project_id}/locations/{location_id}/datasets/{dataset_id}, then
523 // the id for the item is {dataset_id}.
524 //
525 // Currently the only supported location_id is “us-central1”.
526 //
527 // On any input that is documented to expect a string parameter in
528 // snake_case or kebab-case, either of those cases is accepted.
529 type Client struct {
530 // The internal transport-dependent client.
531 internalClient internalClient
532
533 // The call options for this service.
534 CallOptions *CallOptions
535
536 // LROClient is used internally to handle long-running operations.
537 // It is exposed so that its CallOptions can be modified if required.
538 // Users should not Close this client.
539 LROClient *lroauto.OperationsClient
540 }
541
542 // Wrapper methods routed to the internal client.
543
544 // Close closes the connection to the API service. The user should invoke this when
545 // the client is no longer required.
546 func (c *Client) Close() error {
547 return c.internalClient.Close()
548 }
549
550 // setGoogleClientInfo sets the name and version of the application in
551 // the `x-goog-api-client` header passed on each request. Intended for
552 // use by Google-written clients.
553 func (c *Client) setGoogleClientInfo(keyval ...string) {
554 c.internalClient.setGoogleClientInfo(keyval...)
555 }
556
557 // Connection returns a connection to the API service.
558 //
559 // Deprecated: Connections are now pooled so this method does not always
560 // return the same resource.
561 func (c *Client) Connection() *grpc.ClientConn {
562 return c.internalClient.Connection()
563 }
564
565 // CreateDataset creates a dataset.
566 func (c *Client) CreateDataset(ctx context.Context, req *automlpb.CreateDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) {
567 return c.internalClient.CreateDataset(ctx, req, opts...)
568 }
569
570 // GetDataset gets a dataset.
571 func (c *Client) GetDataset(ctx context.Context, req *automlpb.GetDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) {
572 return c.internalClient.GetDataset(ctx, req, opts...)
573 }
574
575 // ListDatasets lists datasets in a project.
576 func (c *Client) ListDatasets(ctx context.Context, req *automlpb.ListDatasetsRequest, opts ...gax.CallOption) *DatasetIterator {
577 return c.internalClient.ListDatasets(ctx, req, opts...)
578 }
579
580 // UpdateDataset updates a dataset.
581 func (c *Client) UpdateDataset(ctx context.Context, req *automlpb.UpdateDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) {
582 return c.internalClient.UpdateDataset(ctx, req, opts...)
583 }
584
585 // DeleteDataset deletes a dataset and all of its contents.
586 // Returns empty response in the
587 // response field when it completes,
588 // and delete_details in the
589 // metadata field.
590 func (c *Client) DeleteDataset(ctx context.Context, req *automlpb.DeleteDatasetRequest, opts ...gax.CallOption) (*DeleteDatasetOperation, error) {
591 return c.internalClient.DeleteDataset(ctx, req, opts...)
592 }
593
594 // DeleteDatasetOperation returns a new DeleteDatasetOperation from a given name.
595 // The name must be that of a previously created DeleteDatasetOperation, possibly from a different process.
596 func (c *Client) DeleteDatasetOperation(name string) *DeleteDatasetOperation {
597 return c.internalClient.DeleteDatasetOperation(name)
598 }
599
600 // ImportData imports data into a dataset.
601 // For Tables this method can only be called on an empty Dataset.
602 //
603 // For Tables:
604 //
605 // A
606 // schema_inference_version
607 // parameter must be explicitly set.
608 // Returns an empty response in the
609 // response field when it completes.
610 func (c *Client) ImportData(ctx context.Context, req *automlpb.ImportDataRequest, opts ...gax.CallOption) (*ImportDataOperation, error) {
611 return c.internalClient.ImportData(ctx, req, opts...)
612 }
613
614 // ImportDataOperation returns a new ImportDataOperation from a given name.
615 // The name must be that of a previously created ImportDataOperation, possibly from a different process.
616 func (c *Client) ImportDataOperation(name string) *ImportDataOperation {
617 return c.internalClient.ImportDataOperation(name)
618 }
619
620 // ExportData exports dataset’s data to the provided output location.
621 // Returns an empty response in the
622 // response field when it completes.
623 func (c *Client) ExportData(ctx context.Context, req *automlpb.ExportDataRequest, opts ...gax.CallOption) (*ExportDataOperation, error) {
624 return c.internalClient.ExportData(ctx, req, opts...)
625 }
626
627 // ExportDataOperation returns a new ExportDataOperation from a given name.
628 // The name must be that of a previously created ExportDataOperation, possibly from a different process.
629 func (c *Client) ExportDataOperation(name string) *ExportDataOperation {
630 return c.internalClient.ExportDataOperation(name)
631 }
632
633 // GetAnnotationSpec gets an annotation spec.
634 func (c *Client) GetAnnotationSpec(ctx context.Context, req *automlpb.GetAnnotationSpecRequest, opts ...gax.CallOption) (*automlpb.AnnotationSpec, error) {
635 return c.internalClient.GetAnnotationSpec(ctx, req, opts...)
636 }
637
638 // GetTableSpec gets a table spec.
639 func (c *Client) GetTableSpec(ctx context.Context, req *automlpb.GetTableSpecRequest, opts ...gax.CallOption) (*automlpb.TableSpec, error) {
640 return c.internalClient.GetTableSpec(ctx, req, opts...)
641 }
642
643 // ListTableSpecs lists table specs in a dataset.
644 func (c *Client) ListTableSpecs(ctx context.Context, req *automlpb.ListTableSpecsRequest, opts ...gax.CallOption) *TableSpecIterator {
645 return c.internalClient.ListTableSpecs(ctx, req, opts...)
646 }
647
648 // UpdateTableSpec updates a table spec.
649 func (c *Client) UpdateTableSpec(ctx context.Context, req *automlpb.UpdateTableSpecRequest, opts ...gax.CallOption) (*automlpb.TableSpec, error) {
650 return c.internalClient.UpdateTableSpec(ctx, req, opts...)
651 }
652
653 // GetColumnSpec gets a column spec.
654 func (c *Client) GetColumnSpec(ctx context.Context, req *automlpb.GetColumnSpecRequest, opts ...gax.CallOption) (*automlpb.ColumnSpec, error) {
655 return c.internalClient.GetColumnSpec(ctx, req, opts...)
656 }
657
658 // ListColumnSpecs lists column specs in a table spec.
659 func (c *Client) ListColumnSpecs(ctx context.Context, req *automlpb.ListColumnSpecsRequest, opts ...gax.CallOption) *ColumnSpecIterator {
660 return c.internalClient.ListColumnSpecs(ctx, req, opts...)
661 }
662
663 // UpdateColumnSpec updates a column spec.
664 func (c *Client) UpdateColumnSpec(ctx context.Context, req *automlpb.UpdateColumnSpecRequest, opts ...gax.CallOption) (*automlpb.ColumnSpec, error) {
665 return c.internalClient.UpdateColumnSpec(ctx, req, opts...)
666 }
667
668 // CreateModel creates a model.
669 // Returns a Model in the response
670 // field when it completes.
671 // When you create a model, several model evaluations are created for it:
672 // a global evaluation, and one evaluation for each annotation spec.
673 func (c *Client) CreateModel(ctx context.Context, req *automlpb.CreateModelRequest, opts ...gax.CallOption) (*CreateModelOperation, error) {
674 return c.internalClient.CreateModel(ctx, req, opts...)
675 }
676
677 // CreateModelOperation returns a new CreateModelOperation from a given name.
678 // The name must be that of a previously created CreateModelOperation, possibly from a different process.
679 func (c *Client) CreateModelOperation(name string) *CreateModelOperation {
680 return c.internalClient.CreateModelOperation(name)
681 }
682
683 // GetModel gets a model.
684 func (c *Client) GetModel(ctx context.Context, req *automlpb.GetModelRequest, opts ...gax.CallOption) (*automlpb.Model, error) {
685 return c.internalClient.GetModel(ctx, req, opts...)
686 }
687
688 // ListModels lists models.
689 func (c *Client) ListModels(ctx context.Context, req *automlpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator {
690 return c.internalClient.ListModels(ctx, req, opts...)
691 }
692
693 // DeleteModel deletes a model.
694 // Returns google.protobuf.Empty in the
695 // response field when it completes,
696 // and delete_details in the
697 // metadata field.
698 func (c *Client) DeleteModel(ctx context.Context, req *automlpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error) {
699 return c.internalClient.DeleteModel(ctx, req, opts...)
700 }
701
702 // DeleteModelOperation returns a new DeleteModelOperation from a given name.
703 // The name must be that of a previously created DeleteModelOperation, possibly from a different process.
704 func (c *Client) DeleteModelOperation(name string) *DeleteModelOperation {
705 return c.internalClient.DeleteModelOperation(name)
706 }
707
708 // DeployModel deploys a model. If a model is already deployed, deploying it with the
709 // same parameters has no effect. Deploying with different parametrs
710 // (as e.g. changing
711 //
712 // node_number)
713 // will reset the deployment state without pausing the model’s availability.
714 //
715 // Only applicable for Text Classification, Image Object Detection , Tables, and Image Segmentation; all other domains manage
716 // deployment automatically.
717 //
718 // Returns an empty response in the
719 // response field when it completes.
720 func (c *Client) DeployModel(ctx context.Context, req *automlpb.DeployModelRequest, opts ...gax.CallOption) (*DeployModelOperation, error) {
721 return c.internalClient.DeployModel(ctx, req, opts...)
722 }
723
724 // DeployModelOperation returns a new DeployModelOperation from a given name.
725 // The name must be that of a previously created DeployModelOperation, possibly from a different process.
726 func (c *Client) DeployModelOperation(name string) *DeployModelOperation {
727 return c.internalClient.DeployModelOperation(name)
728 }
729
730 // UndeployModel undeploys a model. If the model is not deployed this method has no effect.
731 //
732 // Only applicable for Text Classification, Image Object Detection and Tables;
733 // all other domains manage deployment automatically.
734 //
735 // Returns an empty response in the
736 // response field when it completes.
737 func (c *Client) UndeployModel(ctx context.Context, req *automlpb.UndeployModelRequest, opts ...gax.CallOption) (*UndeployModelOperation, error) {
738 return c.internalClient.UndeployModel(ctx, req, opts...)
739 }
740
741 // UndeployModelOperation returns a new UndeployModelOperation from a given name.
742 // The name must be that of a previously created UndeployModelOperation, possibly from a different process.
743 func (c *Client) UndeployModelOperation(name string) *UndeployModelOperation {
744 return c.internalClient.UndeployModelOperation(name)
745 }
746
747 // ExportModel exports a trained, “export-able”, model to a user specified Google Cloud
748 // Storage location. A model is considered export-able if and only if it has
749 // an export format defined for it in
750 //
751 // ModelExportOutputConfig.
752 //
753 // Returns an empty response in the
754 // response field when it completes.
755 func (c *Client) ExportModel(ctx context.Context, req *automlpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error) {
756 return c.internalClient.ExportModel(ctx, req, opts...)
757 }
758
759 // ExportModelOperation returns a new ExportModelOperation from a given name.
760 // The name must be that of a previously created ExportModelOperation, possibly from a different process.
761 func (c *Client) ExportModelOperation(name string) *ExportModelOperation {
762 return c.internalClient.ExportModelOperation(name)
763 }
764
765 // ExportEvaluatedExamples exports examples on which the model was evaluated (i.e. which were in the
766 // TEST set of the dataset the model was created from), together with their
767 // ground truth annotations and the annotations created (predicted) by the
768 // model.
769 // The examples, ground truth and predictions are exported in the state
770 // they were at the moment the model was evaluated.
771 //
772 // This export is available only for 30 days since the model evaluation is
773 // created.
774 //
775 // Currently only available for Tables.
776 //
777 // Returns an empty response in the
778 // response field when it completes.
779 func (c *Client) ExportEvaluatedExamples(ctx context.Context, req *automlpb.ExportEvaluatedExamplesRequest, opts ...gax.CallOption) (*ExportEvaluatedExamplesOperation, error) {
780 return c.internalClient.ExportEvaluatedExamples(ctx, req, opts...)
781 }
782
783 // ExportEvaluatedExamplesOperation returns a new ExportEvaluatedExamplesOperation from a given name.
784 // The name must be that of a previously created ExportEvaluatedExamplesOperation, possibly from a different process.
785 func (c *Client) ExportEvaluatedExamplesOperation(name string) *ExportEvaluatedExamplesOperation {
786 return c.internalClient.ExportEvaluatedExamplesOperation(name)
787 }
788
789 // GetModelEvaluation gets a model evaluation.
790 func (c *Client) GetModelEvaluation(ctx context.Context, req *automlpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*automlpb.ModelEvaluation, error) {
791 return c.internalClient.GetModelEvaluation(ctx, req, opts...)
792 }
793
794 // ListModelEvaluations lists model evaluations.
795 func (c *Client) ListModelEvaluations(ctx context.Context, req *automlpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator {
796 return c.internalClient.ListModelEvaluations(ctx, req, opts...)
797 }
798
799 // gRPCClient is a client for interacting with Cloud AutoML API over gRPC transport.
800 //
801 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
802 type gRPCClient struct {
803 // Connection pool of gRPC connections to the service.
804 connPool gtransport.ConnPool
805
806 // Points back to the CallOptions field of the containing Client
807 CallOptions **CallOptions
808
809 // The gRPC API client.
810 client automlpb.AutoMlClient
811
812 // LROClient is used internally to handle long-running operations.
813 // It is exposed so that its CallOptions can be modified if required.
814 // Users should not Close this client.
815 LROClient **lroauto.OperationsClient
816
817 // The x-goog-* metadata to be sent with each request.
818 xGoogHeaders []string
819
820 logger *slog.Logger
821 }
822
823 // NewClient creates a new auto ml client based on gRPC.
824 // The returned client must be Closed when it is done being used to clean up its underlying connections.
825 //
826 // AutoML Server API.
827 //
828 // The resource names are assigned by the server.
829 // The server never reuses names that it has created after the resources with
830 // those names are deleted.
831 //
832 // An ID of a resource is the last element of the item’s resource name. For
833 // projects/{project_id}/locations/{location_id}/datasets/{dataset_id}, then
834 // the id for the item is {dataset_id}.
835 //
836 // Currently the only supported location_id is “us-central1”.
837 //
838 // On any input that is documented to expect a string parameter in
839 // snake_case or kebab-case, either of those cases is accepted.
840 func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
841 clientOpts := defaultGRPCClientOptions()
842 if newClientHook != nil {
843 hookOpts, err := newClientHook(ctx, clientHookParams{})
844 if err != nil {
845 return nil, err
846 }
847 clientOpts = append(clientOpts, hookOpts...)
848 }
849
850 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
851 if err != nil {
852 return nil, err
853 }
854 client := Client{CallOptions: defaultCallOptions()}
855
856 c := &gRPCClient{
857 connPool: connPool,
858 client: automlpb.NewAutoMlClient(connPool),
859 CallOptions: &client.CallOptions,
860 logger: internaloption.GetLogger(opts),
861 }
862 c.setGoogleClientInfo()
863
864 client.internalClient = c
865
866 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
867 if err != nil {
868 // This error "should not happen", since we are just reusing old connection pool
869 // and never actually need to dial.
870 // If this does happen, we could leak connp. However, we cannot close conn:
871 // If the user invoked the constructor with option.WithGRPCConn,
872 // we would close a connection that's still in use.
873 // TODO: investigate error conditions.
874 return nil, err
875 }
876 c.LROClient = &client.LROClient
877 return &client, nil
878 }
879
880 // Connection returns a connection to the API service.
881 //
882 // Deprecated: Connections are now pooled so this method does not always
883 // return the same resource.
884 func (c *gRPCClient) Connection() *grpc.ClientConn {
885 return c.connPool.Conn()
886 }
887
888 // setGoogleClientInfo sets the name and version of the application in
889 // the `x-goog-api-client` header passed on each request. Intended for
890 // use by Google-written clients.
891 func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
892 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
893 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
894 c.xGoogHeaders = []string{
895 "x-goog-api-client", gax.XGoogHeader(kv...),
896 }
897 }
898
899 // Close closes the connection to the API service. The user should invoke this when
900 // the client is no longer required.
901 func (c *gRPCClient) Close() error {
902 return c.connPool.Close()
903 }
904
905 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
906 type restClient struct {
907 // The http endpoint to connect to.
908 endpoint string
909
910 // The http client.
911 httpClient *http.Client
912
913 // LROClient is used internally to handle long-running operations.
914 // It is exposed so that its CallOptions can be modified if required.
915 // Users should not Close this client.
916 LROClient **lroauto.OperationsClient
917
918 // The x-goog-* headers to be sent with each request.
919 xGoogHeaders []string
920
921 // Points back to the CallOptions field of the containing Client
922 CallOptions **CallOptions
923
924 logger *slog.Logger
925 }
926
927 // NewRESTClient creates a new auto ml rest client.
928 //
929 // AutoML Server API.
930 //
931 // The resource names are assigned by the server.
932 // The server never reuses names that it has created after the resources with
933 // those names are deleted.
934 //
935 // An ID of a resource is the last element of the item’s resource name. For
936 // projects/{project_id}/locations/{location_id}/datasets/{dataset_id}, then
937 // the id for the item is {dataset_id}.
938 //
939 // Currently the only supported location_id is “us-central1”.
940 //
941 // On any input that is documented to expect a string parameter in
942 // snake_case or kebab-case, either of those cases is accepted.
943 func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
944 clientOpts := append(defaultRESTClientOptions(), opts...)
945 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
946 if err != nil {
947 return nil, err
948 }
949
950 callOpts := defaultRESTCallOptions()
951 c := &restClient{
952 endpoint: endpoint,
953 httpClient: httpClient,
954 CallOptions: &callOpts,
955 logger: internaloption.GetLogger(opts),
956 }
957 c.setGoogleClientInfo()
958
959 lroOpts := []option.ClientOption{
960 option.WithHTTPClient(httpClient),
961 option.WithEndpoint(endpoint),
962 }
963 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
964 if err != nil {
965 return nil, err
966 }
967 c.LROClient = &opClient
968
969 return &Client{internalClient: c, CallOptions: callOpts}, nil
970 }
971
972 func defaultRESTClientOptions() []option.ClientOption {
973 return []option.ClientOption{
974 internaloption.WithDefaultEndpoint("https://automl.googleapis.com"),
975 internaloption.WithDefaultEndpointTemplate("https://automl.UNIVERSE_DOMAIN"),
976 internaloption.WithDefaultMTLSEndpoint("https://automl.mtls.googleapis.com"),
977 internaloption.WithDefaultUniverseDomain("googleapis.com"),
978 internaloption.WithDefaultAudience("https://automl.googleapis.com/"),
979 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
980 internaloption.EnableNewAuthLibrary(),
981 }
982 }
983
984 // setGoogleClientInfo sets the name and version of the application in
985 // the `x-goog-api-client` header passed on each request. Intended for
986 // use by Google-written clients.
987 func (c *restClient) setGoogleClientInfo(keyval ...string) {
988 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
989 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
990 c.xGoogHeaders = []string{
991 "x-goog-api-client", gax.XGoogHeader(kv...),
992 }
993 }
994
995 // Close closes the connection to the API service. The user should invoke this when
996 // the client is no longer required.
997 func (c *restClient) Close() error {
998 // Replace httpClient with nil to force cleanup.
999 c.httpClient = nil
1000 return nil
1001 }
1002
1003 // Connection returns a connection to the API service.
1004 //
1005 // Deprecated: This method always returns nil.
1006 func (c *restClient) Connection() *grpc.ClientConn {
1007 return nil
1008 }
1009 func (c *gRPCClient) CreateDataset(ctx context.Context, req *automlpb.CreateDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) {
1010 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1011
1012 hds = append(c.xGoogHeaders, hds...)
1013 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1014 opts = append((*c.CallOptions).CreateDataset[0:len((*c.CallOptions).CreateDataset):len((*c.CallOptions).CreateDataset)], opts...)
1015 var resp *automlpb.Dataset
1016 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1017 var err error
1018 resp, err = executeRPC(ctx, c.client.CreateDataset, req, settings.GRPC, c.logger, "CreateDataset")
1019 return err
1020 }, opts...)
1021 if err != nil {
1022 return nil, err
1023 }
1024 return resp, nil
1025 }
1026
1027 func (c *gRPCClient) GetDataset(ctx context.Context, req *automlpb.GetDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) {
1028 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1029
1030 hds = append(c.xGoogHeaders, hds...)
1031 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1032 opts = append((*c.CallOptions).GetDataset[0:len((*c.CallOptions).GetDataset):len((*c.CallOptions).GetDataset)], opts...)
1033 var resp *automlpb.Dataset
1034 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1035 var err error
1036 resp, err = executeRPC(ctx, c.client.GetDataset, req, settings.GRPC, c.logger, "GetDataset")
1037 return err
1038 }, opts...)
1039 if err != nil {
1040 return nil, err
1041 }
1042 return resp, nil
1043 }
1044
1045 func (c *gRPCClient) ListDatasets(ctx context.Context, req *automlpb.ListDatasetsRequest, opts ...gax.CallOption) *DatasetIterator {
1046 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1047
1048 hds = append(c.xGoogHeaders, hds...)
1049 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1050 opts = append((*c.CallOptions).ListDatasets[0:len((*c.CallOptions).ListDatasets):len((*c.CallOptions).ListDatasets)], opts...)
1051 it := &DatasetIterator{}
1052 req = proto.Clone(req).(*automlpb.ListDatasetsRequest)
1053 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.Dataset, string, error) {
1054 resp := &automlpb.ListDatasetsResponse{}
1055 if pageToken != "" {
1056 req.PageToken = pageToken
1057 }
1058 if pageSize > math.MaxInt32 {
1059 req.PageSize = math.MaxInt32
1060 } else if pageSize != 0 {
1061 req.PageSize = int32(pageSize)
1062 }
1063 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1064 var err error
1065 resp, err = executeRPC(ctx, c.client.ListDatasets, req, settings.GRPC, c.logger, "ListDatasets")
1066 return err
1067 }, opts...)
1068 if err != nil {
1069 return nil, "", err
1070 }
1071
1072 it.Response = resp
1073 return resp.GetDatasets(), resp.GetNextPageToken(), nil
1074 }
1075 fetch := func(pageSize int, pageToken string) (string, error) {
1076 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1077 if err != nil {
1078 return "", err
1079 }
1080 it.items = append(it.items, items...)
1081 return nextPageToken, nil
1082 }
1083
1084 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1085 it.pageInfo.MaxSize = int(req.GetPageSize())
1086 it.pageInfo.Token = req.GetPageToken()
1087
1088 return it
1089 }
1090
1091 func (c *gRPCClient) UpdateDataset(ctx context.Context, req *automlpb.UpdateDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) {
1092 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "dataset.name", url.QueryEscape(req.GetDataset().GetName()))}
1093
1094 hds = append(c.xGoogHeaders, hds...)
1095 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1096 opts = append((*c.CallOptions).UpdateDataset[0:len((*c.CallOptions).UpdateDataset):len((*c.CallOptions).UpdateDataset)], opts...)
1097 var resp *automlpb.Dataset
1098 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1099 var err error
1100 resp, err = executeRPC(ctx, c.client.UpdateDataset, req, settings.GRPC, c.logger, "UpdateDataset")
1101 return err
1102 }, opts...)
1103 if err != nil {
1104 return nil, err
1105 }
1106 return resp, nil
1107 }
1108
1109 func (c *gRPCClient) DeleteDataset(ctx context.Context, req *automlpb.DeleteDatasetRequest, opts ...gax.CallOption) (*DeleteDatasetOperation, error) {
1110 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1111
1112 hds = append(c.xGoogHeaders, hds...)
1113 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1114 opts = append((*c.CallOptions).DeleteDataset[0:len((*c.CallOptions).DeleteDataset):len((*c.CallOptions).DeleteDataset)], opts...)
1115 var resp *longrunningpb.Operation
1116 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1117 var err error
1118 resp, err = executeRPC(ctx, c.client.DeleteDataset, req, settings.GRPC, c.logger, "DeleteDataset")
1119 return err
1120 }, opts...)
1121 if err != nil {
1122 return nil, err
1123 }
1124 return &DeleteDatasetOperation{
1125 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1126 }, nil
1127 }
1128
1129 func (c *gRPCClient) ImportData(ctx context.Context, req *automlpb.ImportDataRequest, opts ...gax.CallOption) (*ImportDataOperation, error) {
1130 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1131
1132 hds = append(c.xGoogHeaders, hds...)
1133 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1134 opts = append((*c.CallOptions).ImportData[0:len((*c.CallOptions).ImportData):len((*c.CallOptions).ImportData)], opts...)
1135 var resp *longrunningpb.Operation
1136 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1137 var err error
1138 resp, err = executeRPC(ctx, c.client.ImportData, req, settings.GRPC, c.logger, "ImportData")
1139 return err
1140 }, opts...)
1141 if err != nil {
1142 return nil, err
1143 }
1144 return &ImportDataOperation{
1145 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1146 }, nil
1147 }
1148
1149 func (c *gRPCClient) ExportData(ctx context.Context, req *automlpb.ExportDataRequest, opts ...gax.CallOption) (*ExportDataOperation, error) {
1150 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1151
1152 hds = append(c.xGoogHeaders, hds...)
1153 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1154 opts = append((*c.CallOptions).ExportData[0:len((*c.CallOptions).ExportData):len((*c.CallOptions).ExportData)], opts...)
1155 var resp *longrunningpb.Operation
1156 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1157 var err error
1158 resp, err = executeRPC(ctx, c.client.ExportData, req, settings.GRPC, c.logger, "ExportData")
1159 return err
1160 }, opts...)
1161 if err != nil {
1162 return nil, err
1163 }
1164 return &ExportDataOperation{
1165 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1166 }, nil
1167 }
1168
1169 func (c *gRPCClient) GetAnnotationSpec(ctx context.Context, req *automlpb.GetAnnotationSpecRequest, opts ...gax.CallOption) (*automlpb.AnnotationSpec, error) {
1170 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1171
1172 hds = append(c.xGoogHeaders, hds...)
1173 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1174 opts = append((*c.CallOptions).GetAnnotationSpec[0:len((*c.CallOptions).GetAnnotationSpec):len((*c.CallOptions).GetAnnotationSpec)], opts...)
1175 var resp *automlpb.AnnotationSpec
1176 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1177 var err error
1178 resp, err = executeRPC(ctx, c.client.GetAnnotationSpec, req, settings.GRPC, c.logger, "GetAnnotationSpec")
1179 return err
1180 }, opts...)
1181 if err != nil {
1182 return nil, err
1183 }
1184 return resp, nil
1185 }
1186
1187 func (c *gRPCClient) GetTableSpec(ctx context.Context, req *automlpb.GetTableSpecRequest, opts ...gax.CallOption) (*automlpb.TableSpec, error) {
1188 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1189
1190 hds = append(c.xGoogHeaders, hds...)
1191 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1192 opts = append((*c.CallOptions).GetTableSpec[0:len((*c.CallOptions).GetTableSpec):len((*c.CallOptions).GetTableSpec)], opts...)
1193 var resp *automlpb.TableSpec
1194 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1195 var err error
1196 resp, err = executeRPC(ctx, c.client.GetTableSpec, req, settings.GRPC, c.logger, "GetTableSpec")
1197 return err
1198 }, opts...)
1199 if err != nil {
1200 return nil, err
1201 }
1202 return resp, nil
1203 }
1204
1205 func (c *gRPCClient) ListTableSpecs(ctx context.Context, req *automlpb.ListTableSpecsRequest, opts ...gax.CallOption) *TableSpecIterator {
1206 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1207
1208 hds = append(c.xGoogHeaders, hds...)
1209 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1210 opts = append((*c.CallOptions).ListTableSpecs[0:len((*c.CallOptions).ListTableSpecs):len((*c.CallOptions).ListTableSpecs)], opts...)
1211 it := &TableSpecIterator{}
1212 req = proto.Clone(req).(*automlpb.ListTableSpecsRequest)
1213 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.TableSpec, string, error) {
1214 resp := &automlpb.ListTableSpecsResponse{}
1215 if pageToken != "" {
1216 req.PageToken = pageToken
1217 }
1218 if pageSize > math.MaxInt32 {
1219 req.PageSize = math.MaxInt32
1220 } else if pageSize != 0 {
1221 req.PageSize = int32(pageSize)
1222 }
1223 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1224 var err error
1225 resp, err = executeRPC(ctx, c.client.ListTableSpecs, req, settings.GRPC, c.logger, "ListTableSpecs")
1226 return err
1227 }, opts...)
1228 if err != nil {
1229 return nil, "", err
1230 }
1231
1232 it.Response = resp
1233 return resp.GetTableSpecs(), resp.GetNextPageToken(), nil
1234 }
1235 fetch := func(pageSize int, pageToken string) (string, error) {
1236 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1237 if err != nil {
1238 return "", err
1239 }
1240 it.items = append(it.items, items...)
1241 return nextPageToken, nil
1242 }
1243
1244 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1245 it.pageInfo.MaxSize = int(req.GetPageSize())
1246 it.pageInfo.Token = req.GetPageToken()
1247
1248 return it
1249 }
1250
1251 func (c *gRPCClient) UpdateTableSpec(ctx context.Context, req *automlpb.UpdateTableSpecRequest, opts ...gax.CallOption) (*automlpb.TableSpec, error) {
1252 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "table_spec.name", url.QueryEscape(req.GetTableSpec().GetName()))}
1253
1254 hds = append(c.xGoogHeaders, hds...)
1255 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1256 opts = append((*c.CallOptions).UpdateTableSpec[0:len((*c.CallOptions).UpdateTableSpec):len((*c.CallOptions).UpdateTableSpec)], opts...)
1257 var resp *automlpb.TableSpec
1258 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1259 var err error
1260 resp, err = executeRPC(ctx, c.client.UpdateTableSpec, req, settings.GRPC, c.logger, "UpdateTableSpec")
1261 return err
1262 }, opts...)
1263 if err != nil {
1264 return nil, err
1265 }
1266 return resp, nil
1267 }
1268
1269 func (c *gRPCClient) GetColumnSpec(ctx context.Context, req *automlpb.GetColumnSpecRequest, opts ...gax.CallOption) (*automlpb.ColumnSpec, error) {
1270 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1271
1272 hds = append(c.xGoogHeaders, hds...)
1273 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1274 opts = append((*c.CallOptions).GetColumnSpec[0:len((*c.CallOptions).GetColumnSpec):len((*c.CallOptions).GetColumnSpec)], opts...)
1275 var resp *automlpb.ColumnSpec
1276 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1277 var err error
1278 resp, err = executeRPC(ctx, c.client.GetColumnSpec, req, settings.GRPC, c.logger, "GetColumnSpec")
1279 return err
1280 }, opts...)
1281 if err != nil {
1282 return nil, err
1283 }
1284 return resp, nil
1285 }
1286
1287 func (c *gRPCClient) ListColumnSpecs(ctx context.Context, req *automlpb.ListColumnSpecsRequest, opts ...gax.CallOption) *ColumnSpecIterator {
1288 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1289
1290 hds = append(c.xGoogHeaders, hds...)
1291 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1292 opts = append((*c.CallOptions).ListColumnSpecs[0:len((*c.CallOptions).ListColumnSpecs):len((*c.CallOptions).ListColumnSpecs)], opts...)
1293 it := &ColumnSpecIterator{}
1294 req = proto.Clone(req).(*automlpb.ListColumnSpecsRequest)
1295 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.ColumnSpec, string, error) {
1296 resp := &automlpb.ListColumnSpecsResponse{}
1297 if pageToken != "" {
1298 req.PageToken = pageToken
1299 }
1300 if pageSize > math.MaxInt32 {
1301 req.PageSize = math.MaxInt32
1302 } else if pageSize != 0 {
1303 req.PageSize = int32(pageSize)
1304 }
1305 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1306 var err error
1307 resp, err = executeRPC(ctx, c.client.ListColumnSpecs, req, settings.GRPC, c.logger, "ListColumnSpecs")
1308 return err
1309 }, opts...)
1310 if err != nil {
1311 return nil, "", err
1312 }
1313
1314 it.Response = resp
1315 return resp.GetColumnSpecs(), resp.GetNextPageToken(), nil
1316 }
1317 fetch := func(pageSize int, pageToken string) (string, error) {
1318 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1319 if err != nil {
1320 return "", err
1321 }
1322 it.items = append(it.items, items...)
1323 return nextPageToken, nil
1324 }
1325
1326 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1327 it.pageInfo.MaxSize = int(req.GetPageSize())
1328 it.pageInfo.Token = req.GetPageToken()
1329
1330 return it
1331 }
1332
1333 func (c *gRPCClient) UpdateColumnSpec(ctx context.Context, req *automlpb.UpdateColumnSpecRequest, opts ...gax.CallOption) (*automlpb.ColumnSpec, error) {
1334 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "column_spec.name", url.QueryEscape(req.GetColumnSpec().GetName()))}
1335
1336 hds = append(c.xGoogHeaders, hds...)
1337 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1338 opts = append((*c.CallOptions).UpdateColumnSpec[0:len((*c.CallOptions).UpdateColumnSpec):len((*c.CallOptions).UpdateColumnSpec)], opts...)
1339 var resp *automlpb.ColumnSpec
1340 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1341 var err error
1342 resp, err = executeRPC(ctx, c.client.UpdateColumnSpec, req, settings.GRPC, c.logger, "UpdateColumnSpec")
1343 return err
1344 }, opts...)
1345 if err != nil {
1346 return nil, err
1347 }
1348 return resp, nil
1349 }
1350
1351 func (c *gRPCClient) CreateModel(ctx context.Context, req *automlpb.CreateModelRequest, opts ...gax.CallOption) (*CreateModelOperation, error) {
1352 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1353
1354 hds = append(c.xGoogHeaders, hds...)
1355 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1356 opts = append((*c.CallOptions).CreateModel[0:len((*c.CallOptions).CreateModel):len((*c.CallOptions).CreateModel)], opts...)
1357 var resp *longrunningpb.Operation
1358 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1359 var err error
1360 resp, err = executeRPC(ctx, c.client.CreateModel, req, settings.GRPC, c.logger, "CreateModel")
1361 return err
1362 }, opts...)
1363 if err != nil {
1364 return nil, err
1365 }
1366 return &CreateModelOperation{
1367 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1368 }, nil
1369 }
1370
1371 func (c *gRPCClient) GetModel(ctx context.Context, req *automlpb.GetModelRequest, opts ...gax.CallOption) (*automlpb.Model, error) {
1372 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1373
1374 hds = append(c.xGoogHeaders, hds...)
1375 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1376 opts = append((*c.CallOptions).GetModel[0:len((*c.CallOptions).GetModel):len((*c.CallOptions).GetModel)], opts...)
1377 var resp *automlpb.Model
1378 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1379 var err error
1380 resp, err = executeRPC(ctx, c.client.GetModel, req, settings.GRPC, c.logger, "GetModel")
1381 return err
1382 }, opts...)
1383 if err != nil {
1384 return nil, err
1385 }
1386 return resp, nil
1387 }
1388
1389 func (c *gRPCClient) ListModels(ctx context.Context, req *automlpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator {
1390 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1391
1392 hds = append(c.xGoogHeaders, hds...)
1393 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1394 opts = append((*c.CallOptions).ListModels[0:len((*c.CallOptions).ListModels):len((*c.CallOptions).ListModels)], opts...)
1395 it := &ModelIterator{}
1396 req = proto.Clone(req).(*automlpb.ListModelsRequest)
1397 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.Model, string, error) {
1398 resp := &automlpb.ListModelsResponse{}
1399 if pageToken != "" {
1400 req.PageToken = pageToken
1401 }
1402 if pageSize > math.MaxInt32 {
1403 req.PageSize = math.MaxInt32
1404 } else if pageSize != 0 {
1405 req.PageSize = int32(pageSize)
1406 }
1407 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1408 var err error
1409 resp, err = executeRPC(ctx, c.client.ListModels, req, settings.GRPC, c.logger, "ListModels")
1410 return err
1411 }, opts...)
1412 if err != nil {
1413 return nil, "", err
1414 }
1415
1416 it.Response = resp
1417 return resp.GetModel(), resp.GetNextPageToken(), nil
1418 }
1419 fetch := func(pageSize int, pageToken string) (string, error) {
1420 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1421 if err != nil {
1422 return "", err
1423 }
1424 it.items = append(it.items, items...)
1425 return nextPageToken, nil
1426 }
1427
1428 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1429 it.pageInfo.MaxSize = int(req.GetPageSize())
1430 it.pageInfo.Token = req.GetPageToken()
1431
1432 return it
1433 }
1434
1435 func (c *gRPCClient) DeleteModel(ctx context.Context, req *automlpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error) {
1436 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1437
1438 hds = append(c.xGoogHeaders, hds...)
1439 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1440 opts = append((*c.CallOptions).DeleteModel[0:len((*c.CallOptions).DeleteModel):len((*c.CallOptions).DeleteModel)], opts...)
1441 var resp *longrunningpb.Operation
1442 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1443 var err error
1444 resp, err = executeRPC(ctx, c.client.DeleteModel, req, settings.GRPC, c.logger, "DeleteModel")
1445 return err
1446 }, opts...)
1447 if err != nil {
1448 return nil, err
1449 }
1450 return &DeleteModelOperation{
1451 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1452 }, nil
1453 }
1454
1455 func (c *gRPCClient) DeployModel(ctx context.Context, req *automlpb.DeployModelRequest, opts ...gax.CallOption) (*DeployModelOperation, error) {
1456 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1457
1458 hds = append(c.xGoogHeaders, hds...)
1459 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1460 opts = append((*c.CallOptions).DeployModel[0:len((*c.CallOptions).DeployModel):len((*c.CallOptions).DeployModel)], opts...)
1461 var resp *longrunningpb.Operation
1462 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1463 var err error
1464 resp, err = executeRPC(ctx, c.client.DeployModel, req, settings.GRPC, c.logger, "DeployModel")
1465 return err
1466 }, opts...)
1467 if err != nil {
1468 return nil, err
1469 }
1470 return &DeployModelOperation{
1471 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1472 }, nil
1473 }
1474
1475 func (c *gRPCClient) UndeployModel(ctx context.Context, req *automlpb.UndeployModelRequest, opts ...gax.CallOption) (*UndeployModelOperation, error) {
1476 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1477
1478 hds = append(c.xGoogHeaders, hds...)
1479 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1480 opts = append((*c.CallOptions).UndeployModel[0:len((*c.CallOptions).UndeployModel):len((*c.CallOptions).UndeployModel)], opts...)
1481 var resp *longrunningpb.Operation
1482 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1483 var err error
1484 resp, err = executeRPC(ctx, c.client.UndeployModel, req, settings.GRPC, c.logger, "UndeployModel")
1485 return err
1486 }, opts...)
1487 if err != nil {
1488 return nil, err
1489 }
1490 return &UndeployModelOperation{
1491 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1492 }, nil
1493 }
1494
1495 func (c *gRPCClient) ExportModel(ctx context.Context, req *automlpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error) {
1496 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1497
1498 hds = append(c.xGoogHeaders, hds...)
1499 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1500 opts = append((*c.CallOptions).ExportModel[0:len((*c.CallOptions).ExportModel):len((*c.CallOptions).ExportModel)], opts...)
1501 var resp *longrunningpb.Operation
1502 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1503 var err error
1504 resp, err = executeRPC(ctx, c.client.ExportModel, req, settings.GRPC, c.logger, "ExportModel")
1505 return err
1506 }, opts...)
1507 if err != nil {
1508 return nil, err
1509 }
1510 return &ExportModelOperation{
1511 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1512 }, nil
1513 }
1514
1515 func (c *gRPCClient) ExportEvaluatedExamples(ctx context.Context, req *automlpb.ExportEvaluatedExamplesRequest, opts ...gax.CallOption) (*ExportEvaluatedExamplesOperation, error) {
1516 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1517
1518 hds = append(c.xGoogHeaders, hds...)
1519 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1520 opts = append((*c.CallOptions).ExportEvaluatedExamples[0:len((*c.CallOptions).ExportEvaluatedExamples):len((*c.CallOptions).ExportEvaluatedExamples)], opts...)
1521 var resp *longrunningpb.Operation
1522 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1523 var err error
1524 resp, err = executeRPC(ctx, c.client.ExportEvaluatedExamples, req, settings.GRPC, c.logger, "ExportEvaluatedExamples")
1525 return err
1526 }, opts...)
1527 if err != nil {
1528 return nil, err
1529 }
1530 return &ExportEvaluatedExamplesOperation{
1531 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1532 }, nil
1533 }
1534
1535 func (c *gRPCClient) GetModelEvaluation(ctx context.Context, req *automlpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*automlpb.ModelEvaluation, error) {
1536 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1537
1538 hds = append(c.xGoogHeaders, hds...)
1539 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1540 opts = append((*c.CallOptions).GetModelEvaluation[0:len((*c.CallOptions).GetModelEvaluation):len((*c.CallOptions).GetModelEvaluation)], opts...)
1541 var resp *automlpb.ModelEvaluation
1542 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1543 var err error
1544 resp, err = executeRPC(ctx, c.client.GetModelEvaluation, req, settings.GRPC, c.logger, "GetModelEvaluation")
1545 return err
1546 }, opts...)
1547 if err != nil {
1548 return nil, err
1549 }
1550 return resp, nil
1551 }
1552
1553 func (c *gRPCClient) ListModelEvaluations(ctx context.Context, req *automlpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator {
1554 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1555
1556 hds = append(c.xGoogHeaders, hds...)
1557 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1558 opts = append((*c.CallOptions).ListModelEvaluations[0:len((*c.CallOptions).ListModelEvaluations):len((*c.CallOptions).ListModelEvaluations)], opts...)
1559 it := &ModelEvaluationIterator{}
1560 req = proto.Clone(req).(*automlpb.ListModelEvaluationsRequest)
1561 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.ModelEvaluation, string, error) {
1562 resp := &automlpb.ListModelEvaluationsResponse{}
1563 if pageToken != "" {
1564 req.PageToken = pageToken
1565 }
1566 if pageSize > math.MaxInt32 {
1567 req.PageSize = math.MaxInt32
1568 } else if pageSize != 0 {
1569 req.PageSize = int32(pageSize)
1570 }
1571 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1572 var err error
1573 resp, err = executeRPC(ctx, c.client.ListModelEvaluations, req, settings.GRPC, c.logger, "ListModelEvaluations")
1574 return err
1575 }, opts...)
1576 if err != nil {
1577 return nil, "", err
1578 }
1579
1580 it.Response = resp
1581 return resp.GetModelEvaluation(), resp.GetNextPageToken(), nil
1582 }
1583 fetch := func(pageSize int, pageToken string) (string, error) {
1584 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1585 if err != nil {
1586 return "", err
1587 }
1588 it.items = append(it.items, items...)
1589 return nextPageToken, nil
1590 }
1591
1592 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1593 it.pageInfo.MaxSize = int(req.GetPageSize())
1594 it.pageInfo.Token = req.GetPageToken()
1595
1596 return it
1597 }
1598
1599 // CreateDataset creates a dataset.
1600 func (c *restClient) CreateDataset(ctx context.Context, req *automlpb.CreateDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) {
1601 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1602 body := req.GetDataset()
1603 jsonReq, err := m.Marshal(body)
1604 if err != nil {
1605 return nil, err
1606 }
1607
1608 baseUrl, err := url.Parse(c.endpoint)
1609 if err != nil {
1610 return nil, err
1611 }
1612 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/datasets", req.GetParent())
1613
1614 params := url.Values{}
1615 params.Add("$alt", "json;enum-encoding=int")
1616
1617 baseUrl.RawQuery = params.Encode()
1618
1619 // Build HTTP headers from client and context metadata.
1620 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1621
1622 hds = append(c.xGoogHeaders, hds...)
1623 hds = append(hds, "Content-Type", "application/json")
1624 headers := gax.BuildHeaders(ctx, hds...)
1625 opts = append((*c.CallOptions).CreateDataset[0:len((*c.CallOptions).CreateDataset):len((*c.CallOptions).CreateDataset)], opts...)
1626 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1627 resp := &automlpb.Dataset{}
1628 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1629 if settings.Path != "" {
1630 baseUrl.Path = settings.Path
1631 }
1632 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1633 if err != nil {
1634 return err
1635 }
1636 httpReq = httpReq.WithContext(ctx)
1637 httpReq.Header = headers
1638
1639 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateDataset")
1640 if err != nil {
1641 return err
1642 }
1643
1644 if err := unm.Unmarshal(buf, resp); err != nil {
1645 return err
1646 }
1647
1648 return nil
1649 }, opts...)
1650 if e != nil {
1651 return nil, e
1652 }
1653 return resp, nil
1654 }
1655
1656 // GetDataset gets a dataset.
1657 func (c *restClient) GetDataset(ctx context.Context, req *automlpb.GetDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) {
1658 baseUrl, err := url.Parse(c.endpoint)
1659 if err != nil {
1660 return nil, err
1661 }
1662 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
1663
1664 params := url.Values{}
1665 params.Add("$alt", "json;enum-encoding=int")
1666
1667 baseUrl.RawQuery = params.Encode()
1668
1669 // Build HTTP headers from client and context metadata.
1670 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1671
1672 hds = append(c.xGoogHeaders, hds...)
1673 hds = append(hds, "Content-Type", "application/json")
1674 headers := gax.BuildHeaders(ctx, hds...)
1675 opts = append((*c.CallOptions).GetDataset[0:len((*c.CallOptions).GetDataset):len((*c.CallOptions).GetDataset)], opts...)
1676 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1677 resp := &automlpb.Dataset{}
1678 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1679 if settings.Path != "" {
1680 baseUrl.Path = settings.Path
1681 }
1682 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1683 if err != nil {
1684 return err
1685 }
1686 httpReq = httpReq.WithContext(ctx)
1687 httpReq.Header = headers
1688
1689 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetDataset")
1690 if err != nil {
1691 return err
1692 }
1693
1694 if err := unm.Unmarshal(buf, resp); err != nil {
1695 return err
1696 }
1697
1698 return nil
1699 }, opts...)
1700 if e != nil {
1701 return nil, e
1702 }
1703 return resp, nil
1704 }
1705
1706 // ListDatasets lists datasets in a project.
1707 func (c *restClient) ListDatasets(ctx context.Context, req *automlpb.ListDatasetsRequest, opts ...gax.CallOption) *DatasetIterator {
1708 it := &DatasetIterator{}
1709 req = proto.Clone(req).(*automlpb.ListDatasetsRequest)
1710 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1711 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.Dataset, string, error) {
1712 resp := &automlpb.ListDatasetsResponse{}
1713 if pageToken != "" {
1714 req.PageToken = pageToken
1715 }
1716 if pageSize > math.MaxInt32 {
1717 req.PageSize = math.MaxInt32
1718 } else if pageSize != 0 {
1719 req.PageSize = int32(pageSize)
1720 }
1721 baseUrl, err := url.Parse(c.endpoint)
1722 if err != nil {
1723 return nil, "", err
1724 }
1725 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/datasets", req.GetParent())
1726
1727 params := url.Values{}
1728 params.Add("$alt", "json;enum-encoding=int")
1729 if req.GetFilter() != "" {
1730 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1731 }
1732 if req.GetPageSize() != 0 {
1733 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1734 }
1735 if req.GetPageToken() != "" {
1736 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1737 }
1738
1739 baseUrl.RawQuery = params.Encode()
1740
1741 // Build HTTP headers from client and context metadata.
1742 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1743 headers := gax.BuildHeaders(ctx, hds...)
1744 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1745 if settings.Path != "" {
1746 baseUrl.Path = settings.Path
1747 }
1748 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1749 if err != nil {
1750 return err
1751 }
1752 httpReq.Header = headers
1753
1754 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDatasets")
1755 if err != nil {
1756 return err
1757 }
1758 if err := unm.Unmarshal(buf, resp); err != nil {
1759 return err
1760 }
1761
1762 return nil
1763 }, opts...)
1764 if e != nil {
1765 return nil, "", e
1766 }
1767 it.Response = resp
1768 return resp.GetDatasets(), resp.GetNextPageToken(), nil
1769 }
1770
1771 fetch := func(pageSize int, pageToken string) (string, error) {
1772 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1773 if err != nil {
1774 return "", err
1775 }
1776 it.items = append(it.items, items...)
1777 return nextPageToken, nil
1778 }
1779
1780 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1781 it.pageInfo.MaxSize = int(req.GetPageSize())
1782 it.pageInfo.Token = req.GetPageToken()
1783
1784 return it
1785 }
1786
1787 // UpdateDataset updates a dataset.
1788 func (c *restClient) UpdateDataset(ctx context.Context, req *automlpb.UpdateDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) {
1789 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1790 body := req.GetDataset()
1791 jsonReq, err := m.Marshal(body)
1792 if err != nil {
1793 return nil, err
1794 }
1795
1796 baseUrl, err := url.Parse(c.endpoint)
1797 if err != nil {
1798 return nil, err
1799 }
1800 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetDataset().GetName())
1801
1802 params := url.Values{}
1803 params.Add("$alt", "json;enum-encoding=int")
1804 if req.GetUpdateMask() != nil {
1805 field, err := protojson.Marshal(req.GetUpdateMask())
1806 if err != nil {
1807 return nil, err
1808 }
1809 params.Add("updateMask", string(field[1:len(field)-1]))
1810 }
1811
1812 baseUrl.RawQuery = params.Encode()
1813
1814 // Build HTTP headers from client and context metadata.
1815 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "dataset.name", url.QueryEscape(req.GetDataset().GetName()))}
1816
1817 hds = append(c.xGoogHeaders, hds...)
1818 hds = append(hds, "Content-Type", "application/json")
1819 headers := gax.BuildHeaders(ctx, hds...)
1820 opts = append((*c.CallOptions).UpdateDataset[0:len((*c.CallOptions).UpdateDataset):len((*c.CallOptions).UpdateDataset)], opts...)
1821 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1822 resp := &automlpb.Dataset{}
1823 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1824 if settings.Path != "" {
1825 baseUrl.Path = settings.Path
1826 }
1827 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1828 if err != nil {
1829 return err
1830 }
1831 httpReq = httpReq.WithContext(ctx)
1832 httpReq.Header = headers
1833
1834 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateDataset")
1835 if err != nil {
1836 return err
1837 }
1838
1839 if err := unm.Unmarshal(buf, resp); err != nil {
1840 return err
1841 }
1842
1843 return nil
1844 }, opts...)
1845 if e != nil {
1846 return nil, e
1847 }
1848 return resp, nil
1849 }
1850
1851 // DeleteDataset deletes a dataset and all of its contents.
1852 // Returns empty response in the
1853 // response field when it completes,
1854 // and delete_details in the
1855 // metadata field.
1856 func (c *restClient) DeleteDataset(ctx context.Context, req *automlpb.DeleteDatasetRequest, opts ...gax.CallOption) (*DeleteDatasetOperation, error) {
1857 baseUrl, err := url.Parse(c.endpoint)
1858 if err != nil {
1859 return nil, err
1860 }
1861 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
1862
1863 params := url.Values{}
1864 params.Add("$alt", "json;enum-encoding=int")
1865
1866 baseUrl.RawQuery = params.Encode()
1867
1868 // Build HTTP headers from client and context metadata.
1869 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1870
1871 hds = append(c.xGoogHeaders, hds...)
1872 hds = append(hds, "Content-Type", "application/json")
1873 headers := gax.BuildHeaders(ctx, hds...)
1874 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1875 resp := &longrunningpb.Operation{}
1876 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1877 if settings.Path != "" {
1878 baseUrl.Path = settings.Path
1879 }
1880 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1881 if err != nil {
1882 return err
1883 }
1884 httpReq = httpReq.WithContext(ctx)
1885 httpReq.Header = headers
1886
1887 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteDataset")
1888 if err != nil {
1889 return err
1890 }
1891 if err := unm.Unmarshal(buf, resp); err != nil {
1892 return err
1893 }
1894
1895 return nil
1896 }, opts...)
1897 if e != nil {
1898 return nil, e
1899 }
1900
1901 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1902 return &DeleteDatasetOperation{
1903 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1904 pollPath: override,
1905 }, nil
1906 }
1907
1908 // ImportData imports data into a dataset.
1909 // For Tables this method can only be called on an empty Dataset.
1910 //
1911 // For Tables:
1912 //
1913 // A
1914 // schema_inference_version
1915 // parameter must be explicitly set.
1916 // Returns an empty response in the
1917 // response field when it completes.
1918 func (c *restClient) ImportData(ctx context.Context, req *automlpb.ImportDataRequest, opts ...gax.CallOption) (*ImportDataOperation, error) {
1919 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1920 jsonReq, err := m.Marshal(req)
1921 if err != nil {
1922 return nil, err
1923 }
1924
1925 baseUrl, err := url.Parse(c.endpoint)
1926 if err != nil {
1927 return nil, err
1928 }
1929 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:importData", req.GetName())
1930
1931 params := url.Values{}
1932 params.Add("$alt", "json;enum-encoding=int")
1933
1934 baseUrl.RawQuery = params.Encode()
1935
1936 // Build HTTP headers from client and context metadata.
1937 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1938
1939 hds = append(c.xGoogHeaders, hds...)
1940 hds = append(hds, "Content-Type", "application/json")
1941 headers := gax.BuildHeaders(ctx, hds...)
1942 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1943 resp := &longrunningpb.Operation{}
1944 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1945 if settings.Path != "" {
1946 baseUrl.Path = settings.Path
1947 }
1948 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1949 if err != nil {
1950 return err
1951 }
1952 httpReq = httpReq.WithContext(ctx)
1953 httpReq.Header = headers
1954
1955 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ImportData")
1956 if err != nil {
1957 return err
1958 }
1959 if err := unm.Unmarshal(buf, resp); err != nil {
1960 return err
1961 }
1962
1963 return nil
1964 }, opts...)
1965 if e != nil {
1966 return nil, e
1967 }
1968
1969 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1970 return &ImportDataOperation{
1971 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1972 pollPath: override,
1973 }, nil
1974 }
1975
1976 // ExportData exports dataset’s data to the provided output location.
1977 // Returns an empty response in the
1978 // response field when it completes.
1979 func (c *restClient) ExportData(ctx context.Context, req *automlpb.ExportDataRequest, opts ...gax.CallOption) (*ExportDataOperation, error) {
1980 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1981 jsonReq, err := m.Marshal(req)
1982 if err != nil {
1983 return nil, err
1984 }
1985
1986 baseUrl, err := url.Parse(c.endpoint)
1987 if err != nil {
1988 return nil, err
1989 }
1990 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:exportData", req.GetName())
1991
1992 params := url.Values{}
1993 params.Add("$alt", "json;enum-encoding=int")
1994
1995 baseUrl.RawQuery = params.Encode()
1996
1997 // Build HTTP headers from client and context metadata.
1998 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1999
2000 hds = append(c.xGoogHeaders, hds...)
2001 hds = append(hds, "Content-Type", "application/json")
2002 headers := gax.BuildHeaders(ctx, hds...)
2003 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2004 resp := &longrunningpb.Operation{}
2005 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2006 if settings.Path != "" {
2007 baseUrl.Path = settings.Path
2008 }
2009 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2010 if err != nil {
2011 return err
2012 }
2013 httpReq = httpReq.WithContext(ctx)
2014 httpReq.Header = headers
2015
2016 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExportData")
2017 if err != nil {
2018 return err
2019 }
2020 if err := unm.Unmarshal(buf, resp); err != nil {
2021 return err
2022 }
2023
2024 return nil
2025 }, opts...)
2026 if e != nil {
2027 return nil, e
2028 }
2029
2030 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
2031 return &ExportDataOperation{
2032 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2033 pollPath: override,
2034 }, nil
2035 }
2036
2037 // GetAnnotationSpec gets an annotation spec.
2038 func (c *restClient) GetAnnotationSpec(ctx context.Context, req *automlpb.GetAnnotationSpecRequest, opts ...gax.CallOption) (*automlpb.AnnotationSpec, error) {
2039 baseUrl, err := url.Parse(c.endpoint)
2040 if err != nil {
2041 return nil, err
2042 }
2043 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
2044
2045 params := url.Values{}
2046 params.Add("$alt", "json;enum-encoding=int")
2047
2048 baseUrl.RawQuery = params.Encode()
2049
2050 // Build HTTP headers from client and context metadata.
2051 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2052
2053 hds = append(c.xGoogHeaders, hds...)
2054 hds = append(hds, "Content-Type", "application/json")
2055 headers := gax.BuildHeaders(ctx, hds...)
2056 opts = append((*c.CallOptions).GetAnnotationSpec[0:len((*c.CallOptions).GetAnnotationSpec):len((*c.CallOptions).GetAnnotationSpec)], opts...)
2057 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2058 resp := &automlpb.AnnotationSpec{}
2059 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2060 if settings.Path != "" {
2061 baseUrl.Path = settings.Path
2062 }
2063 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2064 if err != nil {
2065 return err
2066 }
2067 httpReq = httpReq.WithContext(ctx)
2068 httpReq.Header = headers
2069
2070 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetAnnotationSpec")
2071 if err != nil {
2072 return err
2073 }
2074
2075 if err := unm.Unmarshal(buf, resp); err != nil {
2076 return err
2077 }
2078
2079 return nil
2080 }, opts...)
2081 if e != nil {
2082 return nil, e
2083 }
2084 return resp, nil
2085 }
2086
2087 // GetTableSpec gets a table spec.
2088 func (c *restClient) GetTableSpec(ctx context.Context, req *automlpb.GetTableSpecRequest, opts ...gax.CallOption) (*automlpb.TableSpec, error) {
2089 baseUrl, err := url.Parse(c.endpoint)
2090 if err != nil {
2091 return nil, err
2092 }
2093 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
2094
2095 params := url.Values{}
2096 params.Add("$alt", "json;enum-encoding=int")
2097 if req.GetFieldMask() != nil {
2098 field, err := protojson.Marshal(req.GetFieldMask())
2099 if err != nil {
2100 return nil, err
2101 }
2102 params.Add("fieldMask", string(field[1:len(field)-1]))
2103 }
2104
2105 baseUrl.RawQuery = params.Encode()
2106
2107 // Build HTTP headers from client and context metadata.
2108 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2109
2110 hds = append(c.xGoogHeaders, hds...)
2111 hds = append(hds, "Content-Type", "application/json")
2112 headers := gax.BuildHeaders(ctx, hds...)
2113 opts = append((*c.CallOptions).GetTableSpec[0:len((*c.CallOptions).GetTableSpec):len((*c.CallOptions).GetTableSpec)], opts...)
2114 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2115 resp := &automlpb.TableSpec{}
2116 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2117 if settings.Path != "" {
2118 baseUrl.Path = settings.Path
2119 }
2120 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2121 if err != nil {
2122 return err
2123 }
2124 httpReq = httpReq.WithContext(ctx)
2125 httpReq.Header = headers
2126
2127 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetTableSpec")
2128 if err != nil {
2129 return err
2130 }
2131
2132 if err := unm.Unmarshal(buf, resp); err != nil {
2133 return err
2134 }
2135
2136 return nil
2137 }, opts...)
2138 if e != nil {
2139 return nil, e
2140 }
2141 return resp, nil
2142 }
2143
2144 // ListTableSpecs lists table specs in a dataset.
2145 func (c *restClient) ListTableSpecs(ctx context.Context, req *automlpb.ListTableSpecsRequest, opts ...gax.CallOption) *TableSpecIterator {
2146 it := &TableSpecIterator{}
2147 req = proto.Clone(req).(*automlpb.ListTableSpecsRequest)
2148 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2149 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.TableSpec, string, error) {
2150 resp := &automlpb.ListTableSpecsResponse{}
2151 if pageToken != "" {
2152 req.PageToken = pageToken
2153 }
2154 if pageSize > math.MaxInt32 {
2155 req.PageSize = math.MaxInt32
2156 } else if pageSize != 0 {
2157 req.PageSize = int32(pageSize)
2158 }
2159 baseUrl, err := url.Parse(c.endpoint)
2160 if err != nil {
2161 return nil, "", err
2162 }
2163 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/tableSpecs", req.GetParent())
2164
2165 params := url.Values{}
2166 params.Add("$alt", "json;enum-encoding=int")
2167 if req.GetFieldMask() != nil {
2168 field, err := protojson.Marshal(req.GetFieldMask())
2169 if err != nil {
2170 return nil, "", err
2171 }
2172 params.Add("fieldMask", string(field[1:len(field)-1]))
2173 }
2174 if req.GetFilter() != "" {
2175 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2176 }
2177 if req.GetPageSize() != 0 {
2178 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2179 }
2180 if req.GetPageToken() != "" {
2181 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2182 }
2183
2184 baseUrl.RawQuery = params.Encode()
2185
2186 // Build HTTP headers from client and context metadata.
2187 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2188 headers := gax.BuildHeaders(ctx, hds...)
2189 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2190 if settings.Path != "" {
2191 baseUrl.Path = settings.Path
2192 }
2193 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2194 if err != nil {
2195 return err
2196 }
2197 httpReq.Header = headers
2198
2199 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListTableSpecs")
2200 if err != nil {
2201 return err
2202 }
2203 if err := unm.Unmarshal(buf, resp); err != nil {
2204 return err
2205 }
2206
2207 return nil
2208 }, opts...)
2209 if e != nil {
2210 return nil, "", e
2211 }
2212 it.Response = resp
2213 return resp.GetTableSpecs(), resp.GetNextPageToken(), nil
2214 }
2215
2216 fetch := func(pageSize int, pageToken string) (string, error) {
2217 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2218 if err != nil {
2219 return "", err
2220 }
2221 it.items = append(it.items, items...)
2222 return nextPageToken, nil
2223 }
2224
2225 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2226 it.pageInfo.MaxSize = int(req.GetPageSize())
2227 it.pageInfo.Token = req.GetPageToken()
2228
2229 return it
2230 }
2231
2232 // UpdateTableSpec updates a table spec.
2233 func (c *restClient) UpdateTableSpec(ctx context.Context, req *automlpb.UpdateTableSpecRequest, opts ...gax.CallOption) (*automlpb.TableSpec, error) {
2234 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2235 body := req.GetTableSpec()
2236 jsonReq, err := m.Marshal(body)
2237 if err != nil {
2238 return nil, err
2239 }
2240
2241 baseUrl, err := url.Parse(c.endpoint)
2242 if err != nil {
2243 return nil, err
2244 }
2245 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetTableSpec().GetName())
2246
2247 params := url.Values{}
2248 params.Add("$alt", "json;enum-encoding=int")
2249 if req.GetUpdateMask() != nil {
2250 field, err := protojson.Marshal(req.GetUpdateMask())
2251 if err != nil {
2252 return nil, err
2253 }
2254 params.Add("updateMask", string(field[1:len(field)-1]))
2255 }
2256
2257 baseUrl.RawQuery = params.Encode()
2258
2259 // Build HTTP headers from client and context metadata.
2260 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "table_spec.name", url.QueryEscape(req.GetTableSpec().GetName()))}
2261
2262 hds = append(c.xGoogHeaders, hds...)
2263 hds = append(hds, "Content-Type", "application/json")
2264 headers := gax.BuildHeaders(ctx, hds...)
2265 opts = append((*c.CallOptions).UpdateTableSpec[0:len((*c.CallOptions).UpdateTableSpec):len((*c.CallOptions).UpdateTableSpec)], opts...)
2266 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2267 resp := &automlpb.TableSpec{}
2268 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2269 if settings.Path != "" {
2270 baseUrl.Path = settings.Path
2271 }
2272 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2273 if err != nil {
2274 return err
2275 }
2276 httpReq = httpReq.WithContext(ctx)
2277 httpReq.Header = headers
2278
2279 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateTableSpec")
2280 if err != nil {
2281 return err
2282 }
2283
2284 if err := unm.Unmarshal(buf, resp); err != nil {
2285 return err
2286 }
2287
2288 return nil
2289 }, opts...)
2290 if e != nil {
2291 return nil, e
2292 }
2293 return resp, nil
2294 }
2295
2296 // GetColumnSpec gets a column spec.
2297 func (c *restClient) GetColumnSpec(ctx context.Context, req *automlpb.GetColumnSpecRequest, opts ...gax.CallOption) (*automlpb.ColumnSpec, error) {
2298 baseUrl, err := url.Parse(c.endpoint)
2299 if err != nil {
2300 return nil, err
2301 }
2302 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
2303
2304 params := url.Values{}
2305 params.Add("$alt", "json;enum-encoding=int")
2306 if req.GetFieldMask() != nil {
2307 field, err := protojson.Marshal(req.GetFieldMask())
2308 if err != nil {
2309 return nil, err
2310 }
2311 params.Add("fieldMask", string(field[1:len(field)-1]))
2312 }
2313
2314 baseUrl.RawQuery = params.Encode()
2315
2316 // Build HTTP headers from client and context metadata.
2317 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2318
2319 hds = append(c.xGoogHeaders, hds...)
2320 hds = append(hds, "Content-Type", "application/json")
2321 headers := gax.BuildHeaders(ctx, hds...)
2322 opts = append((*c.CallOptions).GetColumnSpec[0:len((*c.CallOptions).GetColumnSpec):len((*c.CallOptions).GetColumnSpec)], opts...)
2323 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2324 resp := &automlpb.ColumnSpec{}
2325 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2326 if settings.Path != "" {
2327 baseUrl.Path = settings.Path
2328 }
2329 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2330 if err != nil {
2331 return err
2332 }
2333 httpReq = httpReq.WithContext(ctx)
2334 httpReq.Header = headers
2335
2336 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetColumnSpec")
2337 if err != nil {
2338 return err
2339 }
2340
2341 if err := unm.Unmarshal(buf, resp); err != nil {
2342 return err
2343 }
2344
2345 return nil
2346 }, opts...)
2347 if e != nil {
2348 return nil, e
2349 }
2350 return resp, nil
2351 }
2352
2353 // ListColumnSpecs lists column specs in a table spec.
2354 func (c *restClient) ListColumnSpecs(ctx context.Context, req *automlpb.ListColumnSpecsRequest, opts ...gax.CallOption) *ColumnSpecIterator {
2355 it := &ColumnSpecIterator{}
2356 req = proto.Clone(req).(*automlpb.ListColumnSpecsRequest)
2357 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2358 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.ColumnSpec, string, error) {
2359 resp := &automlpb.ListColumnSpecsResponse{}
2360 if pageToken != "" {
2361 req.PageToken = pageToken
2362 }
2363 if pageSize > math.MaxInt32 {
2364 req.PageSize = math.MaxInt32
2365 } else if pageSize != 0 {
2366 req.PageSize = int32(pageSize)
2367 }
2368 baseUrl, err := url.Parse(c.endpoint)
2369 if err != nil {
2370 return nil, "", err
2371 }
2372 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/columnSpecs", req.GetParent())
2373
2374 params := url.Values{}
2375 params.Add("$alt", "json;enum-encoding=int")
2376 if req.GetFieldMask() != nil {
2377 field, err := protojson.Marshal(req.GetFieldMask())
2378 if err != nil {
2379 return nil, "", err
2380 }
2381 params.Add("fieldMask", string(field[1:len(field)-1]))
2382 }
2383 if req.GetFilter() != "" {
2384 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2385 }
2386 if req.GetPageSize() != 0 {
2387 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2388 }
2389 if req.GetPageToken() != "" {
2390 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2391 }
2392
2393 baseUrl.RawQuery = params.Encode()
2394
2395 // Build HTTP headers from client and context metadata.
2396 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2397 headers := gax.BuildHeaders(ctx, hds...)
2398 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2399 if settings.Path != "" {
2400 baseUrl.Path = settings.Path
2401 }
2402 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2403 if err != nil {
2404 return err
2405 }
2406 httpReq.Header = headers
2407
2408 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListColumnSpecs")
2409 if err != nil {
2410 return err
2411 }
2412 if err := unm.Unmarshal(buf, resp); err != nil {
2413 return err
2414 }
2415
2416 return nil
2417 }, opts...)
2418 if e != nil {
2419 return nil, "", e
2420 }
2421 it.Response = resp
2422 return resp.GetColumnSpecs(), resp.GetNextPageToken(), nil
2423 }
2424
2425 fetch := func(pageSize int, pageToken string) (string, error) {
2426 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2427 if err != nil {
2428 return "", err
2429 }
2430 it.items = append(it.items, items...)
2431 return nextPageToken, nil
2432 }
2433
2434 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2435 it.pageInfo.MaxSize = int(req.GetPageSize())
2436 it.pageInfo.Token = req.GetPageToken()
2437
2438 return it
2439 }
2440
2441 // UpdateColumnSpec updates a column spec.
2442 func (c *restClient) UpdateColumnSpec(ctx context.Context, req *automlpb.UpdateColumnSpecRequest, opts ...gax.CallOption) (*automlpb.ColumnSpec, error) {
2443 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2444 body := req.GetColumnSpec()
2445 jsonReq, err := m.Marshal(body)
2446 if err != nil {
2447 return nil, err
2448 }
2449
2450 baseUrl, err := url.Parse(c.endpoint)
2451 if err != nil {
2452 return nil, err
2453 }
2454 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetColumnSpec().GetName())
2455
2456 params := url.Values{}
2457 params.Add("$alt", "json;enum-encoding=int")
2458 if req.GetUpdateMask() != nil {
2459 field, err := protojson.Marshal(req.GetUpdateMask())
2460 if err != nil {
2461 return nil, err
2462 }
2463 params.Add("updateMask", string(field[1:len(field)-1]))
2464 }
2465
2466 baseUrl.RawQuery = params.Encode()
2467
2468 // Build HTTP headers from client and context metadata.
2469 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "column_spec.name", url.QueryEscape(req.GetColumnSpec().GetName()))}
2470
2471 hds = append(c.xGoogHeaders, hds...)
2472 hds = append(hds, "Content-Type", "application/json")
2473 headers := gax.BuildHeaders(ctx, hds...)
2474 opts = append((*c.CallOptions).UpdateColumnSpec[0:len((*c.CallOptions).UpdateColumnSpec):len((*c.CallOptions).UpdateColumnSpec)], opts...)
2475 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2476 resp := &automlpb.ColumnSpec{}
2477 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2478 if settings.Path != "" {
2479 baseUrl.Path = settings.Path
2480 }
2481 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2482 if err != nil {
2483 return err
2484 }
2485 httpReq = httpReq.WithContext(ctx)
2486 httpReq.Header = headers
2487
2488 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateColumnSpec")
2489 if err != nil {
2490 return err
2491 }
2492
2493 if err := unm.Unmarshal(buf, resp); err != nil {
2494 return err
2495 }
2496
2497 return nil
2498 }, opts...)
2499 if e != nil {
2500 return nil, e
2501 }
2502 return resp, nil
2503 }
2504
2505 // CreateModel creates a model.
2506 // Returns a Model in the response
2507 // field when it completes.
2508 // When you create a model, several model evaluations are created for it:
2509 // a global evaluation, and one evaluation for each annotation spec.
2510 func (c *restClient) CreateModel(ctx context.Context, req *automlpb.CreateModelRequest, opts ...gax.CallOption) (*CreateModelOperation, error) {
2511 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2512 body := req.GetModel()
2513 jsonReq, err := m.Marshal(body)
2514 if err != nil {
2515 return nil, err
2516 }
2517
2518 baseUrl, err := url.Parse(c.endpoint)
2519 if err != nil {
2520 return nil, err
2521 }
2522 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/models", req.GetParent())
2523
2524 params := url.Values{}
2525 params.Add("$alt", "json;enum-encoding=int")
2526
2527 baseUrl.RawQuery = params.Encode()
2528
2529 // Build HTTP headers from client and context metadata.
2530 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2531
2532 hds = append(c.xGoogHeaders, hds...)
2533 hds = append(hds, "Content-Type", "application/json")
2534 headers := gax.BuildHeaders(ctx, hds...)
2535 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2536 resp := &longrunningpb.Operation{}
2537 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2538 if settings.Path != "" {
2539 baseUrl.Path = settings.Path
2540 }
2541 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2542 if err != nil {
2543 return err
2544 }
2545 httpReq = httpReq.WithContext(ctx)
2546 httpReq.Header = headers
2547
2548 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateModel")
2549 if err != nil {
2550 return err
2551 }
2552 if err := unm.Unmarshal(buf, resp); err != nil {
2553 return err
2554 }
2555
2556 return nil
2557 }, opts...)
2558 if e != nil {
2559 return nil, e
2560 }
2561
2562 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
2563 return &CreateModelOperation{
2564 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2565 pollPath: override,
2566 }, nil
2567 }
2568
2569 // GetModel gets a model.
2570 func (c *restClient) GetModel(ctx context.Context, req *automlpb.GetModelRequest, opts ...gax.CallOption) (*automlpb.Model, error) {
2571 baseUrl, err := url.Parse(c.endpoint)
2572 if err != nil {
2573 return nil, err
2574 }
2575 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
2576
2577 params := url.Values{}
2578 params.Add("$alt", "json;enum-encoding=int")
2579
2580 baseUrl.RawQuery = params.Encode()
2581
2582 // Build HTTP headers from client and context metadata.
2583 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2584
2585 hds = append(c.xGoogHeaders, hds...)
2586 hds = append(hds, "Content-Type", "application/json")
2587 headers := gax.BuildHeaders(ctx, hds...)
2588 opts = append((*c.CallOptions).GetModel[0:len((*c.CallOptions).GetModel):len((*c.CallOptions).GetModel)], opts...)
2589 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2590 resp := &automlpb.Model{}
2591 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2592 if settings.Path != "" {
2593 baseUrl.Path = settings.Path
2594 }
2595 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2596 if err != nil {
2597 return err
2598 }
2599 httpReq = httpReq.WithContext(ctx)
2600 httpReq.Header = headers
2601
2602 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetModel")
2603 if err != nil {
2604 return err
2605 }
2606
2607 if err := unm.Unmarshal(buf, resp); err != nil {
2608 return err
2609 }
2610
2611 return nil
2612 }, opts...)
2613 if e != nil {
2614 return nil, e
2615 }
2616 return resp, nil
2617 }
2618
2619 // ListModels lists models.
2620 func (c *restClient) ListModels(ctx context.Context, req *automlpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator {
2621 it := &ModelIterator{}
2622 req = proto.Clone(req).(*automlpb.ListModelsRequest)
2623 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2624 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.Model, string, error) {
2625 resp := &automlpb.ListModelsResponse{}
2626 if pageToken != "" {
2627 req.PageToken = pageToken
2628 }
2629 if pageSize > math.MaxInt32 {
2630 req.PageSize = math.MaxInt32
2631 } else if pageSize != 0 {
2632 req.PageSize = int32(pageSize)
2633 }
2634 baseUrl, err := url.Parse(c.endpoint)
2635 if err != nil {
2636 return nil, "", err
2637 }
2638 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/models", req.GetParent())
2639
2640 params := url.Values{}
2641 params.Add("$alt", "json;enum-encoding=int")
2642 if req.GetFilter() != "" {
2643 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2644 }
2645 if req.GetPageSize() != 0 {
2646 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2647 }
2648 if req.GetPageToken() != "" {
2649 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2650 }
2651
2652 baseUrl.RawQuery = params.Encode()
2653
2654 // Build HTTP headers from client and context metadata.
2655 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2656 headers := gax.BuildHeaders(ctx, hds...)
2657 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2658 if settings.Path != "" {
2659 baseUrl.Path = settings.Path
2660 }
2661 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2662 if err != nil {
2663 return err
2664 }
2665 httpReq.Header = headers
2666
2667 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListModels")
2668 if err != nil {
2669 return err
2670 }
2671 if err := unm.Unmarshal(buf, resp); err != nil {
2672 return err
2673 }
2674
2675 return nil
2676 }, opts...)
2677 if e != nil {
2678 return nil, "", e
2679 }
2680 it.Response = resp
2681 return resp.GetModel(), resp.GetNextPageToken(), nil
2682 }
2683
2684 fetch := func(pageSize int, pageToken string) (string, error) {
2685 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2686 if err != nil {
2687 return "", err
2688 }
2689 it.items = append(it.items, items...)
2690 return nextPageToken, nil
2691 }
2692
2693 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2694 it.pageInfo.MaxSize = int(req.GetPageSize())
2695 it.pageInfo.Token = req.GetPageToken()
2696
2697 return it
2698 }
2699
2700 // DeleteModel deletes a model.
2701 // Returns google.protobuf.Empty in the
2702 // response field when it completes,
2703 // and delete_details in the
2704 // metadata field.
2705 func (c *restClient) DeleteModel(ctx context.Context, req *automlpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error) {
2706 baseUrl, err := url.Parse(c.endpoint)
2707 if err != nil {
2708 return nil, err
2709 }
2710 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
2711
2712 params := url.Values{}
2713 params.Add("$alt", "json;enum-encoding=int")
2714
2715 baseUrl.RawQuery = params.Encode()
2716
2717 // Build HTTP headers from client and context metadata.
2718 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2719
2720 hds = append(c.xGoogHeaders, hds...)
2721 hds = append(hds, "Content-Type", "application/json")
2722 headers := gax.BuildHeaders(ctx, hds...)
2723 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2724 resp := &longrunningpb.Operation{}
2725 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2726 if settings.Path != "" {
2727 baseUrl.Path = settings.Path
2728 }
2729 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2730 if err != nil {
2731 return err
2732 }
2733 httpReq = httpReq.WithContext(ctx)
2734 httpReq.Header = headers
2735
2736 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteModel")
2737 if err != nil {
2738 return err
2739 }
2740 if err := unm.Unmarshal(buf, resp); err != nil {
2741 return err
2742 }
2743
2744 return nil
2745 }, opts...)
2746 if e != nil {
2747 return nil, e
2748 }
2749
2750 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
2751 return &DeleteModelOperation{
2752 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2753 pollPath: override,
2754 }, nil
2755 }
2756
2757 // DeployModel deploys a model. If a model is already deployed, deploying it with the
2758 // same parameters has no effect. Deploying with different parametrs
2759 // (as e.g. changing
2760 //
2761 // node_number)
2762 // will reset the deployment state without pausing the model’s availability.
2763 //
2764 // Only applicable for Text Classification, Image Object Detection , Tables, and Image Segmentation; all other domains manage
2765 // deployment automatically.
2766 //
2767 // Returns an empty response in the
2768 // response field when it completes.
2769 func (c *restClient) DeployModel(ctx context.Context, req *automlpb.DeployModelRequest, opts ...gax.CallOption) (*DeployModelOperation, error) {
2770 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2771 jsonReq, err := m.Marshal(req)
2772 if err != nil {
2773 return nil, err
2774 }
2775
2776 baseUrl, err := url.Parse(c.endpoint)
2777 if err != nil {
2778 return nil, err
2779 }
2780 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:deploy", req.GetName())
2781
2782 params := url.Values{}
2783 params.Add("$alt", "json;enum-encoding=int")
2784
2785 baseUrl.RawQuery = params.Encode()
2786
2787 // Build HTTP headers from client and context metadata.
2788 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2789
2790 hds = append(c.xGoogHeaders, hds...)
2791 hds = append(hds, "Content-Type", "application/json")
2792 headers := gax.BuildHeaders(ctx, hds...)
2793 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2794 resp := &longrunningpb.Operation{}
2795 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2796 if settings.Path != "" {
2797 baseUrl.Path = settings.Path
2798 }
2799 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2800 if err != nil {
2801 return err
2802 }
2803 httpReq = httpReq.WithContext(ctx)
2804 httpReq.Header = headers
2805
2806 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "DeployModel")
2807 if err != nil {
2808 return err
2809 }
2810 if err := unm.Unmarshal(buf, resp); err != nil {
2811 return err
2812 }
2813
2814 return nil
2815 }, opts...)
2816 if e != nil {
2817 return nil, e
2818 }
2819
2820 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
2821 return &DeployModelOperation{
2822 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2823 pollPath: override,
2824 }, nil
2825 }
2826
2827 // UndeployModel undeploys a model. If the model is not deployed this method has no effect.
2828 //
2829 // Only applicable for Text Classification, Image Object Detection and Tables;
2830 // all other domains manage deployment automatically.
2831 //
2832 // Returns an empty response in the
2833 // response field when it completes.
2834 func (c *restClient) UndeployModel(ctx context.Context, req *automlpb.UndeployModelRequest, opts ...gax.CallOption) (*UndeployModelOperation, error) {
2835 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2836 jsonReq, err := m.Marshal(req)
2837 if err != nil {
2838 return nil, err
2839 }
2840
2841 baseUrl, err := url.Parse(c.endpoint)
2842 if err != nil {
2843 return nil, err
2844 }
2845 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:undeploy", req.GetName())
2846
2847 params := url.Values{}
2848 params.Add("$alt", "json;enum-encoding=int")
2849
2850 baseUrl.RawQuery = params.Encode()
2851
2852 // Build HTTP headers from client and context metadata.
2853 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2854
2855 hds = append(c.xGoogHeaders, hds...)
2856 hds = append(hds, "Content-Type", "application/json")
2857 headers := gax.BuildHeaders(ctx, hds...)
2858 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2859 resp := &longrunningpb.Operation{}
2860 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2861 if settings.Path != "" {
2862 baseUrl.Path = settings.Path
2863 }
2864 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2865 if err != nil {
2866 return err
2867 }
2868 httpReq = httpReq.WithContext(ctx)
2869 httpReq.Header = headers
2870
2871 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UndeployModel")
2872 if err != nil {
2873 return err
2874 }
2875 if err := unm.Unmarshal(buf, resp); err != nil {
2876 return err
2877 }
2878
2879 return nil
2880 }, opts...)
2881 if e != nil {
2882 return nil, e
2883 }
2884
2885 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
2886 return &UndeployModelOperation{
2887 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2888 pollPath: override,
2889 }, nil
2890 }
2891
2892 // ExportModel exports a trained, “export-able”, model to a user specified Google Cloud
2893 // Storage location. A model is considered export-able if and only if it has
2894 // an export format defined for it in
2895 //
2896 // ModelExportOutputConfig.
2897 //
2898 // Returns an empty response in the
2899 // response field when it completes.
2900 func (c *restClient) ExportModel(ctx context.Context, req *automlpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error) {
2901 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2902 jsonReq, err := m.Marshal(req)
2903 if err != nil {
2904 return nil, err
2905 }
2906
2907 baseUrl, err := url.Parse(c.endpoint)
2908 if err != nil {
2909 return nil, err
2910 }
2911 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:export", req.GetName())
2912
2913 params := url.Values{}
2914 params.Add("$alt", "json;enum-encoding=int")
2915
2916 baseUrl.RawQuery = params.Encode()
2917
2918 // Build HTTP headers from client and context metadata.
2919 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2920
2921 hds = append(c.xGoogHeaders, hds...)
2922 hds = append(hds, "Content-Type", "application/json")
2923 headers := gax.BuildHeaders(ctx, hds...)
2924 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2925 resp := &longrunningpb.Operation{}
2926 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2927 if settings.Path != "" {
2928 baseUrl.Path = settings.Path
2929 }
2930 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2931 if err != nil {
2932 return err
2933 }
2934 httpReq = httpReq.WithContext(ctx)
2935 httpReq.Header = headers
2936
2937 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExportModel")
2938 if err != nil {
2939 return err
2940 }
2941 if err := unm.Unmarshal(buf, resp); err != nil {
2942 return err
2943 }
2944
2945 return nil
2946 }, opts...)
2947 if e != nil {
2948 return nil, e
2949 }
2950
2951 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
2952 return &ExportModelOperation{
2953 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2954 pollPath: override,
2955 }, nil
2956 }
2957
2958 // ExportEvaluatedExamples exports examples on which the model was evaluated (i.e. which were in the
2959 // TEST set of the dataset the model was created from), together with their
2960 // ground truth annotations and the annotations created (predicted) by the
2961 // model.
2962 // The examples, ground truth and predictions are exported in the state
2963 // they were at the moment the model was evaluated.
2964 //
2965 // This export is available only for 30 days since the model evaluation is
2966 // created.
2967 //
2968 // Currently only available for Tables.
2969 //
2970 // Returns an empty response in the
2971 // response field when it completes.
2972 func (c *restClient) ExportEvaluatedExamples(ctx context.Context, req *automlpb.ExportEvaluatedExamplesRequest, opts ...gax.CallOption) (*ExportEvaluatedExamplesOperation, error) {
2973 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2974 jsonReq, err := m.Marshal(req)
2975 if err != nil {
2976 return nil, err
2977 }
2978
2979 baseUrl, err := url.Parse(c.endpoint)
2980 if err != nil {
2981 return nil, err
2982 }
2983 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:exportEvaluatedExamples", req.GetName())
2984
2985 params := url.Values{}
2986 params.Add("$alt", "json;enum-encoding=int")
2987
2988 baseUrl.RawQuery = params.Encode()
2989
2990 // Build HTTP headers from client and context metadata.
2991 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2992
2993 hds = append(c.xGoogHeaders, hds...)
2994 hds = append(hds, "Content-Type", "application/json")
2995 headers := gax.BuildHeaders(ctx, hds...)
2996 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2997 resp := &longrunningpb.Operation{}
2998 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2999 if settings.Path != "" {
3000 baseUrl.Path = settings.Path
3001 }
3002 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3003 if err != nil {
3004 return err
3005 }
3006 httpReq = httpReq.WithContext(ctx)
3007 httpReq.Header = headers
3008
3009 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExportEvaluatedExamples")
3010 if err != nil {
3011 return err
3012 }
3013 if err := unm.Unmarshal(buf, resp); err != nil {
3014 return err
3015 }
3016
3017 return nil
3018 }, opts...)
3019 if e != nil {
3020 return nil, e
3021 }
3022
3023 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
3024 return &ExportEvaluatedExamplesOperation{
3025 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3026 pollPath: override,
3027 }, nil
3028 }
3029
3030 // GetModelEvaluation gets a model evaluation.
3031 func (c *restClient) GetModelEvaluation(ctx context.Context, req *automlpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*automlpb.ModelEvaluation, error) {
3032 baseUrl, err := url.Parse(c.endpoint)
3033 if err != nil {
3034 return nil, err
3035 }
3036 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
3037
3038 params := url.Values{}
3039 params.Add("$alt", "json;enum-encoding=int")
3040
3041 baseUrl.RawQuery = params.Encode()
3042
3043 // Build HTTP headers from client and context metadata.
3044 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3045
3046 hds = append(c.xGoogHeaders, hds...)
3047 hds = append(hds, "Content-Type", "application/json")
3048 headers := gax.BuildHeaders(ctx, hds...)
3049 opts = append((*c.CallOptions).GetModelEvaluation[0:len((*c.CallOptions).GetModelEvaluation):len((*c.CallOptions).GetModelEvaluation)], opts...)
3050 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3051 resp := &automlpb.ModelEvaluation{}
3052 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3053 if settings.Path != "" {
3054 baseUrl.Path = settings.Path
3055 }
3056 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3057 if err != nil {
3058 return err
3059 }
3060 httpReq = httpReq.WithContext(ctx)
3061 httpReq.Header = headers
3062
3063 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetModelEvaluation")
3064 if err != nil {
3065 return err
3066 }
3067
3068 if err := unm.Unmarshal(buf, resp); err != nil {
3069 return err
3070 }
3071
3072 return nil
3073 }, opts...)
3074 if e != nil {
3075 return nil, e
3076 }
3077 return resp, nil
3078 }
3079
3080 // ListModelEvaluations lists model evaluations.
3081 func (c *restClient) ListModelEvaluations(ctx context.Context, req *automlpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator {
3082 it := &ModelEvaluationIterator{}
3083 req = proto.Clone(req).(*automlpb.ListModelEvaluationsRequest)
3084 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3085 it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.ModelEvaluation, string, error) {
3086 resp := &automlpb.ListModelEvaluationsResponse{}
3087 if pageToken != "" {
3088 req.PageToken = pageToken
3089 }
3090 if pageSize > math.MaxInt32 {
3091 req.PageSize = math.MaxInt32
3092 } else if pageSize != 0 {
3093 req.PageSize = int32(pageSize)
3094 }
3095 baseUrl, err := url.Parse(c.endpoint)
3096 if err != nil {
3097 return nil, "", err
3098 }
3099 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/modelEvaluations", req.GetParent())
3100
3101 params := url.Values{}
3102 params.Add("$alt", "json;enum-encoding=int")
3103 if req.GetFilter() != "" {
3104 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3105 }
3106 if req.GetPageSize() != 0 {
3107 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3108 }
3109 if req.GetPageToken() != "" {
3110 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3111 }
3112
3113 baseUrl.RawQuery = params.Encode()
3114
3115 // Build HTTP headers from client and context metadata.
3116 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3117 headers := gax.BuildHeaders(ctx, hds...)
3118 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3119 if settings.Path != "" {
3120 baseUrl.Path = settings.Path
3121 }
3122 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3123 if err != nil {
3124 return err
3125 }
3126 httpReq.Header = headers
3127
3128 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListModelEvaluations")
3129 if err != nil {
3130 return err
3131 }
3132 if err := unm.Unmarshal(buf, resp); err != nil {
3133 return err
3134 }
3135
3136 return nil
3137 }, opts...)
3138 if e != nil {
3139 return nil, "", e
3140 }
3141 it.Response = resp
3142 return resp.GetModelEvaluation(), resp.GetNextPageToken(), nil
3143 }
3144
3145 fetch := func(pageSize int, pageToken string) (string, error) {
3146 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3147 if err != nil {
3148 return "", err
3149 }
3150 it.items = append(it.items, items...)
3151 return nextPageToken, nil
3152 }
3153
3154 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3155 it.pageInfo.MaxSize = int(req.GetPageSize())
3156 it.pageInfo.Token = req.GetPageToken()
3157
3158 return it
3159 }
3160
3161 // CreateModelOperation returns a new CreateModelOperation from a given name.
3162 // The name must be that of a previously created CreateModelOperation, possibly from a different process.
3163 func (c *gRPCClient) CreateModelOperation(name string) *CreateModelOperation {
3164 return &CreateModelOperation{
3165 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3166 }
3167 }
3168
3169 // CreateModelOperation returns a new CreateModelOperation from a given name.
3170 // The name must be that of a previously created CreateModelOperation, possibly from a different process.
3171 func (c *restClient) CreateModelOperation(name string) *CreateModelOperation {
3172 override := fmt.Sprintf("/v1beta1/%s", name)
3173 return &CreateModelOperation{
3174 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3175 pollPath: override,
3176 }
3177 }
3178
3179 // DeleteDatasetOperation returns a new DeleteDatasetOperation from a given name.
3180 // The name must be that of a previously created DeleteDatasetOperation, possibly from a different process.
3181 func (c *gRPCClient) DeleteDatasetOperation(name string) *DeleteDatasetOperation {
3182 return &DeleteDatasetOperation{
3183 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3184 }
3185 }
3186
3187 // DeleteDatasetOperation returns a new DeleteDatasetOperation from a given name.
3188 // The name must be that of a previously created DeleteDatasetOperation, possibly from a different process.
3189 func (c *restClient) DeleteDatasetOperation(name string) *DeleteDatasetOperation {
3190 override := fmt.Sprintf("/v1beta1/%s", name)
3191 return &DeleteDatasetOperation{
3192 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3193 pollPath: override,
3194 }
3195 }
3196
3197 // DeleteModelOperation returns a new DeleteModelOperation from a given name.
3198 // The name must be that of a previously created DeleteModelOperation, possibly from a different process.
3199 func (c *gRPCClient) DeleteModelOperation(name string) *DeleteModelOperation {
3200 return &DeleteModelOperation{
3201 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3202 }
3203 }
3204
3205 // DeleteModelOperation returns a new DeleteModelOperation from a given name.
3206 // The name must be that of a previously created DeleteModelOperation, possibly from a different process.
3207 func (c *restClient) DeleteModelOperation(name string) *DeleteModelOperation {
3208 override := fmt.Sprintf("/v1beta1/%s", name)
3209 return &DeleteModelOperation{
3210 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3211 pollPath: override,
3212 }
3213 }
3214
3215 // DeployModelOperation returns a new DeployModelOperation from a given name.
3216 // The name must be that of a previously created DeployModelOperation, possibly from a different process.
3217 func (c *gRPCClient) DeployModelOperation(name string) *DeployModelOperation {
3218 return &DeployModelOperation{
3219 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3220 }
3221 }
3222
3223 // DeployModelOperation returns a new DeployModelOperation from a given name.
3224 // The name must be that of a previously created DeployModelOperation, possibly from a different process.
3225 func (c *restClient) DeployModelOperation(name string) *DeployModelOperation {
3226 override := fmt.Sprintf("/v1beta1/%s", name)
3227 return &DeployModelOperation{
3228 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3229 pollPath: override,
3230 }
3231 }
3232
3233 // ExportDataOperation returns a new ExportDataOperation from a given name.
3234 // The name must be that of a previously created ExportDataOperation, possibly from a different process.
3235 func (c *gRPCClient) ExportDataOperation(name string) *ExportDataOperation {
3236 return &ExportDataOperation{
3237 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3238 }
3239 }
3240
3241 // ExportDataOperation returns a new ExportDataOperation from a given name.
3242 // The name must be that of a previously created ExportDataOperation, possibly from a different process.
3243 func (c *restClient) ExportDataOperation(name string) *ExportDataOperation {
3244 override := fmt.Sprintf("/v1beta1/%s", name)
3245 return &ExportDataOperation{
3246 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3247 pollPath: override,
3248 }
3249 }
3250
3251 // ExportEvaluatedExamplesOperation returns a new ExportEvaluatedExamplesOperation from a given name.
3252 // The name must be that of a previously created ExportEvaluatedExamplesOperation, possibly from a different process.
3253 func (c *gRPCClient) ExportEvaluatedExamplesOperation(name string) *ExportEvaluatedExamplesOperation {
3254 return &ExportEvaluatedExamplesOperation{
3255 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3256 }
3257 }
3258
3259 // ExportEvaluatedExamplesOperation returns a new ExportEvaluatedExamplesOperation from a given name.
3260 // The name must be that of a previously created ExportEvaluatedExamplesOperation, possibly from a different process.
3261 func (c *restClient) ExportEvaluatedExamplesOperation(name string) *ExportEvaluatedExamplesOperation {
3262 override := fmt.Sprintf("/v1beta1/%s", name)
3263 return &ExportEvaluatedExamplesOperation{
3264 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3265 pollPath: override,
3266 }
3267 }
3268
3269 // ExportModelOperation returns a new ExportModelOperation from a given name.
3270 // The name must be that of a previously created ExportModelOperation, possibly from a different process.
3271 func (c *gRPCClient) ExportModelOperation(name string) *ExportModelOperation {
3272 return &ExportModelOperation{
3273 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3274 }
3275 }
3276
3277 // ExportModelOperation returns a new ExportModelOperation from a given name.
3278 // The name must be that of a previously created ExportModelOperation, possibly from a different process.
3279 func (c *restClient) ExportModelOperation(name string) *ExportModelOperation {
3280 override := fmt.Sprintf("/v1beta1/%s", name)
3281 return &ExportModelOperation{
3282 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3283 pollPath: override,
3284 }
3285 }
3286
3287 // ImportDataOperation returns a new ImportDataOperation from a given name.
3288 // The name must be that of a previously created ImportDataOperation, possibly from a different process.
3289 func (c *gRPCClient) ImportDataOperation(name string) *ImportDataOperation {
3290 return &ImportDataOperation{
3291 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3292 }
3293 }
3294
3295 // ImportDataOperation returns a new ImportDataOperation from a given name.
3296 // The name must be that of a previously created ImportDataOperation, possibly from a different process.
3297 func (c *restClient) ImportDataOperation(name string) *ImportDataOperation {
3298 override := fmt.Sprintf("/v1beta1/%s", name)
3299 return &ImportDataOperation{
3300 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3301 pollPath: override,
3302 }
3303 }
3304
3305 // UndeployModelOperation returns a new UndeployModelOperation from a given name.
3306 // The name must be that of a previously created UndeployModelOperation, possibly from a different process.
3307 func (c *gRPCClient) UndeployModelOperation(name string) *UndeployModelOperation {
3308 return &UndeployModelOperation{
3309 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3310 }
3311 }
3312
3313 // UndeployModelOperation returns a new UndeployModelOperation from a given name.
3314 // The name must be that of a previously created UndeployModelOperation, possibly from a different process.
3315 func (c *restClient) UndeployModelOperation(name string) *UndeployModelOperation {
3316 override := fmt.Sprintf("/v1beta1/%s", name)
3317 return &UndeployModelOperation{
3318 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3319 pollPath: override,
3320 }
3321 }