Debian Codegraph @

automl/apiv1/prediction_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/apiv1/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/option"
35 "google.golang.org/api/option/internaloption"
36 gtransport "google.golang.org/api/transport/grpc"
37 httptransport "google.golang.org/api/transport/http"
38 "google.golang.org/grpc"
39 "google.golang.org/protobuf/encoding/protojson"
40 )
41
42 var newPredictionClientHook clientHook
43
44 // PredictionCallOptions contains the retry settings for each method of PredictionClient.
45 type PredictionCallOptions struct {
46 Predict []gax.CallOption
47 BatchPredict []gax.CallOption
48 }
49
50 func defaultPredictionGRPCClientOptions() []option.ClientOption {
51 return []option.ClientOption{
52 internaloption.WithDefaultEndpoint("automl.googleapis.com:443"),
53 internaloption.WithDefaultEndpointTemplate("automl.UNIVERSE_DOMAIN:443"),
54 internaloption.WithDefaultMTLSEndpoint("automl.mtls.googleapis.com:443"),
55 internaloption.WithDefaultUniverseDomain("googleapis.com"),
56 internaloption.WithDefaultAudience("https://automl.googleapis.com/"),
57 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
58 internaloption.EnableJwtWithScope(),
59 internaloption.EnableNewAuthLibrary(),
60 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
61 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
62 }
63 }
64
65 func defaultPredictionCallOptions() *PredictionCallOptions {
66 return &PredictionCallOptions{
67 Predict: []gax.CallOption{
68 gax.WithTimeout(60000 * time.Millisecond),
69 },
70 BatchPredict: []gax.CallOption{
71 gax.WithTimeout(60000 * time.Millisecond),
72 },
73 }
74 }
75
76 func defaultPredictionRESTCallOptions() *PredictionCallOptions {
77 return &PredictionCallOptions{
78 Predict: []gax.CallOption{
79 gax.WithTimeout(60000 * time.Millisecond),
80 },
81 BatchPredict: []gax.CallOption{
82 gax.WithTimeout(60000 * time.Millisecond),
83 },
84 }
85 }
86
87 // internalPredictionClient is an interface that defines the methods available from Cloud AutoML API.
88 type internalPredictionClient interface {
89 Close() error
90 setGoogleClientInfo(...string)
91 Connection() *grpc.ClientConn
92 Predict(context.Context, *automlpb.PredictRequest, ...gax.CallOption) (*automlpb.PredictResponse, error)
93 BatchPredict(context.Context, *automlpb.BatchPredictRequest, ...gax.CallOption) (*BatchPredictOperation, error)
94 BatchPredictOperation(name string) *BatchPredictOperation
95 }
96
97 // PredictionClient is a client for interacting with Cloud AutoML API.
98 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
99 //
100 // AutoML Prediction API.
101 //
102 // On any input that is documented to expect a string parameter in
103 // snake_case or dash-case, either of those cases is accepted.
104 type PredictionClient struct {
105 // The internal transport-dependent client.
106 internalClient internalPredictionClient
107
108 // The call options for this service.
109 CallOptions *PredictionCallOptions
110
111 // LROClient is used internally to handle long-running operations.
112 // It is exposed so that its CallOptions can be modified if required.
113 // Users should not Close this client.
114 LROClient *lroauto.OperationsClient
115 }
116
117 // Wrapper methods routed to the internal client.
118
119 // Close closes the connection to the API service. The user should invoke this when
120 // the client is no longer required.
121 func (c *PredictionClient) Close() error {
122 return c.internalClient.Close()
123 }
124
125 // setGoogleClientInfo sets the name and version of the application in
126 // the `x-goog-api-client` header passed on each request. Intended for
127 // use by Google-written clients.
128 func (c *PredictionClient) setGoogleClientInfo(keyval ...string) {
129 c.internalClient.setGoogleClientInfo(keyval...)
130 }
131
132 // Connection returns a connection to the API service.
133 //
134 // Deprecated: Connections are now pooled so this method does not always
135 // return the same resource.
136 func (c *PredictionClient) Connection() *grpc.ClientConn {
137 return c.internalClient.Connection()
138 }
139
140 // Predict perform an online prediction. The prediction result is directly
141 // returned in the response.
142 // Available for following ML scenarios, and their expected request payloads:
143 //
144 // AutoML Vision Classification
145 //
146 // An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.
147 //
148 // AutoML Vision Object Detection
149 //
150 // An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.
151 //
152 // AutoML Natural Language Classification
153 //
154 // A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in
155 // .PDF, .TIF or .TIFF format with size upto 2MB.
156 //
157 // AutoML Natural Language Entity Extraction
158 //
159 // A TextSnippet up to 10,000 characters, UTF-8 NFC encoded or a document
160 // in .PDF, .TIF or .TIFF format with size upto 20MB.
161 //
162 // AutoML Natural Language Sentiment Analysis
163 //
164 // A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in
165 // .PDF, .TIF or .TIFF format with size upto 2MB.
166 //
167 // AutoML Translation
168 //
169 // A TextSnippet up to 25,000 characters, UTF-8 encoded.
170 //
171 // AutoML Tables
172 //
173 // A row with column values matching
174 // the columns of the model, up to 5MB. Not available for FORECASTING
175 // prediction_type.
176 func (c *PredictionClient) Predict(ctx context.Context, req *automlpb.PredictRequest, opts ...gax.CallOption) (*automlpb.PredictResponse, error) {
177 return c.internalClient.Predict(ctx, req, opts...)
178 }
179
180 // BatchPredict perform a batch prediction. Unlike the online Predict, batch
181 // prediction result won’t be immediately available in the response. Instead,
182 // a long running operation object is returned. User can poll the operation
183 // result via GetOperation
184 // method. Once the operation is done, BatchPredictResult is returned in
185 // the response field.
186 // Available for following ML scenarios:
187 //
188 // AutoML Vision Classification
189 //
190 // AutoML Vision Object Detection
191 //
192 // AutoML Video Intelligence Classification
193 //
194 // AutoML Video Intelligence Object Tracking * AutoML Natural Language Classification
195 //
196 // AutoML Natural Language Entity Extraction
197 //
198 // AutoML Natural Language Sentiment Analysis
199 //
200 // AutoML Tables
201 func (c *PredictionClient) BatchPredict(ctx context.Context, req *automlpb.BatchPredictRequest, opts ...gax.CallOption) (*BatchPredictOperation, error) {
202 return c.internalClient.BatchPredict(ctx, req, opts...)
203 }
204
205 // BatchPredictOperation returns a new BatchPredictOperation from a given name.
206 // The name must be that of a previously created BatchPredictOperation, possibly from a different process.
207 func (c *PredictionClient) BatchPredictOperation(name string) *BatchPredictOperation {
208 return c.internalClient.BatchPredictOperation(name)
209 }
210
211 // predictionGRPCClient is a client for interacting with Cloud AutoML API over gRPC transport.
212 //
213 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
214 type predictionGRPCClient struct {
215 // Connection pool of gRPC connections to the service.
216 connPool gtransport.ConnPool
217
218 // Points back to the CallOptions field of the containing PredictionClient
219 CallOptions **PredictionCallOptions
220
221 // The gRPC API client.
222 predictionClient automlpb.PredictionServiceClient
223
224 // LROClient is used internally to handle long-running operations.
225 // It is exposed so that its CallOptions can be modified if required.
226 // Users should not Close this client.
227 LROClient **lroauto.OperationsClient
228
229 // The x-goog-* metadata to be sent with each request.
230 xGoogHeaders []string
231
232 logger *slog.Logger
233 }
234
235 // NewPredictionClient creates a new prediction service client based on gRPC.
236 // The returned client must be Closed when it is done being used to clean up its underlying connections.
237 //
238 // AutoML Prediction API.
239 //
240 // On any input that is documented to expect a string parameter in
241 // snake_case or dash-case, either of those cases is accepted.
242 func NewPredictionClient(ctx context.Context, opts ...option.ClientOption) (*PredictionClient, error) {
243 clientOpts := defaultPredictionGRPCClientOptions()
244 if newPredictionClientHook != nil {
245 hookOpts, err := newPredictionClientHook(ctx, clientHookParams{})
246 if err != nil {
247 return nil, err
248 }
249 clientOpts = append(clientOpts, hookOpts...)
250 }
251
252 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
253 if err != nil {
254 return nil, err
255 }
256 client := PredictionClient{CallOptions: defaultPredictionCallOptions()}
257
258 c := &predictionGRPCClient{
259 connPool: connPool,
260 predictionClient: automlpb.NewPredictionServiceClient(connPool),
261 CallOptions: &client.CallOptions,
262 logger: internaloption.GetLogger(opts),
263 }
264 c.setGoogleClientInfo()
265
266 client.internalClient = c
267
268 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
269 if err != nil {
270 // This error "should not happen", since we are just reusing old connection pool
271 // and never actually need to dial.
272 // If this does happen, we could leak connp. However, we cannot close conn:
273 // If the user invoked the constructor with option.WithGRPCConn,
274 // we would close a connection that's still in use.
275 // TODO: investigate error conditions.
276 return nil, err
277 }
278 c.LROClient = &client.LROClient
279 return &client, nil
280 }
281
282 // Connection returns a connection to the API service.
283 //
284 // Deprecated: Connections are now pooled so this method does not always
285 // return the same resource.
286 func (c *predictionGRPCClient) Connection() *grpc.ClientConn {
287 return c.connPool.Conn()
288 }
289
290 // setGoogleClientInfo sets the name and version of the application in
291 // the `x-goog-api-client` header passed on each request. Intended for
292 // use by Google-written clients.
293 func (c *predictionGRPCClient) setGoogleClientInfo(keyval ...string) {
294 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
295 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
296 c.xGoogHeaders = []string{
297 "x-goog-api-client", gax.XGoogHeader(kv...),
298 }
299 }
300
301 // Close closes the connection to the API service. The user should invoke this when
302 // the client is no longer required.
303 func (c *predictionGRPCClient) Close() error {
304 return c.connPool.Close()
305 }
306
307 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
308 type predictionRESTClient struct {
309 // The http endpoint to connect to.
310 endpoint string
311
312 // The http client.
313 httpClient *http.Client
314
315 // LROClient is used internally to handle long-running operations.
316 // It is exposed so that its CallOptions can be modified if required.
317 // Users should not Close this client.
318 LROClient **lroauto.OperationsClient
319
320 // The x-goog-* headers to be sent with each request.
321 xGoogHeaders []string
322
323 // Points back to the CallOptions field of the containing PredictionClient
324 CallOptions **PredictionCallOptions
325
326 logger *slog.Logger
327 }
328
329 // NewPredictionRESTClient creates a new prediction service rest client.
330 //
331 // AutoML Prediction API.
332 //
333 // On any input that is documented to expect a string parameter in
334 // snake_case or dash-case, either of those cases is accepted.
335 func NewPredictionRESTClient(ctx context.Context, opts ...option.ClientOption) (*PredictionClient, error) {
336 clientOpts := append(defaultPredictionRESTClientOptions(), opts...)
337 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
338 if err != nil {
339 return nil, err
340 }
341
342 callOpts := defaultPredictionRESTCallOptions()
343 c := &predictionRESTClient{
344 endpoint: endpoint,
345 httpClient: httpClient,
346 CallOptions: &callOpts,
347 logger: internaloption.GetLogger(opts),
348 }
349 c.setGoogleClientInfo()
350
351 lroOpts := []option.ClientOption{
352 option.WithHTTPClient(httpClient),
353 option.WithEndpoint(endpoint),
354 }
355 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
356 if err != nil {
357 return nil, err
358 }
359 c.LROClient = &opClient
360
361 return &PredictionClient{internalClient: c, CallOptions: callOpts}, nil
362 }
363
364 func defaultPredictionRESTClientOptions() []option.ClientOption {
365 return []option.ClientOption{
366 internaloption.WithDefaultEndpoint("https://automl.googleapis.com"),
367 internaloption.WithDefaultEndpointTemplate("https://automl.UNIVERSE_DOMAIN"),
368 internaloption.WithDefaultMTLSEndpoint("https://automl.mtls.googleapis.com"),
369 internaloption.WithDefaultUniverseDomain("googleapis.com"),
370 internaloption.WithDefaultAudience("https://automl.googleapis.com/"),
371 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
372 internaloption.EnableNewAuthLibrary(),
373 }
374 }
375
376 // setGoogleClientInfo sets the name and version of the application in
377 // the `x-goog-api-client` header passed on each request. Intended for
378 // use by Google-written clients.
379 func (c *predictionRESTClient) setGoogleClientInfo(keyval ...string) {
380 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
381 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
382 c.xGoogHeaders = []string{
383 "x-goog-api-client", gax.XGoogHeader(kv...),
384 }
385 }
386
387 // Close closes the connection to the API service. The user should invoke this when
388 // the client is no longer required.
389 func (c *predictionRESTClient) Close() error {
390 // Replace httpClient with nil to force cleanup.
391 c.httpClient = nil
392 return nil
393 }
394
395 // Connection returns a connection to the API service.
396 //
397 // Deprecated: This method always returns nil.
398 func (c *predictionRESTClient) Connection() *grpc.ClientConn {
399 return nil
400 }
401 func (c *predictionGRPCClient) Predict(ctx context.Context, req *automlpb.PredictRequest, opts ...gax.CallOption) (*automlpb.PredictResponse, error) {
402 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
403
404 hds = append(c.xGoogHeaders, hds...)
405 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
406 opts = append((*c.CallOptions).Predict[0:len((*c.CallOptions).Predict):len((*c.CallOptions).Predict)], opts...)
407 var resp *automlpb.PredictResponse
408 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
409 var err error
410 resp, err = executeRPC(ctx, c.predictionClient.Predict, req, settings.GRPC, c.logger, "Predict")
411 return err
412 }, opts...)
413 if err != nil {
414 return nil, err
415 }
416 return resp, nil
417 }
418
419 func (c *predictionGRPCClient) BatchPredict(ctx context.Context, req *automlpb.BatchPredictRequest, opts ...gax.CallOption) (*BatchPredictOperation, error) {
420 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
421
422 hds = append(c.xGoogHeaders, hds...)
423 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
424 opts = append((*c.CallOptions).BatchPredict[0:len((*c.CallOptions).BatchPredict):len((*c.CallOptions).BatchPredict)], opts...)
425 var resp *longrunningpb.Operation
426 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
427 var err error
428 resp, err = executeRPC(ctx, c.predictionClient.BatchPredict, req, settings.GRPC, c.logger, "BatchPredict")
429 return err
430 }, opts...)
431 if err != nil {
432 return nil, err
433 }
434 return &BatchPredictOperation{
435 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
436 }, nil
437 }
438
439 // Predict perform an online prediction. The prediction result is directly
440 // returned in the response.
441 // Available for following ML scenarios, and their expected request payloads:
442 //
443 // AutoML Vision Classification
444 //
445 // An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.
446 //
447 // AutoML Vision Object Detection
448 //
449 // An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.
450 //
451 // AutoML Natural Language Classification
452 //
453 // A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in
454 // .PDF, .TIF or .TIFF format with size upto 2MB.
455 //
456 // AutoML Natural Language Entity Extraction
457 //
458 // A TextSnippet up to 10,000 characters, UTF-8 NFC encoded or a document
459 // in .PDF, .TIF or .TIFF format with size upto 20MB.
460 //
461 // AutoML Natural Language Sentiment Analysis
462 //
463 // A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in
464 // .PDF, .TIF or .TIFF format with size upto 2MB.
465 //
466 // AutoML Translation
467 //
468 // A TextSnippet up to 25,000 characters, UTF-8 encoded.
469 //
470 // AutoML Tables
471 //
472 // A row with column values matching
473 // the columns of the model, up to 5MB. Not available for FORECASTING
474 // prediction_type.
475 func (c *predictionRESTClient) Predict(ctx context.Context, req *automlpb.PredictRequest, opts ...gax.CallOption) (*automlpb.PredictResponse, error) {
476 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
477 jsonReq, err := m.Marshal(req)
478 if err != nil {
479 return nil, err
480 }
481
482 baseUrl, err := url.Parse(c.endpoint)
483 if err != nil {
484 return nil, err
485 }
486 baseUrl.Path += fmt.Sprintf("/v1/%v:predict", req.GetName())
487
488 params := url.Values{}
489 params.Add("$alt", "json;enum-encoding=int")
490
491 baseUrl.RawQuery = params.Encode()
492
493 // Build HTTP headers from client and context metadata.
494 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
495
496 hds = append(c.xGoogHeaders, hds...)
497 hds = append(hds, "Content-Type", "application/json")
498 headers := gax.BuildHeaders(ctx, hds...)
499 opts = append((*c.CallOptions).Predict[0:len((*c.CallOptions).Predict):len((*c.CallOptions).Predict)], opts...)
500 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
501 resp := &automlpb.PredictResponse{}
502 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
503 if settings.Path != "" {
504 baseUrl.Path = settings.Path
505 }
506 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
507 if err != nil {
508 return err
509 }
510 httpReq = httpReq.WithContext(ctx)
511 httpReq.Header = headers
512
513 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "Predict")
514 if err != nil {
515 return err
516 }
517
518 if err := unm.Unmarshal(buf, resp); err != nil {
519 return err
520 }
521
522 return nil
523 }, opts...)
524 if e != nil {
525 return nil, e
526 }
527 return resp, nil
528 }
529
530 // BatchPredict perform a batch prediction. Unlike the online Predict, batch
531 // prediction result won’t be immediately available in the response. Instead,
532 // a long running operation object is returned. User can poll the operation
533 // result via GetOperation
534 // method. Once the operation is done, BatchPredictResult is returned in
535 // the response field.
536 // Available for following ML scenarios:
537 //
538 // AutoML Vision Classification
539 //
540 // AutoML Vision Object Detection
541 //
542 // AutoML Video Intelligence Classification
543 //
544 // AutoML Video Intelligence Object Tracking * AutoML Natural Language Classification
545 //
546 // AutoML Natural Language Entity Extraction
547 //
548 // AutoML Natural Language Sentiment Analysis
549 //
550 // AutoML Tables
551 func (c *predictionRESTClient) BatchPredict(ctx context.Context, req *automlpb.BatchPredictRequest, opts ...gax.CallOption) (*BatchPredictOperation, error) {
552 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
553 jsonReq, err := m.Marshal(req)
554 if err != nil {
555 return nil, err
556 }
557
558 baseUrl, err := url.Parse(c.endpoint)
559 if err != nil {
560 return nil, err
561 }
562 baseUrl.Path += fmt.Sprintf("/v1/%v:batchPredict", req.GetName())
563
564 params := url.Values{}
565 params.Add("$alt", "json;enum-encoding=int")
566
567 baseUrl.RawQuery = params.Encode()
568
569 // Build HTTP headers from client and context metadata.
570 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
571
572 hds = append(c.xGoogHeaders, hds...)
573 hds = append(hds, "Content-Type", "application/json")
574 headers := gax.BuildHeaders(ctx, hds...)
575 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
576 resp := &longrunningpb.Operation{}
577 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
578 if settings.Path != "" {
579 baseUrl.Path = settings.Path
580 }
581 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
582 if err != nil {
583 return err
584 }
585 httpReq = httpReq.WithContext(ctx)
586 httpReq.Header = headers
587
588 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "BatchPredict")
589 if err != nil {
590 return err
591 }
592 if err := unm.Unmarshal(buf, resp); err != nil {
593 return err
594 }
595
596 return nil
597 }, opts...)
598 if e != nil {
599 return nil, e
600 }
601
602 override := fmt.Sprintf("/v1/%s", resp.GetName())
603 return &BatchPredictOperation{
604 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
605 pollPath: override,
606 }, nil
607 }
608
609 // BatchPredictOperation returns a new BatchPredictOperation from a given name.
610 // The name must be that of a previously created BatchPredictOperation, possibly from a different process.
611 func (c *predictionGRPCClient) BatchPredictOperation(name string) *BatchPredictOperation {
612 return &BatchPredictOperation{
613 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
614 }
615 }
616
617 // BatchPredictOperation returns a new BatchPredictOperation from a given name.
618 // The name must be that of a previously created BatchPredictOperation, possibly from a different process.
619 func (c *predictionRESTClient) BatchPredictOperation(name string) *BatchPredictOperation {
620 override := fmt.Sprintf("/v1/%s", name)
621 return &BatchPredictOperation{
622 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
623 pollPath: override,
624 }
625 }