Debian Codegraph @

visionai/apiv1/warehouse_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 visionai
18
19 import (
20 "bytes"
21 "context"
22 "errors"
23 "fmt"
24 "log/slog"
25 "math"
26 "net/http"
27 "net/url"
28 "time"
29
30 "cloud.google.com/go/longrunning"
31 lroauto "cloud.google.com/go/longrunning/autogen"
32 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
33 visionaipb "cloud.google.com/go/visionai/apiv1/visionaipb"
34 gax "github.com/googleapis/gax-go/v2"
35 "google.golang.org/api/iterator"
36 "google.golang.org/api/option"
37 "google.golang.org/api/option/internaloption"
38 gtransport "google.golang.org/api/transport/grpc"
39 httptransport "google.golang.org/api/transport/http"
40 "google.golang.org/grpc"
41 "google.golang.org/grpc/codes"
42 "google.golang.org/protobuf/encoding/protojson"
43 "google.golang.org/protobuf/proto"
44 )
45
46 var newWarehouseClientHook clientHook
47
48 // WarehouseCallOptions contains the retry settings for each method of WarehouseClient.
49 type WarehouseCallOptions struct {
50 CreateAsset []gax.CallOption
51 UpdateAsset []gax.CallOption
52 GetAsset []gax.CallOption
53 ListAssets []gax.CallOption
54 DeleteAsset []gax.CallOption
55 UploadAsset []gax.CallOption
56 GenerateRetrievalUrl []gax.CallOption
57 AnalyzeAsset []gax.CallOption
58 IndexAsset []gax.CallOption
59 RemoveIndexAsset []gax.CallOption
60 ViewIndexedAssets []gax.CallOption
61 CreateIndex []gax.CallOption
62 UpdateIndex []gax.CallOption
63 GetIndex []gax.CallOption
64 ListIndexes []gax.CallOption
65 DeleteIndex []gax.CallOption
66 CreateCorpus []gax.CallOption
67 GetCorpus []gax.CallOption
68 UpdateCorpus []gax.CallOption
69 ListCorpora []gax.CallOption
70 DeleteCorpus []gax.CallOption
71 AnalyzeCorpus []gax.CallOption
72 CreateDataSchema []gax.CallOption
73 UpdateDataSchema []gax.CallOption
74 GetDataSchema []gax.CallOption
75 DeleteDataSchema []gax.CallOption
76 ListDataSchemas []gax.CallOption
77 CreateAnnotation []gax.CallOption
78 GetAnnotation []gax.CallOption
79 ListAnnotations []gax.CallOption
80 UpdateAnnotation []gax.CallOption
81 DeleteAnnotation []gax.CallOption
82 IngestAsset []gax.CallOption
83 ClipAsset []gax.CallOption
84 GenerateHlsUri []gax.CallOption
85 ImportAssets []gax.CallOption
86 CreateSearchConfig []gax.CallOption
87 UpdateSearchConfig []gax.CallOption
88 GetSearchConfig []gax.CallOption
89 DeleteSearchConfig []gax.CallOption
90 ListSearchConfigs []gax.CallOption
91 CreateSearchHypernym []gax.CallOption
92 UpdateSearchHypernym []gax.CallOption
93 GetSearchHypernym []gax.CallOption
94 DeleteSearchHypernym []gax.CallOption
95 ListSearchHypernyms []gax.CallOption
96 SearchAssets []gax.CallOption
97 SearchIndexEndpoint []gax.CallOption
98 CreateIndexEndpoint []gax.CallOption
99 GetIndexEndpoint []gax.CallOption
100 ListIndexEndpoints []gax.CallOption
101 UpdateIndexEndpoint []gax.CallOption
102 DeleteIndexEndpoint []gax.CallOption
103 DeployIndex []gax.CallOption
104 UndeployIndex []gax.CallOption
105 CreateCollection []gax.CallOption
106 DeleteCollection []gax.CallOption
107 GetCollection []gax.CallOption
108 UpdateCollection []gax.CallOption
109 ListCollections []gax.CallOption
110 AddCollectionItem []gax.CallOption
111 RemoveCollectionItem []gax.CallOption
112 ViewCollectionItems []gax.CallOption
113 CancelOperation []gax.CallOption
114 DeleteOperation []gax.CallOption
115 GetOperation []gax.CallOption
116 ListOperations []gax.CallOption
117 }
118
119 func defaultWarehouseGRPCClientOptions() []option.ClientOption {
120 return []option.ClientOption{
121 internaloption.WithDefaultEndpoint("visionai.googleapis.com:443"),
122 internaloption.WithDefaultEndpointTemplate("visionai.UNIVERSE_DOMAIN:443"),
123 internaloption.WithDefaultMTLSEndpoint("visionai.mtls.googleapis.com:443"),
124 internaloption.WithDefaultUniverseDomain("googleapis.com"),
125 internaloption.WithDefaultAudience("https://visionai.googleapis.com/"),
126 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
127 internaloption.EnableJwtWithScope(),
128 internaloption.EnableNewAuthLibrary(),
129 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
130 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
131 }
132 }
133
134 func defaultWarehouseCallOptions() *WarehouseCallOptions {
135 return &WarehouseCallOptions{
136 CreateAsset: []gax.CallOption{
137 gax.WithTimeout(120000 * time.Millisecond),
138 gax.WithRetry(func() gax.Retryer {
139 return gax.OnCodes([]codes.Code{
140 codes.Unavailable,
141 }, gax.Backoff{
142 Initial: 1000 * time.Millisecond,
143 Max: 120000 * time.Millisecond,
144 Multiplier: 2.50,
145 })
146 }),
147 },
148 UpdateAsset: []gax.CallOption{
149 gax.WithTimeout(60000 * time.Millisecond),
150 gax.WithRetry(func() gax.Retryer {
151 return gax.OnCodes([]codes.Code{
152 codes.Unavailable,
153 }, gax.Backoff{
154 Initial: 1000 * time.Millisecond,
155 Max: 10000 * time.Millisecond,
156 Multiplier: 1.30,
157 })
158 }),
159 },
160 GetAsset: []gax.CallOption{
161 gax.WithTimeout(60000 * time.Millisecond),
162 gax.WithRetry(func() gax.Retryer {
163 return gax.OnCodes([]codes.Code{
164 codes.Unavailable,
165 }, gax.Backoff{
166 Initial: 1000 * time.Millisecond,
167 Max: 10000 * time.Millisecond,
168 Multiplier: 1.30,
169 })
170 }),
171 },
172 ListAssets: []gax.CallOption{
173 gax.WithTimeout(60000 * time.Millisecond),
174 gax.WithRetry(func() gax.Retryer {
175 return gax.OnCodes([]codes.Code{
176 codes.Unavailable,
177 }, gax.Backoff{
178 Initial: 1000 * time.Millisecond,
179 Max: 10000 * time.Millisecond,
180 Multiplier: 1.30,
181 })
182 }),
183 },
184 DeleteAsset: []gax.CallOption{
185 gax.WithTimeout(60000 * time.Millisecond),
186 gax.WithRetry(func() gax.Retryer {
187 return gax.OnCodes([]codes.Code{
188 codes.Unavailable,
189 }, gax.Backoff{
190 Initial: 1000 * time.Millisecond,
191 Max: 10000 * time.Millisecond,
192 Multiplier: 1.30,
193 })
194 }),
195 },
196 UploadAsset: []gax.CallOption{
197 gax.WithTimeout(60000 * time.Millisecond),
198 gax.WithRetry(func() gax.Retryer {
199 return gax.OnCodes([]codes.Code{
200 codes.Unavailable,
201 }, gax.Backoff{
202 Initial: 1000 * time.Millisecond,
203 Max: 10000 * time.Millisecond,
204 Multiplier: 1.30,
205 })
206 }),
207 },
208 GenerateRetrievalUrl: []gax.CallOption{
209 gax.WithTimeout(60000 * time.Millisecond),
210 gax.WithRetry(func() gax.Retryer {
211 return gax.OnCodes([]codes.Code{
212 codes.Unavailable,
213 }, gax.Backoff{
214 Initial: 1000 * time.Millisecond,
215 Max: 10000 * time.Millisecond,
216 Multiplier: 1.30,
217 })
218 }),
219 },
220 AnalyzeAsset: []gax.CallOption{
221 gax.WithTimeout(60000 * time.Millisecond),
222 gax.WithRetry(func() gax.Retryer {
223 return gax.OnCodes([]codes.Code{
224 codes.Unavailable,
225 }, gax.Backoff{
226 Initial: 1000 * time.Millisecond,
227 Max: 10000 * time.Millisecond,
228 Multiplier: 1.30,
229 })
230 }),
231 },
232 IndexAsset: []gax.CallOption{
233 gax.WithTimeout(60000 * time.Millisecond),
234 gax.WithRetry(func() gax.Retryer {
235 return gax.OnCodes([]codes.Code{
236 codes.Unavailable,
237 }, gax.Backoff{
238 Initial: 1000 * time.Millisecond,
239 Max: 10000 * time.Millisecond,
240 Multiplier: 1.30,
241 })
242 }),
243 },
244 RemoveIndexAsset: []gax.CallOption{
245 gax.WithTimeout(60000 * time.Millisecond),
246 gax.WithRetry(func() gax.Retryer {
247 return gax.OnCodes([]codes.Code{
248 codes.Unavailable,
249 }, gax.Backoff{
250 Initial: 1000 * time.Millisecond,
251 Max: 10000 * time.Millisecond,
252 Multiplier: 1.30,
253 })
254 }),
255 },
256 ViewIndexedAssets: []gax.CallOption{
257 gax.WithTimeout(60000 * time.Millisecond),
258 gax.WithRetry(func() gax.Retryer {
259 return gax.OnCodes([]codes.Code{
260 codes.Unavailable,
261 }, gax.Backoff{
262 Initial: 1000 * time.Millisecond,
263 Max: 10000 * time.Millisecond,
264 Multiplier: 1.30,
265 })
266 }),
267 },
268 CreateIndex: []gax.CallOption{
269 gax.WithTimeout(60000 * time.Millisecond),
270 gax.WithRetry(func() gax.Retryer {
271 return gax.OnCodes([]codes.Code{
272 codes.Unavailable,
273 }, gax.Backoff{
274 Initial: 1000 * time.Millisecond,
275 Max: 10000 * time.Millisecond,
276 Multiplier: 1.30,
277 })
278 }),
279 },
280 UpdateIndex: []gax.CallOption{
281 gax.WithTimeout(60000 * time.Millisecond),
282 gax.WithRetry(func() gax.Retryer {
283 return gax.OnCodes([]codes.Code{
284 codes.Unavailable,
285 }, gax.Backoff{
286 Initial: 1000 * time.Millisecond,
287 Max: 10000 * time.Millisecond,
288 Multiplier: 1.30,
289 })
290 }),
291 },
292 GetIndex: []gax.CallOption{
293 gax.WithTimeout(60000 * time.Millisecond),
294 gax.WithRetry(func() gax.Retryer {
295 return gax.OnCodes([]codes.Code{
296 codes.Unavailable,
297 }, gax.Backoff{
298 Initial: 1000 * time.Millisecond,
299 Max: 10000 * time.Millisecond,
300 Multiplier: 1.30,
301 })
302 }),
303 },
304 ListIndexes: []gax.CallOption{
305 gax.WithTimeout(60000 * time.Millisecond),
306 gax.WithRetry(func() gax.Retryer {
307 return gax.OnCodes([]codes.Code{
308 codes.Unavailable,
309 }, gax.Backoff{
310 Initial: 1000 * time.Millisecond,
311 Max: 10000 * time.Millisecond,
312 Multiplier: 1.30,
313 })
314 }),
315 },
316 DeleteIndex: []gax.CallOption{
317 gax.WithTimeout(60000 * time.Millisecond),
318 gax.WithRetry(func() gax.Retryer {
319 return gax.OnCodes([]codes.Code{
320 codes.Unavailable,
321 }, gax.Backoff{
322 Initial: 1000 * time.Millisecond,
323 Max: 10000 * time.Millisecond,
324 Multiplier: 1.30,
325 })
326 }),
327 },
328 CreateCorpus: []gax.CallOption{
329 gax.WithTimeout(120000 * time.Millisecond),
330 gax.WithRetry(func() gax.Retryer {
331 return gax.OnCodes([]codes.Code{
332 codes.Unavailable,
333 }, gax.Backoff{
334 Initial: 1000 * time.Millisecond,
335 Max: 120000 * time.Millisecond,
336 Multiplier: 2.50,
337 })
338 }),
339 },
340 GetCorpus: []gax.CallOption{
341 gax.WithTimeout(60000 * time.Millisecond),
342 gax.WithRetry(func() gax.Retryer {
343 return gax.OnCodes([]codes.Code{
344 codes.Unavailable,
345 }, gax.Backoff{
346 Initial: 1000 * time.Millisecond,
347 Max: 10000 * time.Millisecond,
348 Multiplier: 1.30,
349 })
350 }),
351 },
352 UpdateCorpus: []gax.CallOption{
353 gax.WithTimeout(60000 * time.Millisecond),
354 gax.WithRetry(func() gax.Retryer {
355 return gax.OnCodes([]codes.Code{
356 codes.Unavailable,
357 }, gax.Backoff{
358 Initial: 1000 * time.Millisecond,
359 Max: 10000 * time.Millisecond,
360 Multiplier: 1.30,
361 })
362 }),
363 },
364 ListCorpora: []gax.CallOption{
365 gax.WithTimeout(60000 * time.Millisecond),
366 gax.WithRetry(func() gax.Retryer {
367 return gax.OnCodes([]codes.Code{
368 codes.Unavailable,
369 }, gax.Backoff{
370 Initial: 1000 * time.Millisecond,
371 Max: 10000 * time.Millisecond,
372 Multiplier: 1.30,
373 })
374 }),
375 },
376 DeleteCorpus: []gax.CallOption{
377 gax.WithTimeout(60000 * time.Millisecond),
378 gax.WithRetry(func() gax.Retryer {
379 return gax.OnCodes([]codes.Code{
380 codes.Unavailable,
381 }, gax.Backoff{
382 Initial: 1000 * time.Millisecond,
383 Max: 10000 * time.Millisecond,
384 Multiplier: 1.30,
385 })
386 }),
387 },
388 AnalyzeCorpus: []gax.CallOption{
389 gax.WithTimeout(60000 * time.Millisecond),
390 gax.WithRetry(func() gax.Retryer {
391 return gax.OnCodes([]codes.Code{
392 codes.Unavailable,
393 }, gax.Backoff{
394 Initial: 1000 * time.Millisecond,
395 Max: 10000 * time.Millisecond,
396 Multiplier: 1.30,
397 })
398 }),
399 },
400 CreateDataSchema: []gax.CallOption{
401 gax.WithTimeout(120000 * time.Millisecond),
402 gax.WithRetry(func() gax.Retryer {
403 return gax.OnCodes([]codes.Code{
404 codes.Unavailable,
405 }, gax.Backoff{
406 Initial: 1000 * time.Millisecond,
407 Max: 120000 * time.Millisecond,
408 Multiplier: 2.50,
409 })
410 }),
411 },
412 UpdateDataSchema: []gax.CallOption{
413 gax.WithTimeout(60000 * time.Millisecond),
414 gax.WithRetry(func() gax.Retryer {
415 return gax.OnCodes([]codes.Code{
416 codes.Unavailable,
417 }, gax.Backoff{
418 Initial: 1000 * time.Millisecond,
419 Max: 10000 * time.Millisecond,
420 Multiplier: 1.30,
421 })
422 }),
423 },
424 GetDataSchema: []gax.CallOption{
425 gax.WithTimeout(60000 * time.Millisecond),
426 gax.WithRetry(func() gax.Retryer {
427 return gax.OnCodes([]codes.Code{
428 codes.Unavailable,
429 }, gax.Backoff{
430 Initial: 1000 * time.Millisecond,
431 Max: 10000 * time.Millisecond,
432 Multiplier: 1.30,
433 })
434 }),
435 },
436 DeleteDataSchema: []gax.CallOption{
437 gax.WithTimeout(60000 * time.Millisecond),
438 gax.WithRetry(func() gax.Retryer {
439 return gax.OnCodes([]codes.Code{
440 codes.Unavailable,
441 }, gax.Backoff{
442 Initial: 1000 * time.Millisecond,
443 Max: 10000 * time.Millisecond,
444 Multiplier: 1.30,
445 })
446 }),
447 },
448 ListDataSchemas: []gax.CallOption{
449 gax.WithTimeout(60000 * time.Millisecond),
450 gax.WithRetry(func() gax.Retryer {
451 return gax.OnCodes([]codes.Code{
452 codes.Unavailable,
453 }, gax.Backoff{
454 Initial: 1000 * time.Millisecond,
455 Max: 10000 * time.Millisecond,
456 Multiplier: 1.30,
457 })
458 }),
459 },
460 CreateAnnotation: []gax.CallOption{
461 gax.WithTimeout(120000 * time.Millisecond),
462 gax.WithRetry(func() gax.Retryer {
463 return gax.OnCodes([]codes.Code{
464 codes.Unavailable,
465 }, gax.Backoff{
466 Initial: 1000 * time.Millisecond,
467 Max: 120000 * time.Millisecond,
468 Multiplier: 2.50,
469 })
470 }),
471 },
472 GetAnnotation: []gax.CallOption{
473 gax.WithTimeout(60000 * time.Millisecond),
474 gax.WithRetry(func() gax.Retryer {
475 return gax.OnCodes([]codes.Code{
476 codes.Unavailable,
477 }, gax.Backoff{
478 Initial: 1000 * time.Millisecond,
479 Max: 10000 * time.Millisecond,
480 Multiplier: 1.30,
481 })
482 }),
483 },
484 ListAnnotations: []gax.CallOption{
485 gax.WithTimeout(60000 * time.Millisecond),
486 gax.WithRetry(func() gax.Retryer {
487 return gax.OnCodes([]codes.Code{
488 codes.Unavailable,
489 }, gax.Backoff{
490 Initial: 1000 * time.Millisecond,
491 Max: 10000 * time.Millisecond,
492 Multiplier: 1.30,
493 })
494 }),
495 },
496 UpdateAnnotation: []gax.CallOption{
497 gax.WithTimeout(60000 * time.Millisecond),
498 gax.WithRetry(func() gax.Retryer {
499 return gax.OnCodes([]codes.Code{
500 codes.Unavailable,
501 }, gax.Backoff{
502 Initial: 1000 * time.Millisecond,
503 Max: 10000 * time.Millisecond,
504 Multiplier: 1.30,
505 })
506 }),
507 },
508 DeleteAnnotation: []gax.CallOption{
509 gax.WithTimeout(60000 * time.Millisecond),
510 gax.WithRetry(func() gax.Retryer {
511 return gax.OnCodes([]codes.Code{
512 codes.Unavailable,
513 }, gax.Backoff{
514 Initial: 1000 * time.Millisecond,
515 Max: 10000 * time.Millisecond,
516 Multiplier: 1.30,
517 })
518 }),
519 },
520 IngestAsset: []gax.CallOption{
521 gax.WithRetry(func() gax.Retryer {
522 return gax.OnCodes([]codes.Code{
523 codes.Unavailable,
524 }, gax.Backoff{
525 Initial: 1000 * time.Millisecond,
526 Max: 120000 * time.Millisecond,
527 Multiplier: 2.50,
528 })
529 }),
530 },
531 ClipAsset: []gax.CallOption{
532 gax.WithTimeout(60000 * time.Millisecond),
533 gax.WithRetry(func() gax.Retryer {
534 return gax.OnCodes([]codes.Code{
535 codes.Unavailable,
536 }, gax.Backoff{
537 Initial: 1000 * time.Millisecond,
538 Max: 10000 * time.Millisecond,
539 Multiplier: 1.30,
540 })
541 }),
542 },
543 GenerateHlsUri: []gax.CallOption{
544 gax.WithTimeout(60000 * time.Millisecond),
545 gax.WithRetry(func() gax.Retryer {
546 return gax.OnCodes([]codes.Code{
547 codes.Unavailable,
548 }, gax.Backoff{
549 Initial: 1000 * time.Millisecond,
550 Max: 10000 * time.Millisecond,
551 Multiplier: 1.30,
552 })
553 }),
554 },
555 ImportAssets: []gax.CallOption{
556 gax.WithTimeout(60000 * time.Millisecond),
557 gax.WithRetry(func() gax.Retryer {
558 return gax.OnCodes([]codes.Code{
559 codes.Unavailable,
560 }, gax.Backoff{
561 Initial: 1000 * time.Millisecond,
562 Max: 10000 * time.Millisecond,
563 Multiplier: 1.30,
564 })
565 }),
566 },
567 CreateSearchConfig: []gax.CallOption{
568 gax.WithTimeout(60000 * time.Millisecond),
569 gax.WithRetry(func() gax.Retryer {
570 return gax.OnCodes([]codes.Code{
571 codes.Unavailable,
572 }, gax.Backoff{
573 Initial: 1000 * time.Millisecond,
574 Max: 10000 * time.Millisecond,
575 Multiplier: 1.30,
576 })
577 }),
578 },
579 UpdateSearchConfig: []gax.CallOption{
580 gax.WithTimeout(60000 * time.Millisecond),
581 gax.WithRetry(func() gax.Retryer {
582 return gax.OnCodes([]codes.Code{
583 codes.Unavailable,
584 }, gax.Backoff{
585 Initial: 1000 * time.Millisecond,
586 Max: 10000 * time.Millisecond,
587 Multiplier: 1.30,
588 })
589 }),
590 },
591 GetSearchConfig: []gax.CallOption{
592 gax.WithTimeout(60000 * time.Millisecond),
593 gax.WithRetry(func() gax.Retryer {
594 return gax.OnCodes([]codes.Code{
595 codes.Unavailable,
596 }, gax.Backoff{
597 Initial: 1000 * time.Millisecond,
598 Max: 10000 * time.Millisecond,
599 Multiplier: 1.30,
600 })
601 }),
602 },
603 DeleteSearchConfig: []gax.CallOption{
604 gax.WithTimeout(60000 * time.Millisecond),
605 gax.WithRetry(func() gax.Retryer {
606 return gax.OnCodes([]codes.Code{
607 codes.Unavailable,
608 }, gax.Backoff{
609 Initial: 1000 * time.Millisecond,
610 Max: 10000 * time.Millisecond,
611 Multiplier: 1.30,
612 })
613 }),
614 },
615 ListSearchConfigs: []gax.CallOption{
616 gax.WithTimeout(60000 * time.Millisecond),
617 gax.WithRetry(func() gax.Retryer {
618 return gax.OnCodes([]codes.Code{
619 codes.Unavailable,
620 }, gax.Backoff{
621 Initial: 1000 * time.Millisecond,
622 Max: 10000 * time.Millisecond,
623 Multiplier: 1.30,
624 })
625 }),
626 },
627 CreateSearchHypernym: []gax.CallOption{
628 gax.WithTimeout(60000 * time.Millisecond),
629 gax.WithRetry(func() gax.Retryer {
630 return gax.OnCodes([]codes.Code{
631 codes.Unavailable,
632 }, gax.Backoff{
633 Initial: 1000 * time.Millisecond,
634 Max: 10000 * time.Millisecond,
635 Multiplier: 1.30,
636 })
637 }),
638 },
639 UpdateSearchHypernym: []gax.CallOption{
640 gax.WithTimeout(60000 * time.Millisecond),
641 gax.WithRetry(func() gax.Retryer {
642 return gax.OnCodes([]codes.Code{
643 codes.Unavailable,
644 }, gax.Backoff{
645 Initial: 1000 * time.Millisecond,
646 Max: 10000 * time.Millisecond,
647 Multiplier: 1.30,
648 })
649 }),
650 },
651 GetSearchHypernym: []gax.CallOption{
652 gax.WithTimeout(60000 * time.Millisecond),
653 gax.WithRetry(func() gax.Retryer {
654 return gax.OnCodes([]codes.Code{
655 codes.Unavailable,
656 }, gax.Backoff{
657 Initial: 1000 * time.Millisecond,
658 Max: 10000 * time.Millisecond,
659 Multiplier: 1.30,
660 })
661 }),
662 },
663 DeleteSearchHypernym: []gax.CallOption{
664 gax.WithTimeout(60000 * time.Millisecond),
665 gax.WithRetry(func() gax.Retryer {
666 return gax.OnCodes([]codes.Code{
667 codes.Unavailable,
668 }, gax.Backoff{
669 Initial: 1000 * time.Millisecond,
670 Max: 10000 * time.Millisecond,
671 Multiplier: 1.30,
672 })
673 }),
674 },
675 ListSearchHypernyms: []gax.CallOption{
676 gax.WithTimeout(60000 * time.Millisecond),
677 gax.WithRetry(func() gax.Retryer {
678 return gax.OnCodes([]codes.Code{
679 codes.Unavailable,
680 }, gax.Backoff{
681 Initial: 1000 * time.Millisecond,
682 Max: 10000 * time.Millisecond,
683 Multiplier: 1.30,
684 })
685 }),
686 },
687 SearchAssets: []gax.CallOption{
688 gax.WithTimeout(60000 * time.Millisecond),
689 gax.WithRetry(func() gax.Retryer {
690 return gax.OnCodes([]codes.Code{
691 codes.Unavailable,
692 }, gax.Backoff{
693 Initial: 1000 * time.Millisecond,
694 Max: 10000 * time.Millisecond,
695 Multiplier: 1.30,
696 })
697 }),
698 },
699 SearchIndexEndpoint: []gax.CallOption{
700 gax.WithTimeout(60000 * time.Millisecond),
701 gax.WithRetry(func() gax.Retryer {
702 return gax.OnCodes([]codes.Code{
703 codes.Unavailable,
704 }, gax.Backoff{
705 Initial: 1000 * time.Millisecond,
706 Max: 10000 * time.Millisecond,
707 Multiplier: 1.30,
708 })
709 }),
710 },
711 CreateIndexEndpoint: []gax.CallOption{
712 gax.WithTimeout(60000 * time.Millisecond),
713 gax.WithRetry(func() gax.Retryer {
714 return gax.OnCodes([]codes.Code{
715 codes.Unavailable,
716 }, gax.Backoff{
717 Initial: 1000 * time.Millisecond,
718 Max: 10000 * time.Millisecond,
719 Multiplier: 1.30,
720 })
721 }),
722 },
723 GetIndexEndpoint: []gax.CallOption{
724 gax.WithTimeout(60000 * time.Millisecond),
725 gax.WithRetry(func() gax.Retryer {
726 return gax.OnCodes([]codes.Code{
727 codes.Unavailable,
728 }, gax.Backoff{
729 Initial: 1000 * time.Millisecond,
730 Max: 10000 * time.Millisecond,
731 Multiplier: 1.30,
732 })
733 }),
734 },
735 ListIndexEndpoints: []gax.CallOption{
736 gax.WithTimeout(60000 * time.Millisecond),
737 gax.WithRetry(func() gax.Retryer {
738 return gax.OnCodes([]codes.Code{
739 codes.Unavailable,
740 }, gax.Backoff{
741 Initial: 1000 * time.Millisecond,
742 Max: 10000 * time.Millisecond,
743 Multiplier: 1.30,
744 })
745 }),
746 },
747 UpdateIndexEndpoint: []gax.CallOption{
748 gax.WithTimeout(60000 * time.Millisecond),
749 gax.WithRetry(func() gax.Retryer {
750 return gax.OnCodes([]codes.Code{
751 codes.Unavailable,
752 }, gax.Backoff{
753 Initial: 1000 * time.Millisecond,
754 Max: 10000 * time.Millisecond,
755 Multiplier: 1.30,
756 })
757 }),
758 },
759 DeleteIndexEndpoint: []gax.CallOption{
760 gax.WithTimeout(60000 * time.Millisecond),
761 gax.WithRetry(func() gax.Retryer {
762 return gax.OnCodes([]codes.Code{
763 codes.Unavailable,
764 }, gax.Backoff{
765 Initial: 1000 * time.Millisecond,
766 Max: 10000 * time.Millisecond,
767 Multiplier: 1.30,
768 })
769 }),
770 },
771 DeployIndex: []gax.CallOption{
772 gax.WithTimeout(60000 * time.Millisecond),
773 gax.WithRetry(func() gax.Retryer {
774 return gax.OnCodes([]codes.Code{
775 codes.Unavailable,
776 }, gax.Backoff{
777 Initial: 1000 * time.Millisecond,
778 Max: 10000 * time.Millisecond,
779 Multiplier: 1.30,
780 })
781 }),
782 },
783 UndeployIndex: []gax.CallOption{
784 gax.WithTimeout(60000 * time.Millisecond),
785 gax.WithRetry(func() gax.Retryer {
786 return gax.OnCodes([]codes.Code{
787 codes.Unavailable,
788 }, gax.Backoff{
789 Initial: 1000 * time.Millisecond,
790 Max: 10000 * time.Millisecond,
791 Multiplier: 1.30,
792 })
793 }),
794 },
795 CreateCollection: []gax.CallOption{
796 gax.WithTimeout(60000 * time.Millisecond),
797 gax.WithRetry(func() gax.Retryer {
798 return gax.OnCodes([]codes.Code{
799 codes.Unavailable,
800 }, gax.Backoff{
801 Initial: 1000 * time.Millisecond,
802 Max: 10000 * time.Millisecond,
803 Multiplier: 1.30,
804 })
805 }),
806 },
807 DeleteCollection: []gax.CallOption{
808 gax.WithTimeout(60000 * time.Millisecond),
809 gax.WithRetry(func() gax.Retryer {
810 return gax.OnCodes([]codes.Code{
811 codes.Unavailable,
812 }, gax.Backoff{
813 Initial: 1000 * time.Millisecond,
814 Max: 10000 * time.Millisecond,
815 Multiplier: 1.30,
816 })
817 }),
818 },
819 GetCollection: []gax.CallOption{
820 gax.WithTimeout(60000 * time.Millisecond),
821 gax.WithRetry(func() gax.Retryer {
822 return gax.OnCodes([]codes.Code{
823 codes.Unavailable,
824 }, gax.Backoff{
825 Initial: 1000 * time.Millisecond,
826 Max: 10000 * time.Millisecond,
827 Multiplier: 1.30,
828 })
829 }),
830 },
831 UpdateCollection: []gax.CallOption{
832 gax.WithTimeout(60000 * time.Millisecond),
833 gax.WithRetry(func() gax.Retryer {
834 return gax.OnCodes([]codes.Code{
835 codes.Unavailable,
836 }, gax.Backoff{
837 Initial: 1000 * time.Millisecond,
838 Max: 10000 * time.Millisecond,
839 Multiplier: 1.30,
840 })
841 }),
842 },
843 ListCollections: []gax.CallOption{
844 gax.WithTimeout(60000 * time.Millisecond),
845 gax.WithRetry(func() gax.Retryer {
846 return gax.OnCodes([]codes.Code{
847 codes.Unavailable,
848 }, gax.Backoff{
849 Initial: 1000 * time.Millisecond,
850 Max: 10000 * time.Millisecond,
851 Multiplier: 1.30,
852 })
853 }),
854 },
855 AddCollectionItem: []gax.CallOption{
856 gax.WithTimeout(60000 * time.Millisecond),
857 gax.WithRetry(func() gax.Retryer {
858 return gax.OnCodes([]codes.Code{
859 codes.Unavailable,
860 }, gax.Backoff{
861 Initial: 1000 * time.Millisecond,
862 Max: 10000 * time.Millisecond,
863 Multiplier: 1.30,
864 })
865 }),
866 },
867 RemoveCollectionItem: []gax.CallOption{
868 gax.WithTimeout(60000 * time.Millisecond),
869 gax.WithRetry(func() gax.Retryer {
870 return gax.OnCodes([]codes.Code{
871 codes.Unavailable,
872 }, gax.Backoff{
873 Initial: 1000 * time.Millisecond,
874 Max: 10000 * time.Millisecond,
875 Multiplier: 1.30,
876 })
877 }),
878 },
879 ViewCollectionItems: []gax.CallOption{
880 gax.WithTimeout(60000 * time.Millisecond),
881 gax.WithRetry(func() gax.Retryer {
882 return gax.OnCodes([]codes.Code{
883 codes.Unavailable,
884 }, gax.Backoff{
885 Initial: 1000 * time.Millisecond,
886 Max: 10000 * time.Millisecond,
887 Multiplier: 1.30,
888 })
889 }),
890 },
891 CancelOperation: []gax.CallOption{},
892 DeleteOperation: []gax.CallOption{},
893 GetOperation: []gax.CallOption{},
894 ListOperations: []gax.CallOption{},
895 }
896 }
897
898 func defaultWarehouseRESTCallOptions() *WarehouseCallOptions {
899 return &WarehouseCallOptions{
900 CreateAsset: []gax.CallOption{
901 gax.WithTimeout(120000 * time.Millisecond),
902 gax.WithRetry(func() gax.Retryer {
903 return gax.OnHTTPCodes(gax.Backoff{
904 Initial: 1000 * time.Millisecond,
905 Max: 120000 * time.Millisecond,
906 Multiplier: 2.50,
907 },
908 http.StatusServiceUnavailable)
909 }),
910 },
911 UpdateAsset: []gax.CallOption{
912 gax.WithTimeout(60000 * time.Millisecond),
913 gax.WithRetry(func() gax.Retryer {
914 return gax.OnHTTPCodes(gax.Backoff{
915 Initial: 1000 * time.Millisecond,
916 Max: 10000 * time.Millisecond,
917 Multiplier: 1.30,
918 },
919 http.StatusServiceUnavailable)
920 }),
921 },
922 GetAsset: []gax.CallOption{
923 gax.WithTimeout(60000 * time.Millisecond),
924 gax.WithRetry(func() gax.Retryer {
925 return gax.OnHTTPCodes(gax.Backoff{
926 Initial: 1000 * time.Millisecond,
927 Max: 10000 * time.Millisecond,
928 Multiplier: 1.30,
929 },
930 http.StatusServiceUnavailable)
931 }),
932 },
933 ListAssets: []gax.CallOption{
934 gax.WithTimeout(60000 * time.Millisecond),
935 gax.WithRetry(func() gax.Retryer {
936 return gax.OnHTTPCodes(gax.Backoff{
937 Initial: 1000 * time.Millisecond,
938 Max: 10000 * time.Millisecond,
939 Multiplier: 1.30,
940 },
941 http.StatusServiceUnavailable)
942 }),
943 },
944 DeleteAsset: []gax.CallOption{
945 gax.WithTimeout(60000 * time.Millisecond),
946 gax.WithRetry(func() gax.Retryer {
947 return gax.OnHTTPCodes(gax.Backoff{
948 Initial: 1000 * time.Millisecond,
949 Max: 10000 * time.Millisecond,
950 Multiplier: 1.30,
951 },
952 http.StatusServiceUnavailable)
953 }),
954 },
955 UploadAsset: []gax.CallOption{
956 gax.WithTimeout(60000 * time.Millisecond),
957 gax.WithRetry(func() gax.Retryer {
958 return gax.OnHTTPCodes(gax.Backoff{
959 Initial: 1000 * time.Millisecond,
960 Max: 10000 * time.Millisecond,
961 Multiplier: 1.30,
962 },
963 http.StatusServiceUnavailable)
964 }),
965 },
966 GenerateRetrievalUrl: []gax.CallOption{
967 gax.WithTimeout(60000 * time.Millisecond),
968 gax.WithRetry(func() gax.Retryer {
969 return gax.OnHTTPCodes(gax.Backoff{
970 Initial: 1000 * time.Millisecond,
971 Max: 10000 * time.Millisecond,
972 Multiplier: 1.30,
973 },
974 http.StatusServiceUnavailable)
975 }),
976 },
977 AnalyzeAsset: []gax.CallOption{
978 gax.WithTimeout(60000 * time.Millisecond),
979 gax.WithRetry(func() gax.Retryer {
980 return gax.OnHTTPCodes(gax.Backoff{
981 Initial: 1000 * time.Millisecond,
982 Max: 10000 * time.Millisecond,
983 Multiplier: 1.30,
984 },
985 http.StatusServiceUnavailable)
986 }),
987 },
988 IndexAsset: []gax.CallOption{
989 gax.WithTimeout(60000 * time.Millisecond),
990 gax.WithRetry(func() gax.Retryer {
991 return gax.OnHTTPCodes(gax.Backoff{
992 Initial: 1000 * time.Millisecond,
993 Max: 10000 * time.Millisecond,
994 Multiplier: 1.30,
995 },
996 http.StatusServiceUnavailable)
997 }),
998 },
999 RemoveIndexAsset: []gax.CallOption{
1000 gax.WithTimeout(60000 * time.Millisecond),
1001 gax.WithRetry(func() gax.Retryer {
1002 return gax.OnHTTPCodes(gax.Backoff{
1003 Initial: 1000 * time.Millisecond,
1004 Max: 10000 * time.Millisecond,
1005 Multiplier: 1.30,
1006 },
1007 http.StatusServiceUnavailable)
1008 }),
1009 },
1010 ViewIndexedAssets: []gax.CallOption{
1011 gax.WithTimeout(60000 * time.Millisecond),
1012 gax.WithRetry(func() gax.Retryer {
1013 return gax.OnHTTPCodes(gax.Backoff{
1014 Initial: 1000 * time.Millisecond,
1015 Max: 10000 * time.Millisecond,
1016 Multiplier: 1.30,
1017 },
1018 http.StatusServiceUnavailable)
1019 }),
1020 },
1021 CreateIndex: []gax.CallOption{
1022 gax.WithTimeout(60000 * time.Millisecond),
1023 gax.WithRetry(func() gax.Retryer {
1024 return gax.OnHTTPCodes(gax.Backoff{
1025 Initial: 1000 * time.Millisecond,
1026 Max: 10000 * time.Millisecond,
1027 Multiplier: 1.30,
1028 },
1029 http.StatusServiceUnavailable)
1030 }),
1031 },
1032 UpdateIndex: []gax.CallOption{
1033 gax.WithTimeout(60000 * time.Millisecond),
1034 gax.WithRetry(func() gax.Retryer {
1035 return gax.OnHTTPCodes(gax.Backoff{
1036 Initial: 1000 * time.Millisecond,
1037 Max: 10000 * time.Millisecond,
1038 Multiplier: 1.30,
1039 },
1040 http.StatusServiceUnavailable)
1041 }),
1042 },
1043 GetIndex: []gax.CallOption{
1044 gax.WithTimeout(60000 * time.Millisecond),
1045 gax.WithRetry(func() gax.Retryer {
1046 return gax.OnHTTPCodes(gax.Backoff{
1047 Initial: 1000 * time.Millisecond,
1048 Max: 10000 * time.Millisecond,
1049 Multiplier: 1.30,
1050 },
1051 http.StatusServiceUnavailable)
1052 }),
1053 },
1054 ListIndexes: []gax.CallOption{
1055 gax.WithTimeout(60000 * time.Millisecond),
1056 gax.WithRetry(func() gax.Retryer {
1057 return gax.OnHTTPCodes(gax.Backoff{
1058 Initial: 1000 * time.Millisecond,
1059 Max: 10000 * time.Millisecond,
1060 Multiplier: 1.30,
1061 },
1062 http.StatusServiceUnavailable)
1063 }),
1064 },
1065 DeleteIndex: []gax.CallOption{
1066 gax.WithTimeout(60000 * time.Millisecond),
1067 gax.WithRetry(func() gax.Retryer {
1068 return gax.OnHTTPCodes(gax.Backoff{
1069 Initial: 1000 * time.Millisecond,
1070 Max: 10000 * time.Millisecond,
1071 Multiplier: 1.30,
1072 },
1073 http.StatusServiceUnavailable)
1074 }),
1075 },
1076 CreateCorpus: []gax.CallOption{
1077 gax.WithTimeout(120000 * time.Millisecond),
1078 gax.WithRetry(func() gax.Retryer {
1079 return gax.OnHTTPCodes(gax.Backoff{
1080 Initial: 1000 * time.Millisecond,
1081 Max: 120000 * time.Millisecond,
1082 Multiplier: 2.50,
1083 },
1084 http.StatusServiceUnavailable)
1085 }),
1086 },
1087 GetCorpus: []gax.CallOption{
1088 gax.WithTimeout(60000 * time.Millisecond),
1089 gax.WithRetry(func() gax.Retryer {
1090 return gax.OnHTTPCodes(gax.Backoff{
1091 Initial: 1000 * time.Millisecond,
1092 Max: 10000 * time.Millisecond,
1093 Multiplier: 1.30,
1094 },
1095 http.StatusServiceUnavailable)
1096 }),
1097 },
1098 UpdateCorpus: []gax.CallOption{
1099 gax.WithTimeout(60000 * time.Millisecond),
1100 gax.WithRetry(func() gax.Retryer {
1101 return gax.OnHTTPCodes(gax.Backoff{
1102 Initial: 1000 * time.Millisecond,
1103 Max: 10000 * time.Millisecond,
1104 Multiplier: 1.30,
1105 },
1106 http.StatusServiceUnavailable)
1107 }),
1108 },
1109 ListCorpora: []gax.CallOption{
1110 gax.WithTimeout(60000 * time.Millisecond),
1111 gax.WithRetry(func() gax.Retryer {
1112 return gax.OnHTTPCodes(gax.Backoff{
1113 Initial: 1000 * time.Millisecond,
1114 Max: 10000 * time.Millisecond,
1115 Multiplier: 1.30,
1116 },
1117 http.StatusServiceUnavailable)
1118 }),
1119 },
1120 DeleteCorpus: []gax.CallOption{
1121 gax.WithTimeout(60000 * time.Millisecond),
1122 gax.WithRetry(func() gax.Retryer {
1123 return gax.OnHTTPCodes(gax.Backoff{
1124 Initial: 1000 * time.Millisecond,
1125 Max: 10000 * time.Millisecond,
1126 Multiplier: 1.30,
1127 },
1128 http.StatusServiceUnavailable)
1129 }),
1130 },
1131 AnalyzeCorpus: []gax.CallOption{
1132 gax.WithTimeout(60000 * time.Millisecond),
1133 gax.WithRetry(func() gax.Retryer {
1134 return gax.OnHTTPCodes(gax.Backoff{
1135 Initial: 1000 * time.Millisecond,
1136 Max: 10000 * time.Millisecond,
1137 Multiplier: 1.30,
1138 },
1139 http.StatusServiceUnavailable)
1140 }),
1141 },
1142 CreateDataSchema: []gax.CallOption{
1143 gax.WithTimeout(120000 * time.Millisecond),
1144 gax.WithRetry(func() gax.Retryer {
1145 return gax.OnHTTPCodes(gax.Backoff{
1146 Initial: 1000 * time.Millisecond,
1147 Max: 120000 * time.Millisecond,
1148 Multiplier: 2.50,
1149 },
1150 http.StatusServiceUnavailable)
1151 }),
1152 },
1153 UpdateDataSchema: []gax.CallOption{
1154 gax.WithTimeout(60000 * time.Millisecond),
1155 gax.WithRetry(func() gax.Retryer {
1156 return gax.OnHTTPCodes(gax.Backoff{
1157 Initial: 1000 * time.Millisecond,
1158 Max: 10000 * time.Millisecond,
1159 Multiplier: 1.30,
1160 },
1161 http.StatusServiceUnavailable)
1162 }),
1163 },
1164 GetDataSchema: []gax.CallOption{
1165 gax.WithTimeout(60000 * time.Millisecond),
1166 gax.WithRetry(func() gax.Retryer {
1167 return gax.OnHTTPCodes(gax.Backoff{
1168 Initial: 1000 * time.Millisecond,
1169 Max: 10000 * time.Millisecond,
1170 Multiplier: 1.30,
1171 },
1172 http.StatusServiceUnavailable)
1173 }),
1174 },
1175 DeleteDataSchema: []gax.CallOption{
1176 gax.WithTimeout(60000 * time.Millisecond),
1177 gax.WithRetry(func() gax.Retryer {
1178 return gax.OnHTTPCodes(gax.Backoff{
1179 Initial: 1000 * time.Millisecond,
1180 Max: 10000 * time.Millisecond,
1181 Multiplier: 1.30,
1182 },
1183 http.StatusServiceUnavailable)
1184 }),
1185 },
1186 ListDataSchemas: []gax.CallOption{
1187 gax.WithTimeout(60000 * time.Millisecond),
1188 gax.WithRetry(func() gax.Retryer {
1189 return gax.OnHTTPCodes(gax.Backoff{
1190 Initial: 1000 * time.Millisecond,
1191 Max: 10000 * time.Millisecond,
1192 Multiplier: 1.30,
1193 },
1194 http.StatusServiceUnavailable)
1195 }),
1196 },
1197 CreateAnnotation: []gax.CallOption{
1198 gax.WithTimeout(120000 * time.Millisecond),
1199 gax.WithRetry(func() gax.Retryer {
1200 return gax.OnHTTPCodes(gax.Backoff{
1201 Initial: 1000 * time.Millisecond,
1202 Max: 120000 * time.Millisecond,
1203 Multiplier: 2.50,
1204 },
1205 http.StatusServiceUnavailable)
1206 }),
1207 },
1208 GetAnnotation: []gax.CallOption{
1209 gax.WithTimeout(60000 * time.Millisecond),
1210 gax.WithRetry(func() gax.Retryer {
1211 return gax.OnHTTPCodes(gax.Backoff{
1212 Initial: 1000 * time.Millisecond,
1213 Max: 10000 * time.Millisecond,
1214 Multiplier: 1.30,
1215 },
1216 http.StatusServiceUnavailable)
1217 }),
1218 },
1219 ListAnnotations: []gax.CallOption{
1220 gax.WithTimeout(60000 * time.Millisecond),
1221 gax.WithRetry(func() gax.Retryer {
1222 return gax.OnHTTPCodes(gax.Backoff{
1223 Initial: 1000 * time.Millisecond,
1224 Max: 10000 * time.Millisecond,
1225 Multiplier: 1.30,
1226 },
1227 http.StatusServiceUnavailable)
1228 }),
1229 },
1230 UpdateAnnotation: []gax.CallOption{
1231 gax.WithTimeout(60000 * time.Millisecond),
1232 gax.WithRetry(func() gax.Retryer {
1233 return gax.OnHTTPCodes(gax.Backoff{
1234 Initial: 1000 * time.Millisecond,
1235 Max: 10000 * time.Millisecond,
1236 Multiplier: 1.30,
1237 },
1238 http.StatusServiceUnavailable)
1239 }),
1240 },
1241 DeleteAnnotation: []gax.CallOption{
1242 gax.WithTimeout(60000 * time.Millisecond),
1243 gax.WithRetry(func() gax.Retryer {
1244 return gax.OnHTTPCodes(gax.Backoff{
1245 Initial: 1000 * time.Millisecond,
1246 Max: 10000 * time.Millisecond,
1247 Multiplier: 1.30,
1248 },
1249 http.StatusServiceUnavailable)
1250 }),
1251 },
1252 IngestAsset: []gax.CallOption{
1253 gax.WithTimeout(120000 * time.Millisecond),
1254 gax.WithRetry(func() gax.Retryer {
1255 return gax.OnHTTPCodes(gax.Backoff{
1256 Initial: 1000 * time.Millisecond,
1257 Max: 120000 * time.Millisecond,
1258 Multiplier: 2.50,
1259 },
1260 http.StatusServiceUnavailable)
1261 }),
1262 },
1263 ClipAsset: []gax.CallOption{
1264 gax.WithTimeout(60000 * time.Millisecond),
1265 gax.WithRetry(func() gax.Retryer {
1266 return gax.OnHTTPCodes(gax.Backoff{
1267 Initial: 1000 * time.Millisecond,
1268 Max: 10000 * time.Millisecond,
1269 Multiplier: 1.30,
1270 },
1271 http.StatusServiceUnavailable)
1272 }),
1273 },
1274 GenerateHlsUri: []gax.CallOption{
1275 gax.WithTimeout(60000 * time.Millisecond),
1276 gax.WithRetry(func() gax.Retryer {
1277 return gax.OnHTTPCodes(gax.Backoff{
1278 Initial: 1000 * time.Millisecond,
1279 Max: 10000 * time.Millisecond,
1280 Multiplier: 1.30,
1281 },
1282 http.StatusServiceUnavailable)
1283 }),
1284 },
1285 ImportAssets: []gax.CallOption{
1286 gax.WithTimeout(60000 * time.Millisecond),
1287 gax.WithRetry(func() gax.Retryer {
1288 return gax.OnHTTPCodes(gax.Backoff{
1289 Initial: 1000 * time.Millisecond,
1290 Max: 10000 * time.Millisecond,
1291 Multiplier: 1.30,
1292 },
1293 http.StatusServiceUnavailable)
1294 }),
1295 },
1296 CreateSearchConfig: []gax.CallOption{
1297 gax.WithTimeout(60000 * time.Millisecond),
1298 gax.WithRetry(func() gax.Retryer {
1299 return gax.OnHTTPCodes(gax.Backoff{
1300 Initial: 1000 * time.Millisecond,
1301 Max: 10000 * time.Millisecond,
1302 Multiplier: 1.30,
1303 },
1304 http.StatusServiceUnavailable)
1305 }),
1306 },
1307 UpdateSearchConfig: []gax.CallOption{
1308 gax.WithTimeout(60000 * time.Millisecond),
1309 gax.WithRetry(func() gax.Retryer {
1310 return gax.OnHTTPCodes(gax.Backoff{
1311 Initial: 1000 * time.Millisecond,
1312 Max: 10000 * time.Millisecond,
1313 Multiplier: 1.30,
1314 },
1315 http.StatusServiceUnavailable)
1316 }),
1317 },
1318 GetSearchConfig: []gax.CallOption{
1319 gax.WithTimeout(60000 * time.Millisecond),
1320 gax.WithRetry(func() gax.Retryer {
1321 return gax.OnHTTPCodes(gax.Backoff{
1322 Initial: 1000 * time.Millisecond,
1323 Max: 10000 * time.Millisecond,
1324 Multiplier: 1.30,
1325 },
1326 http.StatusServiceUnavailable)
1327 }),
1328 },
1329 DeleteSearchConfig: []gax.CallOption{
1330 gax.WithTimeout(60000 * time.Millisecond),
1331 gax.WithRetry(func() gax.Retryer {
1332 return gax.OnHTTPCodes(gax.Backoff{
1333 Initial: 1000 * time.Millisecond,
1334 Max: 10000 * time.Millisecond,
1335 Multiplier: 1.30,
1336 },
1337 http.StatusServiceUnavailable)
1338 }),
1339 },
1340 ListSearchConfigs: []gax.CallOption{
1341 gax.WithTimeout(60000 * time.Millisecond),
1342 gax.WithRetry(func() gax.Retryer {
1343 return gax.OnHTTPCodes(gax.Backoff{
1344 Initial: 1000 * time.Millisecond,
1345 Max: 10000 * time.Millisecond,
1346 Multiplier: 1.30,
1347 },
1348 http.StatusServiceUnavailable)
1349 }),
1350 },
1351 CreateSearchHypernym: []gax.CallOption{
1352 gax.WithTimeout(60000 * time.Millisecond),
1353 gax.WithRetry(func() gax.Retryer {
1354 return gax.OnHTTPCodes(gax.Backoff{
1355 Initial: 1000 * time.Millisecond,
1356 Max: 10000 * time.Millisecond,
1357 Multiplier: 1.30,
1358 },
1359 http.StatusServiceUnavailable)
1360 }),
1361 },
1362 UpdateSearchHypernym: []gax.CallOption{
1363 gax.WithTimeout(60000 * time.Millisecond),
1364 gax.WithRetry(func() gax.Retryer {
1365 return gax.OnHTTPCodes(gax.Backoff{
1366 Initial: 1000 * time.Millisecond,
1367 Max: 10000 * time.Millisecond,
1368 Multiplier: 1.30,
1369 },
1370 http.StatusServiceUnavailable)
1371 }),
1372 },
1373 GetSearchHypernym: []gax.CallOption{
1374 gax.WithTimeout(60000 * time.Millisecond),
1375 gax.WithRetry(func() gax.Retryer {
1376 return gax.OnHTTPCodes(gax.Backoff{
1377 Initial: 1000 * time.Millisecond,
1378 Max: 10000 * time.Millisecond,
1379 Multiplier: 1.30,
1380 },
1381 http.StatusServiceUnavailable)
1382 }),
1383 },
1384 DeleteSearchHypernym: []gax.CallOption{
1385 gax.WithTimeout(60000 * time.Millisecond),
1386 gax.WithRetry(func() gax.Retryer {
1387 return gax.OnHTTPCodes(gax.Backoff{
1388 Initial: 1000 * time.Millisecond,
1389 Max: 10000 * time.Millisecond,
1390 Multiplier: 1.30,
1391 },
1392 http.StatusServiceUnavailable)
1393 }),
1394 },
1395 ListSearchHypernyms: []gax.CallOption{
1396 gax.WithTimeout(60000 * time.Millisecond),
1397 gax.WithRetry(func() gax.Retryer {
1398 return gax.OnHTTPCodes(gax.Backoff{
1399 Initial: 1000 * time.Millisecond,
1400 Max: 10000 * time.Millisecond,
1401 Multiplier: 1.30,
1402 },
1403 http.StatusServiceUnavailable)
1404 }),
1405 },
1406 SearchAssets: []gax.CallOption{
1407 gax.WithTimeout(60000 * time.Millisecond),
1408 gax.WithRetry(func() gax.Retryer {
1409 return gax.OnHTTPCodes(gax.Backoff{
1410 Initial: 1000 * time.Millisecond,
1411 Max: 10000 * time.Millisecond,
1412 Multiplier: 1.30,
1413 },
1414 http.StatusServiceUnavailable)
1415 }),
1416 },
1417 SearchIndexEndpoint: []gax.CallOption{
1418 gax.WithTimeout(60000 * time.Millisecond),
1419 gax.WithRetry(func() gax.Retryer {
1420 return gax.OnHTTPCodes(gax.Backoff{
1421 Initial: 1000 * time.Millisecond,
1422 Max: 10000 * time.Millisecond,
1423 Multiplier: 1.30,
1424 },
1425 http.StatusServiceUnavailable)
1426 }),
1427 },
1428 CreateIndexEndpoint: []gax.CallOption{
1429 gax.WithTimeout(60000 * time.Millisecond),
1430 gax.WithRetry(func() gax.Retryer {
1431 return gax.OnHTTPCodes(gax.Backoff{
1432 Initial: 1000 * time.Millisecond,
1433 Max: 10000 * time.Millisecond,
1434 Multiplier: 1.30,
1435 },
1436 http.StatusServiceUnavailable)
1437 }),
1438 },
1439 GetIndexEndpoint: []gax.CallOption{
1440 gax.WithTimeout(60000 * time.Millisecond),
1441 gax.WithRetry(func() gax.Retryer {
1442 return gax.OnHTTPCodes(gax.Backoff{
1443 Initial: 1000 * time.Millisecond,
1444 Max: 10000 * time.Millisecond,
1445 Multiplier: 1.30,
1446 },
1447 http.StatusServiceUnavailable)
1448 }),
1449 },
1450 ListIndexEndpoints: []gax.CallOption{
1451 gax.WithTimeout(60000 * time.Millisecond),
1452 gax.WithRetry(func() gax.Retryer {
1453 return gax.OnHTTPCodes(gax.Backoff{
1454 Initial: 1000 * time.Millisecond,
1455 Max: 10000 * time.Millisecond,
1456 Multiplier: 1.30,
1457 },
1458 http.StatusServiceUnavailable)
1459 }),
1460 },
1461 UpdateIndexEndpoint: []gax.CallOption{
1462 gax.WithTimeout(60000 * time.Millisecond),
1463 gax.WithRetry(func() gax.Retryer {
1464 return gax.OnHTTPCodes(gax.Backoff{
1465 Initial: 1000 * time.Millisecond,
1466 Max: 10000 * time.Millisecond,
1467 Multiplier: 1.30,
1468 },
1469 http.StatusServiceUnavailable)
1470 }),
1471 },
1472 DeleteIndexEndpoint: []gax.CallOption{
1473 gax.WithTimeout(60000 * time.Millisecond),
1474 gax.WithRetry(func() gax.Retryer {
1475 return gax.OnHTTPCodes(gax.Backoff{
1476 Initial: 1000 * time.Millisecond,
1477 Max: 10000 * time.Millisecond,
1478 Multiplier: 1.30,
1479 },
1480 http.StatusServiceUnavailable)
1481 }),
1482 },
1483 DeployIndex: []gax.CallOption{
1484 gax.WithTimeout(60000 * time.Millisecond),
1485 gax.WithRetry(func() gax.Retryer {
1486 return gax.OnHTTPCodes(gax.Backoff{
1487 Initial: 1000 * time.Millisecond,
1488 Max: 10000 * time.Millisecond,
1489 Multiplier: 1.30,
1490 },
1491 http.StatusServiceUnavailable)
1492 }),
1493 },
1494 UndeployIndex: []gax.CallOption{
1495 gax.WithTimeout(60000 * time.Millisecond),
1496 gax.WithRetry(func() gax.Retryer {
1497 return gax.OnHTTPCodes(gax.Backoff{
1498 Initial: 1000 * time.Millisecond,
1499 Max: 10000 * time.Millisecond,
1500 Multiplier: 1.30,
1501 },
1502 http.StatusServiceUnavailable)
1503 }),
1504 },
1505 CreateCollection: []gax.CallOption{
1506 gax.WithTimeout(60000 * time.Millisecond),
1507 gax.WithRetry(func() gax.Retryer {
1508 return gax.OnHTTPCodes(gax.Backoff{
1509 Initial: 1000 * time.Millisecond,
1510 Max: 10000 * time.Millisecond,
1511 Multiplier: 1.30,
1512 },
1513 http.StatusServiceUnavailable)
1514 }),
1515 },
1516 DeleteCollection: []gax.CallOption{
1517 gax.WithTimeout(60000 * time.Millisecond),
1518 gax.WithRetry(func() gax.Retryer {
1519 return gax.OnHTTPCodes(gax.Backoff{
1520 Initial: 1000 * time.Millisecond,
1521 Max: 10000 * time.Millisecond,
1522 Multiplier: 1.30,
1523 },
1524 http.StatusServiceUnavailable)
1525 }),
1526 },
1527 GetCollection: []gax.CallOption{
1528 gax.WithTimeout(60000 * time.Millisecond),
1529 gax.WithRetry(func() gax.Retryer {
1530 return gax.OnHTTPCodes(gax.Backoff{
1531 Initial: 1000 * time.Millisecond,
1532 Max: 10000 * time.Millisecond,
1533 Multiplier: 1.30,
1534 },
1535 http.StatusServiceUnavailable)
1536 }),
1537 },
1538 UpdateCollection: []gax.CallOption{
1539 gax.WithTimeout(60000 * time.Millisecond),
1540 gax.WithRetry(func() gax.Retryer {
1541 return gax.OnHTTPCodes(gax.Backoff{
1542 Initial: 1000 * time.Millisecond,
1543 Max: 10000 * time.Millisecond,
1544 Multiplier: 1.30,
1545 },
1546 http.StatusServiceUnavailable)
1547 }),
1548 },
1549 ListCollections: []gax.CallOption{
1550 gax.WithTimeout(60000 * time.Millisecond),
1551 gax.WithRetry(func() gax.Retryer {
1552 return gax.OnHTTPCodes(gax.Backoff{
1553 Initial: 1000 * time.Millisecond,
1554 Max: 10000 * time.Millisecond,
1555 Multiplier: 1.30,
1556 },
1557 http.StatusServiceUnavailable)
1558 }),
1559 },
1560 AddCollectionItem: []gax.CallOption{
1561 gax.WithTimeout(60000 * time.Millisecond),
1562 gax.WithRetry(func() gax.Retryer {
1563 return gax.OnHTTPCodes(gax.Backoff{
1564 Initial: 1000 * time.Millisecond,
1565 Max: 10000 * time.Millisecond,
1566 Multiplier: 1.30,
1567 },
1568 http.StatusServiceUnavailable)
1569 }),
1570 },
1571 RemoveCollectionItem: []gax.CallOption{
1572 gax.WithTimeout(60000 * time.Millisecond),
1573 gax.WithRetry(func() gax.Retryer {
1574 return gax.OnHTTPCodes(gax.Backoff{
1575 Initial: 1000 * time.Millisecond,
1576 Max: 10000 * time.Millisecond,
1577 Multiplier: 1.30,
1578 },
1579 http.StatusServiceUnavailable)
1580 }),
1581 },
1582 ViewCollectionItems: []gax.CallOption{
1583 gax.WithTimeout(60000 * time.Millisecond),
1584 gax.WithRetry(func() gax.Retryer {
1585 return gax.OnHTTPCodes(gax.Backoff{
1586 Initial: 1000 * time.Millisecond,
1587 Max: 10000 * time.Millisecond,
1588 Multiplier: 1.30,
1589 },
1590 http.StatusServiceUnavailable)
1591 }),
1592 },
1593 CancelOperation: []gax.CallOption{},
1594 DeleteOperation: []gax.CallOption{},
1595 GetOperation: []gax.CallOption{},
1596 ListOperations: []gax.CallOption{},
1597 }
1598 }
1599
1600 // internalWarehouseClient is an interface that defines the methods available from Vision AI API.
1601 type internalWarehouseClient interface {
1602 Close() error
1603 setGoogleClientInfo(...string)
1604 Connection() *grpc.ClientConn
1605 CreateAsset(context.Context, *visionaipb.CreateAssetRequest, ...gax.CallOption) (*visionaipb.Asset, error)
1606 UpdateAsset(context.Context, *visionaipb.UpdateAssetRequest, ...gax.CallOption) (*visionaipb.Asset, error)
1607 GetAsset(context.Context, *visionaipb.GetAssetRequest, ...gax.CallOption) (*visionaipb.Asset, error)
1608 ListAssets(context.Context, *visionaipb.ListAssetsRequest, ...gax.CallOption) *AssetIterator
1609 DeleteAsset(context.Context, *visionaipb.DeleteAssetRequest, ...gax.CallOption) (*DeleteAssetOperation, error)
1610 DeleteAssetOperation(name string) *DeleteAssetOperation
1611 UploadAsset(context.Context, *visionaipb.UploadAssetRequest, ...gax.CallOption) (*UploadAssetOperation, error)
1612 UploadAssetOperation(name string) *UploadAssetOperation
1613 GenerateRetrievalUrl(context.Context, *visionaipb.GenerateRetrievalUrlRequest, ...gax.CallOption) (*visionaipb.GenerateRetrievalUrlResponse, error)
1614 AnalyzeAsset(context.Context, *visionaipb.AnalyzeAssetRequest, ...gax.CallOption) (*AnalyzeAssetOperation, error)
1615 AnalyzeAssetOperation(name string) *AnalyzeAssetOperation
1616 IndexAsset(context.Context, *visionaipb.IndexAssetRequest, ...gax.CallOption) (*IndexAssetOperation, error)
1617 IndexAssetOperation(name string) *IndexAssetOperation
1618 RemoveIndexAsset(context.Context, *visionaipb.RemoveIndexAssetRequest, ...gax.CallOption) (*RemoveIndexAssetOperation, error)
1619 RemoveIndexAssetOperation(name string) *RemoveIndexAssetOperation
1620 ViewIndexedAssets(context.Context, *visionaipb.ViewIndexedAssetsRequest, ...gax.CallOption) *IndexedAssetIterator
1621 CreateIndex(context.Context, *visionaipb.CreateIndexRequest, ...gax.CallOption) (*CreateIndexOperation, error)
1622 CreateIndexOperation(name string) *CreateIndexOperation
1623 UpdateIndex(context.Context, *visionaipb.UpdateIndexRequest, ...gax.CallOption) (*UpdateIndexOperation, error)
1624 UpdateIndexOperation(name string) *UpdateIndexOperation
1625 GetIndex(context.Context, *visionaipb.GetIndexRequest, ...gax.CallOption) (*visionaipb.Index, error)
1626 ListIndexes(context.Context, *visionaipb.ListIndexesRequest, ...gax.CallOption) *IndexIterator
1627 DeleteIndex(context.Context, *visionaipb.DeleteIndexRequest, ...gax.CallOption) (*DeleteIndexOperation, error)
1628 DeleteIndexOperation(name string) *DeleteIndexOperation
1629 CreateCorpus(context.Context, *visionaipb.CreateCorpusRequest, ...gax.CallOption) (*CreateCorpusOperation, error)
1630 CreateCorpusOperation(name string) *CreateCorpusOperation
1631 GetCorpus(context.Context, *visionaipb.GetCorpusRequest, ...gax.CallOption) (*visionaipb.Corpus, error)
1632 UpdateCorpus(context.Context, *visionaipb.UpdateCorpusRequest, ...gax.CallOption) (*visionaipb.Corpus, error)
1633 ListCorpora(context.Context, *visionaipb.ListCorporaRequest, ...gax.CallOption) *CorpusIterator
1634 DeleteCorpus(context.Context, *visionaipb.DeleteCorpusRequest, ...gax.CallOption) error
1635 AnalyzeCorpus(context.Context, *visionaipb.AnalyzeCorpusRequest, ...gax.CallOption) (*AnalyzeCorpusOperation, error)
1636 AnalyzeCorpusOperation(name string) *AnalyzeCorpusOperation
1637 CreateDataSchema(context.Context, *visionaipb.CreateDataSchemaRequest, ...gax.CallOption) (*visionaipb.DataSchema, error)
1638 UpdateDataSchema(context.Context, *visionaipb.UpdateDataSchemaRequest, ...gax.CallOption) (*visionaipb.DataSchema, error)
1639 GetDataSchema(context.Context, *visionaipb.GetDataSchemaRequest, ...gax.CallOption) (*visionaipb.DataSchema, error)
1640 DeleteDataSchema(context.Context, *visionaipb.DeleteDataSchemaRequest, ...gax.CallOption) error
1641 ListDataSchemas(context.Context, *visionaipb.ListDataSchemasRequest, ...gax.CallOption) *DataSchemaIterator
1642 CreateAnnotation(context.Context, *visionaipb.CreateAnnotationRequest, ...gax.CallOption) (*visionaipb.Annotation, error)
1643 GetAnnotation(context.Context, *visionaipb.GetAnnotationRequest, ...gax.CallOption) (*visionaipb.Annotation, error)
1644 ListAnnotations(context.Context, *visionaipb.ListAnnotationsRequest, ...gax.CallOption) *AnnotationIterator
1645 UpdateAnnotation(context.Context, *visionaipb.UpdateAnnotationRequest, ...gax.CallOption) (*visionaipb.Annotation, error)
1646 DeleteAnnotation(context.Context, *visionaipb.DeleteAnnotationRequest, ...gax.CallOption) error
1647 IngestAsset(context.Context, ...gax.CallOption) (visionaipb.Warehouse_IngestAssetClient, error)
1648 ClipAsset(context.Context, *visionaipb.ClipAssetRequest, ...gax.CallOption) (*visionaipb.ClipAssetResponse, error)
1649 GenerateHlsUri(context.Context, *visionaipb.GenerateHlsUriRequest, ...gax.CallOption) (*visionaipb.GenerateHlsUriResponse, error)
1650 ImportAssets(context.Context, *visionaipb.ImportAssetsRequest, ...gax.CallOption) (*ImportAssetsOperation, error)
1651 ImportAssetsOperation(name string) *ImportAssetsOperation
1652 CreateSearchConfig(context.Context, *visionaipb.CreateSearchConfigRequest, ...gax.CallOption) (*visionaipb.SearchConfig, error)
1653 UpdateSearchConfig(context.Context, *visionaipb.UpdateSearchConfigRequest, ...gax.CallOption) (*visionaipb.SearchConfig, error)
1654 GetSearchConfig(context.Context, *visionaipb.GetSearchConfigRequest, ...gax.CallOption) (*visionaipb.SearchConfig, error)
1655 DeleteSearchConfig(context.Context, *visionaipb.DeleteSearchConfigRequest, ...gax.CallOption) error
1656 ListSearchConfigs(context.Context, *visionaipb.ListSearchConfigsRequest, ...gax.CallOption) *SearchConfigIterator
1657 CreateSearchHypernym(context.Context, *visionaipb.CreateSearchHypernymRequest, ...gax.CallOption) (*visionaipb.SearchHypernym, error)
1658 UpdateSearchHypernym(context.Context, *visionaipb.UpdateSearchHypernymRequest, ...gax.CallOption) (*visionaipb.SearchHypernym, error)
1659 GetSearchHypernym(context.Context, *visionaipb.GetSearchHypernymRequest, ...gax.CallOption) (*visionaipb.SearchHypernym, error)
1660 DeleteSearchHypernym(context.Context, *visionaipb.DeleteSearchHypernymRequest, ...gax.CallOption) error
1661 ListSearchHypernyms(context.Context, *visionaipb.ListSearchHypernymsRequest, ...gax.CallOption) *SearchHypernymIterator
1662 SearchAssets(context.Context, *visionaipb.SearchAssetsRequest, ...gax.CallOption) *SearchResultItemIterator
1663 SearchIndexEndpoint(context.Context, *visionaipb.SearchIndexEndpointRequest, ...gax.CallOption) *SearchResultItemIterator
1664 CreateIndexEndpoint(context.Context, *visionaipb.CreateIndexEndpointRequest, ...gax.CallOption) (*CreateIndexEndpointOperation, error)
1665 CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation
1666 GetIndexEndpoint(context.Context, *visionaipb.GetIndexEndpointRequest, ...gax.CallOption) (*visionaipb.IndexEndpoint, error)
1667 ListIndexEndpoints(context.Context, *visionaipb.ListIndexEndpointsRequest, ...gax.CallOption) *IndexEndpointIterator
1668 UpdateIndexEndpoint(context.Context, *visionaipb.UpdateIndexEndpointRequest, ...gax.CallOption) (*UpdateIndexEndpointOperation, error)
1669 UpdateIndexEndpointOperation(name string) *UpdateIndexEndpointOperation
1670 DeleteIndexEndpoint(context.Context, *visionaipb.DeleteIndexEndpointRequest, ...gax.CallOption) (*DeleteIndexEndpointOperation, error)
1671 DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation
1672 DeployIndex(context.Context, *visionaipb.DeployIndexRequest, ...gax.CallOption) (*DeployIndexOperation, error)
1673 DeployIndexOperation(name string) *DeployIndexOperation
1674 UndeployIndex(context.Context, *visionaipb.UndeployIndexRequest, ...gax.CallOption) (*UndeployIndexOperation, error)
1675 UndeployIndexOperation(name string) *UndeployIndexOperation
1676 CreateCollection(context.Context, *visionaipb.CreateCollectionRequest, ...gax.CallOption) (*CreateCollectionOperation, error)
1677 CreateCollectionOperation(name string) *CreateCollectionOperation
1678 DeleteCollection(context.Context, *visionaipb.DeleteCollectionRequest, ...gax.CallOption) (*DeleteCollectionOperation, error)
1679 DeleteCollectionOperation(name string) *DeleteCollectionOperation
1680 GetCollection(context.Context, *visionaipb.GetCollectionRequest, ...gax.CallOption) (*visionaipb.Collection, error)
1681 UpdateCollection(context.Context, *visionaipb.UpdateCollectionRequest, ...gax.CallOption) (*visionaipb.Collection, error)
1682 ListCollections(context.Context, *visionaipb.ListCollectionsRequest, ...gax.CallOption) *CollectionIterator
1683 AddCollectionItem(context.Context, *visionaipb.AddCollectionItemRequest, ...gax.CallOption) (*visionaipb.AddCollectionItemResponse, error)
1684 RemoveCollectionItem(context.Context, *visionaipb.RemoveCollectionItemRequest, ...gax.CallOption) (*visionaipb.RemoveCollectionItemResponse, error)
1685 ViewCollectionItems(context.Context, *visionaipb.ViewCollectionItemsRequest, ...gax.CallOption) *CollectionItemIterator
1686 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
1687 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
1688 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
1689 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
1690 }
1691
1692 // WarehouseClient is a client for interacting with Vision AI API.
1693 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
1694 //
1695 // Service that manages media content + metadata for streaming.
1696 type WarehouseClient struct {
1697 // The internal transport-dependent client.
1698 internalClient internalWarehouseClient
1699
1700 // The call options for this service.
1701 CallOptions *WarehouseCallOptions
1702
1703 // LROClient is used internally to handle long-running operations.
1704 // It is exposed so that its CallOptions can be modified if required.
1705 // Users should not Close this client.
1706 LROClient *lroauto.OperationsClient
1707 }
1708
1709 // Wrapper methods routed to the internal client.
1710
1711 // Close closes the connection to the API service. The user should invoke this when
1712 // the client is no longer required.
1713 func (c *WarehouseClient) Close() error {
1714 return c.internalClient.Close()
1715 }
1716
1717 // setGoogleClientInfo sets the name and version of the application in
1718 // the `x-goog-api-client` header passed on each request. Intended for
1719 // use by Google-written clients.
1720 func (c *WarehouseClient) setGoogleClientInfo(keyval ...string) {
1721 c.internalClient.setGoogleClientInfo(keyval...)
1722 }
1723
1724 // Connection returns a connection to the API service.
1725 //
1726 // Deprecated: Connections are now pooled so this method does not always
1727 // return the same resource.
1728 func (c *WarehouseClient) Connection() *grpc.ClientConn {
1729 return c.internalClient.Connection()
1730 }
1731
1732 // CreateAsset creates an asset inside corpus.
1733 func (c *WarehouseClient) CreateAsset(ctx context.Context, req *visionaipb.CreateAssetRequest, opts ...gax.CallOption) (*visionaipb.Asset, error) {
1734 return c.internalClient.CreateAsset(ctx, req, opts...)
1735 }
1736
1737 // UpdateAsset updates an asset inside corpus.
1738 func (c *WarehouseClient) UpdateAsset(ctx context.Context, req *visionaipb.UpdateAssetRequest, opts ...gax.CallOption) (*visionaipb.Asset, error) {
1739 return c.internalClient.UpdateAsset(ctx, req, opts...)
1740 }
1741
1742 // GetAsset reads an asset inside corpus.
1743 func (c *WarehouseClient) GetAsset(ctx context.Context, req *visionaipb.GetAssetRequest, opts ...gax.CallOption) (*visionaipb.Asset, error) {
1744 return c.internalClient.GetAsset(ctx, req, opts...)
1745 }
1746
1747 // ListAssets lists an list of assets inside corpus.
1748 func (c *WarehouseClient) ListAssets(ctx context.Context, req *visionaipb.ListAssetsRequest, opts ...gax.CallOption) *AssetIterator {
1749 return c.internalClient.ListAssets(ctx, req, opts...)
1750 }
1751
1752 // DeleteAsset deletes asset inside corpus.
1753 func (c *WarehouseClient) DeleteAsset(ctx context.Context, req *visionaipb.DeleteAssetRequest, opts ...gax.CallOption) (*DeleteAssetOperation, error) {
1754 return c.internalClient.DeleteAsset(ctx, req, opts...)
1755 }
1756
1757 // DeleteAssetOperation returns a new DeleteAssetOperation from a given name.
1758 // The name must be that of a previously created DeleteAssetOperation, possibly from a different process.
1759 func (c *WarehouseClient) DeleteAssetOperation(name string) *DeleteAssetOperation {
1760 return c.internalClient.DeleteAssetOperation(name)
1761 }
1762
1763 // UploadAsset upload asset by specifing the asset Cloud Storage uri.
1764 // For video warehouse, it requires users who call this API have read access
1765 // to the cloud storage file. Once it is uploaded, it can be retrieved by
1766 // GenerateRetrievalUrl API which by default, only can retrieve cloud storage
1767 // files from the same project of the warehouse. To allow retrieval cloud
1768 // storage files that are in a separate project, it requires to find the
1769 // vision ai service account (Go to IAM, check checkbox to show “Include
1770 // Google-provided role grants”, search for “Cloud Vision AI Service Agent”)
1771 // and grant the read access of the cloud storage files to that service
1772 // account.
1773 func (c *WarehouseClient) UploadAsset(ctx context.Context, req *visionaipb.UploadAssetRequest, opts ...gax.CallOption) (*UploadAssetOperation, error) {
1774 return c.internalClient.UploadAsset(ctx, req, opts...)
1775 }
1776
1777 // UploadAssetOperation returns a new UploadAssetOperation from a given name.
1778 // The name must be that of a previously created UploadAssetOperation, possibly from a different process.
1779 func (c *WarehouseClient) UploadAssetOperation(name string) *UploadAssetOperation {
1780 return c.internalClient.UploadAssetOperation(name)
1781 }
1782
1783 // GenerateRetrievalUrl generates a signed url for downloading the asset.
1784 // For video warehouse, please see comment of UploadAsset about how to allow
1785 // retrieval of cloud storage files in a different project.
1786 func (c *WarehouseClient) GenerateRetrievalUrl(ctx context.Context, req *visionaipb.GenerateRetrievalUrlRequest, opts ...gax.CallOption) (*visionaipb.GenerateRetrievalUrlResponse, error) {
1787 return c.internalClient.GenerateRetrievalUrl(ctx, req, opts...)
1788 }
1789
1790 // AnalyzeAsset analyze asset to power search capability.
1791 func (c *WarehouseClient) AnalyzeAsset(ctx context.Context, req *visionaipb.AnalyzeAssetRequest, opts ...gax.CallOption) (*AnalyzeAssetOperation, error) {
1792 return c.internalClient.AnalyzeAsset(ctx, req, opts...)
1793 }
1794
1795 // AnalyzeAssetOperation returns a new AnalyzeAssetOperation from a given name.
1796 // The name must be that of a previously created AnalyzeAssetOperation, possibly from a different process.
1797 func (c *WarehouseClient) AnalyzeAssetOperation(name string) *AnalyzeAssetOperation {
1798 return c.internalClient.AnalyzeAssetOperation(name)
1799 }
1800
1801 // IndexAsset index one asset for search.
1802 // Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND
1803 func (c *WarehouseClient) IndexAsset(ctx context.Context, req *visionaipb.IndexAssetRequest, opts ...gax.CallOption) (*IndexAssetOperation, error) {
1804 return c.internalClient.IndexAsset(ctx, req, opts...)
1805 }
1806
1807 // IndexAssetOperation returns a new IndexAssetOperation from a given name.
1808 // The name must be that of a previously created IndexAssetOperation, possibly from a different process.
1809 func (c *WarehouseClient) IndexAssetOperation(name string) *IndexAssetOperation {
1810 return c.internalClient.IndexAssetOperation(name)
1811 }
1812
1813 // RemoveIndexAsset remove one asset’s index data for search.
1814 // Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND
1815 func (c *WarehouseClient) RemoveIndexAsset(ctx context.Context, req *visionaipb.RemoveIndexAssetRequest, opts ...gax.CallOption) (*RemoveIndexAssetOperation, error) {
1816 return c.internalClient.RemoveIndexAsset(ctx, req, opts...)
1817 }
1818
1819 // RemoveIndexAssetOperation returns a new RemoveIndexAssetOperation from a given name.
1820 // The name must be that of a previously created RemoveIndexAssetOperation, possibly from a different process.
1821 func (c *WarehouseClient) RemoveIndexAssetOperation(name string) *RemoveIndexAssetOperation {
1822 return c.internalClient.RemoveIndexAssetOperation(name)
1823 }
1824
1825 // ViewIndexedAssets lists assets inside an index.
1826 func (c *WarehouseClient) ViewIndexedAssets(ctx context.Context, req *visionaipb.ViewIndexedAssetsRequest, opts ...gax.CallOption) *IndexedAssetIterator {
1827 return c.internalClient.ViewIndexedAssets(ctx, req, opts...)
1828 }
1829
1830 // CreateIndex creates an Index under the corpus.
1831 func (c *WarehouseClient) CreateIndex(ctx context.Context, req *visionaipb.CreateIndexRequest, opts ...gax.CallOption) (*CreateIndexOperation, error) {
1832 return c.internalClient.CreateIndex(ctx, req, opts...)
1833 }
1834
1835 // CreateIndexOperation returns a new CreateIndexOperation from a given name.
1836 // The name must be that of a previously created CreateIndexOperation, possibly from a different process.
1837 func (c *WarehouseClient) CreateIndexOperation(name string) *CreateIndexOperation {
1838 return c.internalClient.CreateIndexOperation(name)
1839 }
1840
1841 // UpdateIndex updates an Index under the corpus.
1842 // Users can perform a metadata-only update or trigger a full index rebuild
1843 // with different update_mask values.
1844 func (c *WarehouseClient) UpdateIndex(ctx context.Context, req *visionaipb.UpdateIndexRequest, opts ...gax.CallOption) (*UpdateIndexOperation, error) {
1845 return c.internalClient.UpdateIndex(ctx, req, opts...)
1846 }
1847
1848 // UpdateIndexOperation returns a new UpdateIndexOperation from a given name.
1849 // The name must be that of a previously created UpdateIndexOperation, possibly from a different process.
1850 func (c *WarehouseClient) UpdateIndexOperation(name string) *UpdateIndexOperation {
1851 return c.internalClient.UpdateIndexOperation(name)
1852 }
1853
1854 // GetIndex gets the details of a single Index under a Corpus.
1855 func (c *WarehouseClient) GetIndex(ctx context.Context, req *visionaipb.GetIndexRequest, opts ...gax.CallOption) (*visionaipb.Index, error) {
1856 return c.internalClient.GetIndex(ctx, req, opts...)
1857 }
1858
1859 // ListIndexes list all Indexes in a given Corpus.
1860 func (c *WarehouseClient) ListIndexes(ctx context.Context, req *visionaipb.ListIndexesRequest, opts ...gax.CallOption) *IndexIterator {
1861 return c.internalClient.ListIndexes(ctx, req, opts...)
1862 }
1863
1864 // DeleteIndex delete a single Index. In order to delete an index, the caller must
1865 // make sure that it is not deployed to any index endpoint.
1866 func (c *WarehouseClient) DeleteIndex(ctx context.Context, req *visionaipb.DeleteIndexRequest, opts ...gax.CallOption) (*DeleteIndexOperation, error) {
1867 return c.internalClient.DeleteIndex(ctx, req, opts...)
1868 }
1869
1870 // DeleteIndexOperation returns a new DeleteIndexOperation from a given name.
1871 // The name must be that of a previously created DeleteIndexOperation, possibly from a different process.
1872 func (c *WarehouseClient) DeleteIndexOperation(name string) *DeleteIndexOperation {
1873 return c.internalClient.DeleteIndexOperation(name)
1874 }
1875
1876 // CreateCorpus creates a corpus inside a project.
1877 func (c *WarehouseClient) CreateCorpus(ctx context.Context, req *visionaipb.CreateCorpusRequest, opts ...gax.CallOption) (*CreateCorpusOperation, error) {
1878 return c.internalClient.CreateCorpus(ctx, req, opts...)
1879 }
1880
1881 // CreateCorpusOperation returns a new CreateCorpusOperation from a given name.
1882 // The name must be that of a previously created CreateCorpusOperation, possibly from a different process.
1883 func (c *WarehouseClient) CreateCorpusOperation(name string) *CreateCorpusOperation {
1884 return c.internalClient.CreateCorpusOperation(name)
1885 }
1886
1887 // GetCorpus gets corpus details inside a project.
1888 func (c *WarehouseClient) GetCorpus(ctx context.Context, req *visionaipb.GetCorpusRequest, opts ...gax.CallOption) (*visionaipb.Corpus, error) {
1889 return c.internalClient.GetCorpus(ctx, req, opts...)
1890 }
1891
1892 // UpdateCorpus updates a corpus in a project.
1893 func (c *WarehouseClient) UpdateCorpus(ctx context.Context, req *visionaipb.UpdateCorpusRequest, opts ...gax.CallOption) (*visionaipb.Corpus, error) {
1894 return c.internalClient.UpdateCorpus(ctx, req, opts...)
1895 }
1896
1897 // ListCorpora lists all corpora in a project.
1898 func (c *WarehouseClient) ListCorpora(ctx context.Context, req *visionaipb.ListCorporaRequest, opts ...gax.CallOption) *CorpusIterator {
1899 return c.internalClient.ListCorpora(ctx, req, opts...)
1900 }
1901
1902 // DeleteCorpus deletes a corpus only if its empty.
1903 // Returns empty response.
1904 func (c *WarehouseClient) DeleteCorpus(ctx context.Context, req *visionaipb.DeleteCorpusRequest, opts ...gax.CallOption) error {
1905 return c.internalClient.DeleteCorpus(ctx, req, opts...)
1906 }
1907
1908 // AnalyzeCorpus analyzes a corpus.
1909 func (c *WarehouseClient) AnalyzeCorpus(ctx context.Context, req *visionaipb.AnalyzeCorpusRequest, opts ...gax.CallOption) (*AnalyzeCorpusOperation, error) {
1910 return c.internalClient.AnalyzeCorpus(ctx, req, opts...)
1911 }
1912
1913 // AnalyzeCorpusOperation returns a new AnalyzeCorpusOperation from a given name.
1914 // The name must be that of a previously created AnalyzeCorpusOperation, possibly from a different process.
1915 func (c *WarehouseClient) AnalyzeCorpusOperation(name string) *AnalyzeCorpusOperation {
1916 return c.internalClient.AnalyzeCorpusOperation(name)
1917 }
1918
1919 // CreateDataSchema creates data schema inside corpus.
1920 func (c *WarehouseClient) CreateDataSchema(ctx context.Context, req *visionaipb.CreateDataSchemaRequest, opts ...gax.CallOption) (*visionaipb.DataSchema, error) {
1921 return c.internalClient.CreateDataSchema(ctx, req, opts...)
1922 }
1923
1924 // UpdateDataSchema updates data schema inside corpus.
1925 func (c *WarehouseClient) UpdateDataSchema(ctx context.Context, req *visionaipb.UpdateDataSchemaRequest, opts ...gax.CallOption) (*visionaipb.DataSchema, error) {
1926 return c.internalClient.UpdateDataSchema(ctx, req, opts...)
1927 }
1928
1929 // GetDataSchema gets data schema inside corpus.
1930 func (c *WarehouseClient) GetDataSchema(ctx context.Context, req *visionaipb.GetDataSchemaRequest, opts ...gax.CallOption) (*visionaipb.DataSchema, error) {
1931 return c.internalClient.GetDataSchema(ctx, req, opts...)
1932 }
1933
1934 // DeleteDataSchema deletes data schema inside corpus.
1935 func (c *WarehouseClient) DeleteDataSchema(ctx context.Context, req *visionaipb.DeleteDataSchemaRequest, opts ...gax.CallOption) error {
1936 return c.internalClient.DeleteDataSchema(ctx, req, opts...)
1937 }
1938
1939 // ListDataSchemas lists a list of data schemas inside corpus.
1940 func (c *WarehouseClient) ListDataSchemas(ctx context.Context, req *visionaipb.ListDataSchemasRequest, opts ...gax.CallOption) *DataSchemaIterator {
1941 return c.internalClient.ListDataSchemas(ctx, req, opts...)
1942 }
1943
1944 // CreateAnnotation creates annotation inside asset.
1945 func (c *WarehouseClient) CreateAnnotation(ctx context.Context, req *visionaipb.CreateAnnotationRequest, opts ...gax.CallOption) (*visionaipb.Annotation, error) {
1946 return c.internalClient.CreateAnnotation(ctx, req, opts...)
1947 }
1948
1949 // GetAnnotation reads annotation inside asset.
1950 func (c *WarehouseClient) GetAnnotation(ctx context.Context, req *visionaipb.GetAnnotationRequest, opts ...gax.CallOption) (*visionaipb.Annotation, error) {
1951 return c.internalClient.GetAnnotation(ctx, req, opts...)
1952 }
1953
1954 // ListAnnotations lists a list of annotations inside asset.
1955 func (c *WarehouseClient) ListAnnotations(ctx context.Context, req *visionaipb.ListAnnotationsRequest, opts ...gax.CallOption) *AnnotationIterator {
1956 return c.internalClient.ListAnnotations(ctx, req, opts...)
1957 }
1958
1959 // UpdateAnnotation updates annotation inside asset.
1960 func (c *WarehouseClient) UpdateAnnotation(ctx context.Context, req *visionaipb.UpdateAnnotationRequest, opts ...gax.CallOption) (*visionaipb.Annotation, error) {
1961 return c.internalClient.UpdateAnnotation(ctx, req, opts...)
1962 }
1963
1964 // DeleteAnnotation deletes annotation inside asset.
1965 func (c *WarehouseClient) DeleteAnnotation(ctx context.Context, req *visionaipb.DeleteAnnotationRequest, opts ...gax.CallOption) error {
1966 return c.internalClient.DeleteAnnotation(ctx, req, opts...)
1967 }
1968
1969 // IngestAsset ingests data for the asset. It is not allowed to ingest a data chunk which
1970 // is already expired according to TTL.
1971 // This method is only available via the gRPC API (not HTTP since
1972 // bi-directional streaming is not supported via HTTP).
1973 //
1974 // This method is not supported for the REST transport.
1975 func (c *WarehouseClient) IngestAsset(ctx context.Context, opts ...gax.CallOption) (visionaipb.Warehouse_IngestAssetClient, error) {
1976 return c.internalClient.IngestAsset(ctx, opts...)
1977 }
1978
1979 // ClipAsset supported by STREAM_VIDEO corpus type.
1980 // Generates clips for downloading. The api takes in a time range, and
1981 // generates a clip of the first content available after start_time and
1982 // before end_time, which may overflow beyond these bounds.
1983 // Returned clips are truncated if the total size of the clips are larger
1984 // than 100MB.
1985 func (c *WarehouseClient) ClipAsset(ctx context.Context, req *visionaipb.ClipAssetRequest, opts ...gax.CallOption) (*visionaipb.ClipAssetResponse, error) {
1986 return c.internalClient.ClipAsset(ctx, req, opts...)
1987 }
1988
1989 // GenerateHlsUri generates a uri for an HLS manifest. The api takes in a collection of time
1990 // ranges, and generates a URI for an HLS manifest that covers all the
1991 // requested time ranges.
1992 func (c *WarehouseClient) GenerateHlsUri(ctx context.Context, req *visionaipb.GenerateHlsUriRequest, opts ...gax.CallOption) (*visionaipb.GenerateHlsUriResponse, error) {
1993 return c.internalClient.GenerateHlsUri(ctx, req, opts...)
1994 }
1995
1996 // ImportAssets imports assets (images plus annotations) from a meta file on cloud storage.
1997 // Each row in the meta file is corresponding to an image (specified by a
1998 // cloud storage uri) and its annotations.
1999 func (c *WarehouseClient) ImportAssets(ctx context.Context, req *visionaipb.ImportAssetsRequest, opts ...gax.CallOption) (*ImportAssetsOperation, error) {
2000 return c.internalClient.ImportAssets(ctx, req, opts...)
2001 }
2002
2003 // ImportAssetsOperation returns a new ImportAssetsOperation from a given name.
2004 // The name must be that of a previously created ImportAssetsOperation, possibly from a different process.
2005 func (c *WarehouseClient) ImportAssetsOperation(name string) *ImportAssetsOperation {
2006 return c.internalClient.ImportAssetsOperation(name)
2007 }
2008
2009 // CreateSearchConfig creates a search configuration inside a corpus.
2010 //
2011 // Please follow the rules below to create a valid CreateSearchConfigRequest.
2012 // — General Rules —
2013 //
2014 // Request.search_config_id must not be associated with an existing
2015 // SearchConfig.
2016 //
2017 // Request must contain at least one non-empty search_criteria_property or
2018 // facet_property.
2019 //
2020 // mapped_fields must not be empty, and must map to existing UGA keys.
2021 //
2022 // All mapped_fields must be of the same type.
2023 //
2024 // All mapped_fields must share the same granularity.
2025 //
2026 // All mapped_fields must share the same semantic SearchConfig match
2027 // options.
2028 // For property-specific rules, please reference the comments for
2029 // FacetProperty and SearchCriteriaProperty.
2030 func (c *WarehouseClient) CreateSearchConfig(ctx context.Context, req *visionaipb.CreateSearchConfigRequest, opts ...gax.CallOption) (*visionaipb.SearchConfig, error) {
2031 return c.internalClient.CreateSearchConfig(ctx, req, opts...)
2032 }
2033
2034 // UpdateSearchConfig updates a search configuration inside a corpus.
2035 //
2036 // Please follow the rules below to create a valid UpdateSearchConfigRequest.
2037 // — General Rules —
2038 //
2039 // Request.search_configuration.name must already exist.
2040 //
2041 // Request must contain at least one non-empty search_criteria_property or
2042 // facet_property.
2043 //
2044 // mapped_fields must not be empty, and must map to existing UGA keys.
2045 //
2046 // All mapped_fields must be of the same type.
2047 //
2048 // All mapped_fields must share the same granularity.
2049 //
2050 // All mapped_fields must share the same semantic SearchConfig match
2051 // options.
2052 // For property-specific rules, please reference the comments for
2053 // FacetProperty and SearchCriteriaProperty.
2054 func (c *WarehouseClient) UpdateSearchConfig(ctx context.Context, req *visionaipb.UpdateSearchConfigRequest, opts ...gax.CallOption) (*visionaipb.SearchConfig, error) {
2055 return c.internalClient.UpdateSearchConfig(ctx, req, opts...)
2056 }
2057
2058 // GetSearchConfig gets a search configuration inside a corpus.
2059 func (c *WarehouseClient) GetSearchConfig(ctx context.Context, req *visionaipb.GetSearchConfigRequest, opts ...gax.CallOption) (*visionaipb.SearchConfig, error) {
2060 return c.internalClient.GetSearchConfig(ctx, req, opts...)
2061 }
2062
2063 // DeleteSearchConfig deletes a search configuration inside a corpus.
2064 //
2065 // For a DeleteSearchConfigRequest to be valid,
2066 // Request.search_configuration.name must already exist.
2067 func (c *WarehouseClient) DeleteSearchConfig(ctx context.Context, req *visionaipb.DeleteSearchConfigRequest, opts ...gax.CallOption) error {
2068 return c.internalClient.DeleteSearchConfig(ctx, req, opts...)
2069 }
2070
2071 // ListSearchConfigs lists all search configurations inside a corpus.
2072 func (c *WarehouseClient) ListSearchConfigs(ctx context.Context, req *visionaipb.ListSearchConfigsRequest, opts ...gax.CallOption) *SearchConfigIterator {
2073 return c.internalClient.ListSearchConfigs(ctx, req, opts...)
2074 }
2075
2076 // CreateSearchHypernym creates a SearchHypernym inside a corpus.
2077 func (c *WarehouseClient) CreateSearchHypernym(ctx context.Context, req *visionaipb.CreateSearchHypernymRequest, opts ...gax.CallOption) (*visionaipb.SearchHypernym, error) {
2078 return c.internalClient.CreateSearchHypernym(ctx, req, opts...)
2079 }
2080
2081 // UpdateSearchHypernym updates a SearchHypernym inside a corpus.
2082 func (c *WarehouseClient) UpdateSearchHypernym(ctx context.Context, req *visionaipb.UpdateSearchHypernymRequest, opts ...gax.CallOption) (*visionaipb.SearchHypernym, error) {
2083 return c.internalClient.UpdateSearchHypernym(ctx, req, opts...)
2084 }
2085
2086 // GetSearchHypernym gets a SearchHypernym inside a corpus.
2087 func (c *WarehouseClient) GetSearchHypernym(ctx context.Context, req *visionaipb.GetSearchHypernymRequest, opts ...gax.CallOption) (*visionaipb.SearchHypernym, error) {
2088 return c.internalClient.GetSearchHypernym(ctx, req, opts...)
2089 }
2090
2091 // DeleteSearchHypernym deletes a SearchHypernym inside a corpus.
2092 func (c *WarehouseClient) DeleteSearchHypernym(ctx context.Context, req *visionaipb.DeleteSearchHypernymRequest, opts ...gax.CallOption) error {
2093 return c.internalClient.DeleteSearchHypernym(ctx, req, opts...)
2094 }
2095
2096 // ListSearchHypernyms lists SearchHypernyms inside a corpus.
2097 func (c *WarehouseClient) ListSearchHypernyms(ctx context.Context, req *visionaipb.ListSearchHypernymsRequest, opts ...gax.CallOption) *SearchHypernymIterator {
2098 return c.internalClient.ListSearchHypernyms(ctx, req, opts...)
2099 }
2100
2101 // SearchAssets search media asset.
2102 func (c *WarehouseClient) SearchAssets(ctx context.Context, req *visionaipb.SearchAssetsRequest, opts ...gax.CallOption) *SearchResultItemIterator {
2103 return c.internalClient.SearchAssets(ctx, req, opts...)
2104 }
2105
2106 // SearchIndexEndpoint search a deployed index endpoint (IMAGE corpus type only).
2107 func (c *WarehouseClient) SearchIndexEndpoint(ctx context.Context, req *visionaipb.SearchIndexEndpointRequest, opts ...gax.CallOption) *SearchResultItemIterator {
2108 return c.internalClient.SearchIndexEndpoint(ctx, req, opts...)
2109 }
2110
2111 // CreateIndexEndpoint creates an IndexEndpoint.
2112 func (c *WarehouseClient) CreateIndexEndpoint(ctx context.Context, req *visionaipb.CreateIndexEndpointRequest, opts ...gax.CallOption) (*CreateIndexEndpointOperation, error) {
2113 return c.internalClient.CreateIndexEndpoint(ctx, req, opts...)
2114 }
2115
2116 // CreateIndexEndpointOperation returns a new CreateIndexEndpointOperation from a given name.
2117 // The name must be that of a previously created CreateIndexEndpointOperation, possibly from a different process.
2118 func (c *WarehouseClient) CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation {
2119 return c.internalClient.CreateIndexEndpointOperation(name)
2120 }
2121
2122 // GetIndexEndpoint gets an IndexEndpoint.
2123 func (c *WarehouseClient) GetIndexEndpoint(ctx context.Context, req *visionaipb.GetIndexEndpointRequest, opts ...gax.CallOption) (*visionaipb.IndexEndpoint, error) {
2124 return c.internalClient.GetIndexEndpoint(ctx, req, opts...)
2125 }
2126
2127 // ListIndexEndpoints lists all IndexEndpoints in a project.
2128 func (c *WarehouseClient) ListIndexEndpoints(ctx context.Context, req *visionaipb.ListIndexEndpointsRequest, opts ...gax.CallOption) *IndexEndpointIterator {
2129 return c.internalClient.ListIndexEndpoints(ctx, req, opts...)
2130 }
2131
2132 // UpdateIndexEndpoint updates an IndexEndpoint.
2133 func (c *WarehouseClient) UpdateIndexEndpoint(ctx context.Context, req *visionaipb.UpdateIndexEndpointRequest, opts ...gax.CallOption) (*UpdateIndexEndpointOperation, error) {
2134 return c.internalClient.UpdateIndexEndpoint(ctx, req, opts...)
2135 }
2136
2137 // UpdateIndexEndpointOperation returns a new UpdateIndexEndpointOperation from a given name.
2138 // The name must be that of a previously created UpdateIndexEndpointOperation, possibly from a different process.
2139 func (c *WarehouseClient) UpdateIndexEndpointOperation(name string) *UpdateIndexEndpointOperation {
2140 return c.internalClient.UpdateIndexEndpointOperation(name)
2141 }
2142
2143 // DeleteIndexEndpoint deletes an IndexEndpoint.
2144 func (c *WarehouseClient) DeleteIndexEndpoint(ctx context.Context, req *visionaipb.DeleteIndexEndpointRequest, opts ...gax.CallOption) (*DeleteIndexEndpointOperation, error) {
2145 return c.internalClient.DeleteIndexEndpoint(ctx, req, opts...)
2146 }
2147
2148 // DeleteIndexEndpointOperation returns a new DeleteIndexEndpointOperation from a given name.
2149 // The name must be that of a previously created DeleteIndexEndpointOperation, possibly from a different process.
2150 func (c *WarehouseClient) DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation {
2151 return c.internalClient.DeleteIndexEndpointOperation(name)
2152 }
2153
2154 // DeployIndex deploys an Index to IndexEndpoint.
2155 func (c *WarehouseClient) DeployIndex(ctx context.Context, req *visionaipb.DeployIndexRequest, opts ...gax.CallOption) (*DeployIndexOperation, error) {
2156 return c.internalClient.DeployIndex(ctx, req, opts...)
2157 }
2158
2159 // DeployIndexOperation returns a new DeployIndexOperation from a given name.
2160 // The name must be that of a previously created DeployIndexOperation, possibly from a different process.
2161 func (c *WarehouseClient) DeployIndexOperation(name string) *DeployIndexOperation {
2162 return c.internalClient.DeployIndexOperation(name)
2163 }
2164
2165 // UndeployIndex undeploys an Index from IndexEndpoint.
2166 func (c *WarehouseClient) UndeployIndex(ctx context.Context, req *visionaipb.UndeployIndexRequest, opts ...gax.CallOption) (*UndeployIndexOperation, error) {
2167 return c.internalClient.UndeployIndex(ctx, req, opts...)
2168 }
2169
2170 // UndeployIndexOperation returns a new UndeployIndexOperation from a given name.
2171 // The name must be that of a previously created UndeployIndexOperation, possibly from a different process.
2172 func (c *WarehouseClient) UndeployIndexOperation(name string) *UndeployIndexOperation {
2173 return c.internalClient.UndeployIndexOperation(name)
2174 }
2175
2176 // CreateCollection creates a collection.
2177 func (c *WarehouseClient) CreateCollection(ctx context.Context, req *visionaipb.CreateCollectionRequest, opts ...gax.CallOption) (*CreateCollectionOperation, error) {
2178 return c.internalClient.CreateCollection(ctx, req, opts...)
2179 }
2180
2181 // CreateCollectionOperation returns a new CreateCollectionOperation from a given name.
2182 // The name must be that of a previously created CreateCollectionOperation, possibly from a different process.
2183 func (c *WarehouseClient) CreateCollectionOperation(name string) *CreateCollectionOperation {
2184 return c.internalClient.CreateCollectionOperation(name)
2185 }
2186
2187 // DeleteCollection deletes a collection.
2188 func (c *WarehouseClient) DeleteCollection(ctx context.Context, req *visionaipb.DeleteCollectionRequest, opts ...gax.CallOption) (*DeleteCollectionOperation, error) {
2189 return c.internalClient.DeleteCollection(ctx, req, opts...)
2190 }
2191
2192 // DeleteCollectionOperation returns a new DeleteCollectionOperation from a given name.
2193 // The name must be that of a previously created DeleteCollectionOperation, possibly from a different process.
2194 func (c *WarehouseClient) DeleteCollectionOperation(name string) *DeleteCollectionOperation {
2195 return c.internalClient.DeleteCollectionOperation(name)
2196 }
2197
2198 // GetCollection gets a collection.
2199 func (c *WarehouseClient) GetCollection(ctx context.Context, req *visionaipb.GetCollectionRequest, opts ...gax.CallOption) (*visionaipb.Collection, error) {
2200 return c.internalClient.GetCollection(ctx, req, opts...)
2201 }
2202
2203 // UpdateCollection updates a collection.
2204 func (c *WarehouseClient) UpdateCollection(ctx context.Context, req *visionaipb.UpdateCollectionRequest, opts ...gax.CallOption) (*visionaipb.Collection, error) {
2205 return c.internalClient.UpdateCollection(ctx, req, opts...)
2206 }
2207
2208 // ListCollections lists collections inside a corpus.
2209 func (c *WarehouseClient) ListCollections(ctx context.Context, req *visionaipb.ListCollectionsRequest, opts ...gax.CallOption) *CollectionIterator {
2210 return c.internalClient.ListCollections(ctx, req, opts...)
2211 }
2212
2213 // AddCollectionItem adds an item into a Collection.
2214 func (c *WarehouseClient) AddCollectionItem(ctx context.Context, req *visionaipb.AddCollectionItemRequest, opts ...gax.CallOption) (*visionaipb.AddCollectionItemResponse, error) {
2215 return c.internalClient.AddCollectionItem(ctx, req, opts...)
2216 }
2217
2218 // RemoveCollectionItem removes an item from a collection.
2219 func (c *WarehouseClient) RemoveCollectionItem(ctx context.Context, req *visionaipb.RemoveCollectionItemRequest, opts ...gax.CallOption) (*visionaipb.RemoveCollectionItemResponse, error) {
2220 return c.internalClient.RemoveCollectionItem(ctx, req, opts...)
2221 }
2222
2223 // ViewCollectionItems view items inside a collection.
2224 func (c *WarehouseClient) ViewCollectionItems(ctx context.Context, req *visionaipb.ViewCollectionItemsRequest, opts ...gax.CallOption) *CollectionItemIterator {
2225 return c.internalClient.ViewCollectionItems(ctx, req, opts...)
2226 }
2227
2228 // CancelOperation is a utility method from google.longrunning.Operations.
2229 func (c *WarehouseClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
2230 return c.internalClient.CancelOperation(ctx, req, opts...)
2231 }
2232
2233 // DeleteOperation is a utility method from google.longrunning.Operations.
2234 func (c *WarehouseClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
2235 return c.internalClient.DeleteOperation(ctx, req, opts...)
2236 }
2237
2238 // GetOperation is a utility method from google.longrunning.Operations.
2239 func (c *WarehouseClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
2240 return c.internalClient.GetOperation(ctx, req, opts...)
2241 }
2242
2243 // ListOperations is a utility method from google.longrunning.Operations.
2244 func (c *WarehouseClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
2245 return c.internalClient.ListOperations(ctx, req, opts...)
2246 }
2247
2248 // warehouseGRPCClient is a client for interacting with Vision AI API over gRPC transport.
2249 //
2250 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
2251 type warehouseGRPCClient struct {
2252 // Connection pool of gRPC connections to the service.
2253 connPool gtransport.ConnPool
2254
2255 // Points back to the CallOptions field of the containing WarehouseClient
2256 CallOptions **WarehouseCallOptions
2257
2258 // The gRPC API client.
2259 warehouseClient visionaipb.WarehouseClient
2260
2261 // LROClient is used internally to handle long-running operations.
2262 // It is exposed so that its CallOptions can be modified if required.
2263 // Users should not Close this client.
2264 LROClient **lroauto.OperationsClient
2265
2266 operationsClient longrunningpb.OperationsClient
2267
2268 // The x-goog-* metadata to be sent with each request.
2269 xGoogHeaders []string
2270
2271 logger *slog.Logger
2272 }
2273
2274 // NewWarehouseClient creates a new warehouse client based on gRPC.
2275 // The returned client must be Closed when it is done being used to clean up its underlying connections.
2276 //
2277 // Service that manages media content + metadata for streaming.
2278 func NewWarehouseClient(ctx context.Context, opts ...option.ClientOption) (*WarehouseClient, error) {
2279 clientOpts := defaultWarehouseGRPCClientOptions()
2280 if newWarehouseClientHook != nil {
2281 hookOpts, err := newWarehouseClientHook(ctx, clientHookParams{})
2282 if err != nil {
2283 return nil, err
2284 }
2285 clientOpts = append(clientOpts, hookOpts...)
2286 }
2287
2288 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
2289 if err != nil {
2290 return nil, err
2291 }
2292 client := WarehouseClient{CallOptions: defaultWarehouseCallOptions()}
2293
2294 c := &warehouseGRPCClient{
2295 connPool: connPool,
2296 warehouseClient: visionaipb.NewWarehouseClient(connPool),
2297 CallOptions: &client.CallOptions,
2298 logger: internaloption.GetLogger(opts),
2299 operationsClient: longrunningpb.NewOperationsClient(connPool),
2300 }
2301 c.setGoogleClientInfo()
2302
2303 client.internalClient = c
2304
2305 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
2306 if err != nil {
2307 // This error "should not happen", since we are just reusing old connection pool
2308 // and never actually need to dial.
2309 // If this does happen, we could leak connp. However, we cannot close conn:
2310 // If the user invoked the constructor with option.WithGRPCConn,
2311 // we would close a connection that's still in use.
2312 // TODO: investigate error conditions.
2313 return nil, err
2314 }
2315 c.LROClient = &client.LROClient
2316 return &client, nil
2317 }
2318
2319 // Connection returns a connection to the API service.
2320 //
2321 // Deprecated: Connections are now pooled so this method does not always
2322 // return the same resource.
2323 func (c *warehouseGRPCClient) Connection() *grpc.ClientConn {
2324 return c.connPool.Conn()
2325 }
2326
2327 // setGoogleClientInfo sets the name and version of the application in
2328 // the `x-goog-api-client` header passed on each request. Intended for
2329 // use by Google-written clients.
2330 func (c *warehouseGRPCClient) setGoogleClientInfo(keyval ...string) {
2331 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
2332 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
2333 c.xGoogHeaders = []string{
2334 "x-goog-api-client", gax.XGoogHeader(kv...),
2335 }
2336 }
2337
2338 // Close closes the connection to the API service. The user should invoke this when
2339 // the client is no longer required.
2340 func (c *warehouseGRPCClient) Close() error {
2341 return c.connPool.Close()
2342 }
2343
2344 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
2345 type warehouseRESTClient struct {
2346 // The http endpoint to connect to.
2347 endpoint string
2348
2349 // The http client.
2350 httpClient *http.Client
2351
2352 // LROClient is used internally to handle long-running operations.
2353 // It is exposed so that its CallOptions can be modified if required.
2354 // Users should not Close this client.
2355 LROClient **lroauto.OperationsClient
2356
2357 // The x-goog-* headers to be sent with each request.
2358 xGoogHeaders []string
2359
2360 // Points back to the CallOptions field of the containing WarehouseClient
2361 CallOptions **WarehouseCallOptions
2362
2363 logger *slog.Logger
2364 }
2365
2366 // NewWarehouseRESTClient creates a new warehouse rest client.
2367 //
2368 // Service that manages media content + metadata for streaming.
2369 func NewWarehouseRESTClient(ctx context.Context, opts ...option.ClientOption) (*WarehouseClient, error) {
2370 clientOpts := append(defaultWarehouseRESTClientOptions(), opts...)
2371 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
2372 if err != nil {
2373 return nil, err
2374 }
2375
2376 callOpts := defaultWarehouseRESTCallOptions()
2377 c := &warehouseRESTClient{
2378 endpoint: endpoint,
2379 httpClient: httpClient,
2380 CallOptions: &callOpts,
2381 logger: internaloption.GetLogger(opts),
2382 }
2383 c.setGoogleClientInfo()
2384
2385 lroOpts := []option.ClientOption{
2386 option.WithHTTPClient(httpClient),
2387 option.WithEndpoint(endpoint),
2388 }
2389 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
2390 if err != nil {
2391 return nil, err
2392 }
2393 c.LROClient = &opClient
2394
2395 return &WarehouseClient{internalClient: c, CallOptions: callOpts}, nil
2396 }
2397
2398 func defaultWarehouseRESTClientOptions() []option.ClientOption {
2399 return []option.ClientOption{
2400 internaloption.WithDefaultEndpoint("https://visionai.googleapis.com"),
2401 internaloption.WithDefaultEndpointTemplate("https://visionai.UNIVERSE_DOMAIN"),
2402 internaloption.WithDefaultMTLSEndpoint("https://visionai.mtls.googleapis.com"),
2403 internaloption.WithDefaultUniverseDomain("googleapis.com"),
2404 internaloption.WithDefaultAudience("https://visionai.googleapis.com/"),
2405 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
2406 internaloption.EnableNewAuthLibrary(),
2407 }
2408 }
2409
2410 // setGoogleClientInfo sets the name and version of the application in
2411 // the `x-goog-api-client` header passed on each request. Intended for
2412 // use by Google-written clients.
2413 func (c *warehouseRESTClient) setGoogleClientInfo(keyval ...string) {
2414 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
2415 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
2416 c.xGoogHeaders = []string{
2417 "x-goog-api-client", gax.XGoogHeader(kv...),
2418 }
2419 }
2420
2421 // Close closes the connection to the API service. The user should invoke this when
2422 // the client is no longer required.
2423 func (c *warehouseRESTClient) Close() error {
2424 // Replace httpClient with nil to force cleanup.
2425 c.httpClient = nil
2426 return nil
2427 }
2428
2429 // Connection returns a connection to the API service.
2430 //
2431 // Deprecated: This method always returns nil.
2432 func (c *warehouseRESTClient) Connection() *grpc.ClientConn {
2433 return nil
2434 }
2435 func (c *warehouseGRPCClient) CreateAsset(ctx context.Context, req *visionaipb.CreateAssetRequest, opts ...gax.CallOption) (*visionaipb.Asset, error) {
2436 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2437
2438 hds = append(c.xGoogHeaders, hds...)
2439 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2440 opts = append((*c.CallOptions).CreateAsset[0:len((*c.CallOptions).CreateAsset):len((*c.CallOptions).CreateAsset)], opts...)
2441 var resp *visionaipb.Asset
2442 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2443 var err error
2444 resp, err = executeRPC(ctx, c.warehouseClient.CreateAsset, req, settings.GRPC, c.logger, "CreateAsset")
2445 return err
2446 }, opts...)
2447 if err != nil {
2448 return nil, err
2449 }
2450 return resp, nil
2451 }
2452
2453 func (c *warehouseGRPCClient) UpdateAsset(ctx context.Context, req *visionaipb.UpdateAssetRequest, opts ...gax.CallOption) (*visionaipb.Asset, error) {
2454 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "asset.name", url.QueryEscape(req.GetAsset().GetName()))}
2455
2456 hds = append(c.xGoogHeaders, hds...)
2457 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2458 opts = append((*c.CallOptions).UpdateAsset[0:len((*c.CallOptions).UpdateAsset):len((*c.CallOptions).UpdateAsset)], opts...)
2459 var resp *visionaipb.Asset
2460 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2461 var err error
2462 resp, err = executeRPC(ctx, c.warehouseClient.UpdateAsset, req, settings.GRPC, c.logger, "UpdateAsset")
2463 return err
2464 }, opts...)
2465 if err != nil {
2466 return nil, err
2467 }
2468 return resp, nil
2469 }
2470
2471 func (c *warehouseGRPCClient) GetAsset(ctx context.Context, req *visionaipb.GetAssetRequest, opts ...gax.CallOption) (*visionaipb.Asset, error) {
2472 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2473
2474 hds = append(c.xGoogHeaders, hds...)
2475 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2476 opts = append((*c.CallOptions).GetAsset[0:len((*c.CallOptions).GetAsset):len((*c.CallOptions).GetAsset)], opts...)
2477 var resp *visionaipb.Asset
2478 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2479 var err error
2480 resp, err = executeRPC(ctx, c.warehouseClient.GetAsset, req, settings.GRPC, c.logger, "GetAsset")
2481 return err
2482 }, opts...)
2483 if err != nil {
2484 return nil, err
2485 }
2486 return resp, nil
2487 }
2488
2489 func (c *warehouseGRPCClient) ListAssets(ctx context.Context, req *visionaipb.ListAssetsRequest, opts ...gax.CallOption) *AssetIterator {
2490 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2491
2492 hds = append(c.xGoogHeaders, hds...)
2493 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2494 opts = append((*c.CallOptions).ListAssets[0:len((*c.CallOptions).ListAssets):len((*c.CallOptions).ListAssets)], opts...)
2495 it := &AssetIterator{}
2496 req = proto.Clone(req).(*visionaipb.ListAssetsRequest)
2497 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Asset, string, error) {
2498 resp := &visionaipb.ListAssetsResponse{}
2499 if pageToken != "" {
2500 req.PageToken = pageToken
2501 }
2502 if pageSize > math.MaxInt32 {
2503 req.PageSize = math.MaxInt32
2504 } else if pageSize != 0 {
2505 req.PageSize = int32(pageSize)
2506 }
2507 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2508 var err error
2509 resp, err = executeRPC(ctx, c.warehouseClient.ListAssets, req, settings.GRPC, c.logger, "ListAssets")
2510 return err
2511 }, opts...)
2512 if err != nil {
2513 return nil, "", err
2514 }
2515
2516 it.Response = resp
2517 return resp.GetAssets(), resp.GetNextPageToken(), nil
2518 }
2519 fetch := func(pageSize int, pageToken string) (string, error) {
2520 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2521 if err != nil {
2522 return "", err
2523 }
2524 it.items = append(it.items, items...)
2525 return nextPageToken, nil
2526 }
2527
2528 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2529 it.pageInfo.MaxSize = int(req.GetPageSize())
2530 it.pageInfo.Token = req.GetPageToken()
2531
2532 return it
2533 }
2534
2535 func (c *warehouseGRPCClient) DeleteAsset(ctx context.Context, req *visionaipb.DeleteAssetRequest, opts ...gax.CallOption) (*DeleteAssetOperation, error) {
2536 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2537
2538 hds = append(c.xGoogHeaders, hds...)
2539 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2540 opts = append((*c.CallOptions).DeleteAsset[0:len((*c.CallOptions).DeleteAsset):len((*c.CallOptions).DeleteAsset)], opts...)
2541 var resp *longrunningpb.Operation
2542 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2543 var err error
2544 resp, err = executeRPC(ctx, c.warehouseClient.DeleteAsset, req, settings.GRPC, c.logger, "DeleteAsset")
2545 return err
2546 }, opts...)
2547 if err != nil {
2548 return nil, err
2549 }
2550 return &DeleteAssetOperation{
2551 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2552 }, nil
2553 }
2554
2555 func (c *warehouseGRPCClient) UploadAsset(ctx context.Context, req *visionaipb.UploadAssetRequest, opts ...gax.CallOption) (*UploadAssetOperation, error) {
2556 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2557
2558 hds = append(c.xGoogHeaders, hds...)
2559 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2560 opts = append((*c.CallOptions).UploadAsset[0:len((*c.CallOptions).UploadAsset):len((*c.CallOptions).UploadAsset)], opts...)
2561 var resp *longrunningpb.Operation
2562 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2563 var err error
2564 resp, err = executeRPC(ctx, c.warehouseClient.UploadAsset, req, settings.GRPC, c.logger, "UploadAsset")
2565 return err
2566 }, opts...)
2567 if err != nil {
2568 return nil, err
2569 }
2570 return &UploadAssetOperation{
2571 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2572 }, nil
2573 }
2574
2575 func (c *warehouseGRPCClient) GenerateRetrievalUrl(ctx context.Context, req *visionaipb.GenerateRetrievalUrlRequest, opts ...gax.CallOption) (*visionaipb.GenerateRetrievalUrlResponse, error) {
2576 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2577
2578 hds = append(c.xGoogHeaders, hds...)
2579 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2580 opts = append((*c.CallOptions).GenerateRetrievalUrl[0:len((*c.CallOptions).GenerateRetrievalUrl):len((*c.CallOptions).GenerateRetrievalUrl)], opts...)
2581 var resp *visionaipb.GenerateRetrievalUrlResponse
2582 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2583 var err error
2584 resp, err = executeRPC(ctx, c.warehouseClient.GenerateRetrievalUrl, req, settings.GRPC, c.logger, "GenerateRetrievalUrl")
2585 return err
2586 }, opts...)
2587 if err != nil {
2588 return nil, err
2589 }
2590 return resp, nil
2591 }
2592
2593 func (c *warehouseGRPCClient) AnalyzeAsset(ctx context.Context, req *visionaipb.AnalyzeAssetRequest, opts ...gax.CallOption) (*AnalyzeAssetOperation, error) {
2594 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2595
2596 hds = append(c.xGoogHeaders, hds...)
2597 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2598 opts = append((*c.CallOptions).AnalyzeAsset[0:len((*c.CallOptions).AnalyzeAsset):len((*c.CallOptions).AnalyzeAsset)], opts...)
2599 var resp *longrunningpb.Operation
2600 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2601 var err error
2602 resp, err = executeRPC(ctx, c.warehouseClient.AnalyzeAsset, req, settings.GRPC, c.logger, "AnalyzeAsset")
2603 return err
2604 }, opts...)
2605 if err != nil {
2606 return nil, err
2607 }
2608 return &AnalyzeAssetOperation{
2609 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2610 }, nil
2611 }
2612
2613 func (c *warehouseGRPCClient) IndexAsset(ctx context.Context, req *visionaipb.IndexAssetRequest, opts ...gax.CallOption) (*IndexAssetOperation, error) {
2614 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2615
2616 hds = append(c.xGoogHeaders, hds...)
2617 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2618 opts = append((*c.CallOptions).IndexAsset[0:len((*c.CallOptions).IndexAsset):len((*c.CallOptions).IndexAsset)], opts...)
2619 var resp *longrunningpb.Operation
2620 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2621 var err error
2622 resp, err = executeRPC(ctx, c.warehouseClient.IndexAsset, req, settings.GRPC, c.logger, "IndexAsset")
2623 return err
2624 }, opts...)
2625 if err != nil {
2626 return nil, err
2627 }
2628 return &IndexAssetOperation{
2629 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2630 }, nil
2631 }
2632
2633 func (c *warehouseGRPCClient) RemoveIndexAsset(ctx context.Context, req *visionaipb.RemoveIndexAssetRequest, opts ...gax.CallOption) (*RemoveIndexAssetOperation, error) {
2634 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2635
2636 hds = append(c.xGoogHeaders, hds...)
2637 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2638 opts = append((*c.CallOptions).RemoveIndexAsset[0:len((*c.CallOptions).RemoveIndexAsset):len((*c.CallOptions).RemoveIndexAsset)], opts...)
2639 var resp *longrunningpb.Operation
2640 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2641 var err error
2642 resp, err = executeRPC(ctx, c.warehouseClient.RemoveIndexAsset, req, settings.GRPC, c.logger, "RemoveIndexAsset")
2643 return err
2644 }, opts...)
2645 if err != nil {
2646 return nil, err
2647 }
2648 return &RemoveIndexAssetOperation{
2649 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2650 }, nil
2651 }
2652
2653 func (c *warehouseGRPCClient) ViewIndexedAssets(ctx context.Context, req *visionaipb.ViewIndexedAssetsRequest, opts ...gax.CallOption) *IndexedAssetIterator {
2654 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index", url.QueryEscape(req.GetIndex()))}
2655
2656 hds = append(c.xGoogHeaders, hds...)
2657 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2658 opts = append((*c.CallOptions).ViewIndexedAssets[0:len((*c.CallOptions).ViewIndexedAssets):len((*c.CallOptions).ViewIndexedAssets)], opts...)
2659 it := &IndexedAssetIterator{}
2660 req = proto.Clone(req).(*visionaipb.ViewIndexedAssetsRequest)
2661 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.IndexedAsset, string, error) {
2662 resp := &visionaipb.ViewIndexedAssetsResponse{}
2663 if pageToken != "" {
2664 req.PageToken = pageToken
2665 }
2666 if pageSize > math.MaxInt32 {
2667 req.PageSize = math.MaxInt32
2668 } else if pageSize != 0 {
2669 req.PageSize = int32(pageSize)
2670 }
2671 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2672 var err error
2673 resp, err = executeRPC(ctx, c.warehouseClient.ViewIndexedAssets, req, settings.GRPC, c.logger, "ViewIndexedAssets")
2674 return err
2675 }, opts...)
2676 if err != nil {
2677 return nil, "", err
2678 }
2679
2680 it.Response = resp
2681 return resp.GetIndexedAssets(), resp.GetNextPageToken(), nil
2682 }
2683 fetch := func(pageSize int, pageToken string) (string, error) {
2684 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2685 if err != nil {
2686 return "", err
2687 }
2688 it.items = append(it.items, items...)
2689 return nextPageToken, nil
2690 }
2691
2692 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2693 it.pageInfo.MaxSize = int(req.GetPageSize())
2694 it.pageInfo.Token = req.GetPageToken()
2695
2696 return it
2697 }
2698
2699 func (c *warehouseGRPCClient) CreateIndex(ctx context.Context, req *visionaipb.CreateIndexRequest, opts ...gax.CallOption) (*CreateIndexOperation, error) {
2700 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2701
2702 hds = append(c.xGoogHeaders, hds...)
2703 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2704 opts = append((*c.CallOptions).CreateIndex[0:len((*c.CallOptions).CreateIndex):len((*c.CallOptions).CreateIndex)], opts...)
2705 var resp *longrunningpb.Operation
2706 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2707 var err error
2708 resp, err = executeRPC(ctx, c.warehouseClient.CreateIndex, req, settings.GRPC, c.logger, "CreateIndex")
2709 return err
2710 }, opts...)
2711 if err != nil {
2712 return nil, err
2713 }
2714 return &CreateIndexOperation{
2715 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2716 }, nil
2717 }
2718
2719 func (c *warehouseGRPCClient) UpdateIndex(ctx context.Context, req *visionaipb.UpdateIndexRequest, opts ...gax.CallOption) (*UpdateIndexOperation, error) {
2720 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index.name", url.QueryEscape(req.GetIndex().GetName()))}
2721
2722 hds = append(c.xGoogHeaders, hds...)
2723 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2724 opts = append((*c.CallOptions).UpdateIndex[0:len((*c.CallOptions).UpdateIndex):len((*c.CallOptions).UpdateIndex)], opts...)
2725 var resp *longrunningpb.Operation
2726 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2727 var err error
2728 resp, err = executeRPC(ctx, c.warehouseClient.UpdateIndex, req, settings.GRPC, c.logger, "UpdateIndex")
2729 return err
2730 }, opts...)
2731 if err != nil {
2732 return nil, err
2733 }
2734 return &UpdateIndexOperation{
2735 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2736 }, nil
2737 }
2738
2739 func (c *warehouseGRPCClient) GetIndex(ctx context.Context, req *visionaipb.GetIndexRequest, opts ...gax.CallOption) (*visionaipb.Index, error) {
2740 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2741
2742 hds = append(c.xGoogHeaders, hds...)
2743 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2744 opts = append((*c.CallOptions).GetIndex[0:len((*c.CallOptions).GetIndex):len((*c.CallOptions).GetIndex)], opts...)
2745 var resp *visionaipb.Index
2746 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2747 var err error
2748 resp, err = executeRPC(ctx, c.warehouseClient.GetIndex, req, settings.GRPC, c.logger, "GetIndex")
2749 return err
2750 }, opts...)
2751 if err != nil {
2752 return nil, err
2753 }
2754 return resp, nil
2755 }
2756
2757 func (c *warehouseGRPCClient) ListIndexes(ctx context.Context, req *visionaipb.ListIndexesRequest, opts ...gax.CallOption) *IndexIterator {
2758 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2759
2760 hds = append(c.xGoogHeaders, hds...)
2761 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2762 opts = append((*c.CallOptions).ListIndexes[0:len((*c.CallOptions).ListIndexes):len((*c.CallOptions).ListIndexes)], opts...)
2763 it := &IndexIterator{}
2764 req = proto.Clone(req).(*visionaipb.ListIndexesRequest)
2765 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Index, string, error) {
2766 resp := &visionaipb.ListIndexesResponse{}
2767 if pageToken != "" {
2768 req.PageToken = pageToken
2769 }
2770 if pageSize > math.MaxInt32 {
2771 req.PageSize = math.MaxInt32
2772 } else if pageSize != 0 {
2773 req.PageSize = int32(pageSize)
2774 }
2775 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2776 var err error
2777 resp, err = executeRPC(ctx, c.warehouseClient.ListIndexes, req, settings.GRPC, c.logger, "ListIndexes")
2778 return err
2779 }, opts...)
2780 if err != nil {
2781 return nil, "", err
2782 }
2783
2784 it.Response = resp
2785 return resp.GetIndexes(), resp.GetNextPageToken(), nil
2786 }
2787 fetch := func(pageSize int, pageToken string) (string, error) {
2788 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2789 if err != nil {
2790 return "", err
2791 }
2792 it.items = append(it.items, items...)
2793 return nextPageToken, nil
2794 }
2795
2796 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2797 it.pageInfo.MaxSize = int(req.GetPageSize())
2798 it.pageInfo.Token = req.GetPageToken()
2799
2800 return it
2801 }
2802
2803 func (c *warehouseGRPCClient) DeleteIndex(ctx context.Context, req *visionaipb.DeleteIndexRequest, opts ...gax.CallOption) (*DeleteIndexOperation, error) {
2804 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2805
2806 hds = append(c.xGoogHeaders, hds...)
2807 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2808 opts = append((*c.CallOptions).DeleteIndex[0:len((*c.CallOptions).DeleteIndex):len((*c.CallOptions).DeleteIndex)], opts...)
2809 var resp *longrunningpb.Operation
2810 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2811 var err error
2812 resp, err = executeRPC(ctx, c.warehouseClient.DeleteIndex, req, settings.GRPC, c.logger, "DeleteIndex")
2813 return err
2814 }, opts...)
2815 if err != nil {
2816 return nil, err
2817 }
2818 return &DeleteIndexOperation{
2819 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2820 }, nil
2821 }
2822
2823 func (c *warehouseGRPCClient) CreateCorpus(ctx context.Context, req *visionaipb.CreateCorpusRequest, opts ...gax.CallOption) (*CreateCorpusOperation, error) {
2824 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2825
2826 hds = append(c.xGoogHeaders, hds...)
2827 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2828 opts = append((*c.CallOptions).CreateCorpus[0:len((*c.CallOptions).CreateCorpus):len((*c.CallOptions).CreateCorpus)], opts...)
2829 var resp *longrunningpb.Operation
2830 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2831 var err error
2832 resp, err = executeRPC(ctx, c.warehouseClient.CreateCorpus, req, settings.GRPC, c.logger, "CreateCorpus")
2833 return err
2834 }, opts...)
2835 if err != nil {
2836 return nil, err
2837 }
2838 return &CreateCorpusOperation{
2839 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2840 }, nil
2841 }
2842
2843 func (c *warehouseGRPCClient) GetCorpus(ctx context.Context, req *visionaipb.GetCorpusRequest, opts ...gax.CallOption) (*visionaipb.Corpus, error) {
2844 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2845
2846 hds = append(c.xGoogHeaders, hds...)
2847 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2848 opts = append((*c.CallOptions).GetCorpus[0:len((*c.CallOptions).GetCorpus):len((*c.CallOptions).GetCorpus)], opts...)
2849 var resp *visionaipb.Corpus
2850 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2851 var err error
2852 resp, err = executeRPC(ctx, c.warehouseClient.GetCorpus, req, settings.GRPC, c.logger, "GetCorpus")
2853 return err
2854 }, opts...)
2855 if err != nil {
2856 return nil, err
2857 }
2858 return resp, nil
2859 }
2860
2861 func (c *warehouseGRPCClient) UpdateCorpus(ctx context.Context, req *visionaipb.UpdateCorpusRequest, opts ...gax.CallOption) (*visionaipb.Corpus, error) {
2862 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "corpus.name", url.QueryEscape(req.GetCorpus().GetName()))}
2863
2864 hds = append(c.xGoogHeaders, hds...)
2865 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2866 opts = append((*c.CallOptions).UpdateCorpus[0:len((*c.CallOptions).UpdateCorpus):len((*c.CallOptions).UpdateCorpus)], opts...)
2867 var resp *visionaipb.Corpus
2868 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2869 var err error
2870 resp, err = executeRPC(ctx, c.warehouseClient.UpdateCorpus, req, settings.GRPC, c.logger, "UpdateCorpus")
2871 return err
2872 }, opts...)
2873 if err != nil {
2874 return nil, err
2875 }
2876 return resp, nil
2877 }
2878
2879 func (c *warehouseGRPCClient) ListCorpora(ctx context.Context, req *visionaipb.ListCorporaRequest, opts ...gax.CallOption) *CorpusIterator {
2880 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2881
2882 hds = append(c.xGoogHeaders, hds...)
2883 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2884 opts = append((*c.CallOptions).ListCorpora[0:len((*c.CallOptions).ListCorpora):len((*c.CallOptions).ListCorpora)], opts...)
2885 it := &CorpusIterator{}
2886 req = proto.Clone(req).(*visionaipb.ListCorporaRequest)
2887 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Corpus, string, error) {
2888 resp := &visionaipb.ListCorporaResponse{}
2889 if pageToken != "" {
2890 req.PageToken = pageToken
2891 }
2892 if pageSize > math.MaxInt32 {
2893 req.PageSize = math.MaxInt32
2894 } else if pageSize != 0 {
2895 req.PageSize = int32(pageSize)
2896 }
2897 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2898 var err error
2899 resp, err = executeRPC(ctx, c.warehouseClient.ListCorpora, req, settings.GRPC, c.logger, "ListCorpora")
2900 return err
2901 }, opts...)
2902 if err != nil {
2903 return nil, "", err
2904 }
2905
2906 it.Response = resp
2907 return resp.GetCorpora(), resp.GetNextPageToken(), nil
2908 }
2909 fetch := func(pageSize int, pageToken string) (string, error) {
2910 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2911 if err != nil {
2912 return "", err
2913 }
2914 it.items = append(it.items, items...)
2915 return nextPageToken, nil
2916 }
2917
2918 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2919 it.pageInfo.MaxSize = int(req.GetPageSize())
2920 it.pageInfo.Token = req.GetPageToken()
2921
2922 return it
2923 }
2924
2925 func (c *warehouseGRPCClient) DeleteCorpus(ctx context.Context, req *visionaipb.DeleteCorpusRequest, opts ...gax.CallOption) error {
2926 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2927
2928 hds = append(c.xGoogHeaders, hds...)
2929 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2930 opts = append((*c.CallOptions).DeleteCorpus[0:len((*c.CallOptions).DeleteCorpus):len((*c.CallOptions).DeleteCorpus)], opts...)
2931 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2932 var err error
2933 _, err = executeRPC(ctx, c.warehouseClient.DeleteCorpus, req, settings.GRPC, c.logger, "DeleteCorpus")
2934 return err
2935 }, opts...)
2936 return err
2937 }
2938
2939 func (c *warehouseGRPCClient) AnalyzeCorpus(ctx context.Context, req *visionaipb.AnalyzeCorpusRequest, opts ...gax.CallOption) (*AnalyzeCorpusOperation, error) {
2940 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2941
2942 hds = append(c.xGoogHeaders, hds...)
2943 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2944 opts = append((*c.CallOptions).AnalyzeCorpus[0:len((*c.CallOptions).AnalyzeCorpus):len((*c.CallOptions).AnalyzeCorpus)], opts...)
2945 var resp *longrunningpb.Operation
2946 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2947 var err error
2948 resp, err = executeRPC(ctx, c.warehouseClient.AnalyzeCorpus, req, settings.GRPC, c.logger, "AnalyzeCorpus")
2949 return err
2950 }, opts...)
2951 if err != nil {
2952 return nil, err
2953 }
2954 return &AnalyzeCorpusOperation{
2955 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2956 }, nil
2957 }
2958
2959 func (c *warehouseGRPCClient) CreateDataSchema(ctx context.Context, req *visionaipb.CreateDataSchemaRequest, opts ...gax.CallOption) (*visionaipb.DataSchema, error) {
2960 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2961
2962 hds = append(c.xGoogHeaders, hds...)
2963 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2964 opts = append((*c.CallOptions).CreateDataSchema[0:len((*c.CallOptions).CreateDataSchema):len((*c.CallOptions).CreateDataSchema)], opts...)
2965 var resp *visionaipb.DataSchema
2966 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2967 var err error
2968 resp, err = executeRPC(ctx, c.warehouseClient.CreateDataSchema, req, settings.GRPC, c.logger, "CreateDataSchema")
2969 return err
2970 }, opts...)
2971 if err != nil {
2972 return nil, err
2973 }
2974 return resp, nil
2975 }
2976
2977 func (c *warehouseGRPCClient) UpdateDataSchema(ctx context.Context, req *visionaipb.UpdateDataSchemaRequest, opts ...gax.CallOption) (*visionaipb.DataSchema, error) {
2978 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "data_schema.name", url.QueryEscape(req.GetDataSchema().GetName()))}
2979
2980 hds = append(c.xGoogHeaders, hds...)
2981 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2982 opts = append((*c.CallOptions).UpdateDataSchema[0:len((*c.CallOptions).UpdateDataSchema):len((*c.CallOptions).UpdateDataSchema)], opts...)
2983 var resp *visionaipb.DataSchema
2984 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2985 var err error
2986 resp, err = executeRPC(ctx, c.warehouseClient.UpdateDataSchema, req, settings.GRPC, c.logger, "UpdateDataSchema")
2987 return err
2988 }, opts...)
2989 if err != nil {
2990 return nil, err
2991 }
2992 return resp, nil
2993 }
2994
2995 func (c *warehouseGRPCClient) GetDataSchema(ctx context.Context, req *visionaipb.GetDataSchemaRequest, opts ...gax.CallOption) (*visionaipb.DataSchema, error) {
2996 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2997
2998 hds = append(c.xGoogHeaders, hds...)
2999 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3000 opts = append((*c.CallOptions).GetDataSchema[0:len((*c.CallOptions).GetDataSchema):len((*c.CallOptions).GetDataSchema)], opts...)
3001 var resp *visionaipb.DataSchema
3002 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3003 var err error
3004 resp, err = executeRPC(ctx, c.warehouseClient.GetDataSchema, req, settings.GRPC, c.logger, "GetDataSchema")
3005 return err
3006 }, opts...)
3007 if err != nil {
3008 return nil, err
3009 }
3010 return resp, nil
3011 }
3012
3013 func (c *warehouseGRPCClient) DeleteDataSchema(ctx context.Context, req *visionaipb.DeleteDataSchemaRequest, opts ...gax.CallOption) error {
3014 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3015
3016 hds = append(c.xGoogHeaders, hds...)
3017 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3018 opts = append((*c.CallOptions).DeleteDataSchema[0:len((*c.CallOptions).DeleteDataSchema):len((*c.CallOptions).DeleteDataSchema)], opts...)
3019 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3020 var err error
3021 _, err = executeRPC(ctx, c.warehouseClient.DeleteDataSchema, req, settings.GRPC, c.logger, "DeleteDataSchema")
3022 return err
3023 }, opts...)
3024 return err
3025 }
3026
3027 func (c *warehouseGRPCClient) ListDataSchemas(ctx context.Context, req *visionaipb.ListDataSchemasRequest, opts ...gax.CallOption) *DataSchemaIterator {
3028 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3029
3030 hds = append(c.xGoogHeaders, hds...)
3031 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3032 opts = append((*c.CallOptions).ListDataSchemas[0:len((*c.CallOptions).ListDataSchemas):len((*c.CallOptions).ListDataSchemas)], opts...)
3033 it := &DataSchemaIterator{}
3034 req = proto.Clone(req).(*visionaipb.ListDataSchemasRequest)
3035 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.DataSchema, string, error) {
3036 resp := &visionaipb.ListDataSchemasResponse{}
3037 if pageToken != "" {
3038 req.PageToken = pageToken
3039 }
3040 if pageSize > math.MaxInt32 {
3041 req.PageSize = math.MaxInt32
3042 } else if pageSize != 0 {
3043 req.PageSize = int32(pageSize)
3044 }
3045 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3046 var err error
3047 resp, err = executeRPC(ctx, c.warehouseClient.ListDataSchemas, req, settings.GRPC, c.logger, "ListDataSchemas")
3048 return err
3049 }, opts...)
3050 if err != nil {
3051 return nil, "", err
3052 }
3053
3054 it.Response = resp
3055 return resp.GetDataSchemas(), resp.GetNextPageToken(), nil
3056 }
3057 fetch := func(pageSize int, pageToken string) (string, error) {
3058 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3059 if err != nil {
3060 return "", err
3061 }
3062 it.items = append(it.items, items...)
3063 return nextPageToken, nil
3064 }
3065
3066 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3067 it.pageInfo.MaxSize = int(req.GetPageSize())
3068 it.pageInfo.Token = req.GetPageToken()
3069
3070 return it
3071 }
3072
3073 func (c *warehouseGRPCClient) CreateAnnotation(ctx context.Context, req *visionaipb.CreateAnnotationRequest, opts ...gax.CallOption) (*visionaipb.Annotation, error) {
3074 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3075
3076 hds = append(c.xGoogHeaders, hds...)
3077 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3078 opts = append((*c.CallOptions).CreateAnnotation[0:len((*c.CallOptions).CreateAnnotation):len((*c.CallOptions).CreateAnnotation)], opts...)
3079 var resp *visionaipb.Annotation
3080 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3081 var err error
3082 resp, err = executeRPC(ctx, c.warehouseClient.CreateAnnotation, req, settings.GRPC, c.logger, "CreateAnnotation")
3083 return err
3084 }, opts...)
3085 if err != nil {
3086 return nil, err
3087 }
3088 return resp, nil
3089 }
3090
3091 func (c *warehouseGRPCClient) GetAnnotation(ctx context.Context, req *visionaipb.GetAnnotationRequest, opts ...gax.CallOption) (*visionaipb.Annotation, error) {
3092 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3093
3094 hds = append(c.xGoogHeaders, hds...)
3095 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3096 opts = append((*c.CallOptions).GetAnnotation[0:len((*c.CallOptions).GetAnnotation):len((*c.CallOptions).GetAnnotation)], opts...)
3097 var resp *visionaipb.Annotation
3098 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3099 var err error
3100 resp, err = executeRPC(ctx, c.warehouseClient.GetAnnotation, req, settings.GRPC, c.logger, "GetAnnotation")
3101 return err
3102 }, opts...)
3103 if err != nil {
3104 return nil, err
3105 }
3106 return resp, nil
3107 }
3108
3109 func (c *warehouseGRPCClient) ListAnnotations(ctx context.Context, req *visionaipb.ListAnnotationsRequest, opts ...gax.CallOption) *AnnotationIterator {
3110 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3111
3112 hds = append(c.xGoogHeaders, hds...)
3113 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3114 opts = append((*c.CallOptions).ListAnnotations[0:len((*c.CallOptions).ListAnnotations):len((*c.CallOptions).ListAnnotations)], opts...)
3115 it := &AnnotationIterator{}
3116 req = proto.Clone(req).(*visionaipb.ListAnnotationsRequest)
3117 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Annotation, string, error) {
3118 resp := &visionaipb.ListAnnotationsResponse{}
3119 if pageToken != "" {
3120 req.PageToken = pageToken
3121 }
3122 if pageSize > math.MaxInt32 {
3123 req.PageSize = math.MaxInt32
3124 } else if pageSize != 0 {
3125 req.PageSize = int32(pageSize)
3126 }
3127 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3128 var err error
3129 resp, err = executeRPC(ctx, c.warehouseClient.ListAnnotations, req, settings.GRPC, c.logger, "ListAnnotations")
3130 return err
3131 }, opts...)
3132 if err != nil {
3133 return nil, "", err
3134 }
3135
3136 it.Response = resp
3137 return resp.GetAnnotations(), resp.GetNextPageToken(), nil
3138 }
3139 fetch := func(pageSize int, pageToken string) (string, error) {
3140 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3141 if err != nil {
3142 return "", err
3143 }
3144 it.items = append(it.items, items...)
3145 return nextPageToken, nil
3146 }
3147
3148 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3149 it.pageInfo.MaxSize = int(req.GetPageSize())
3150 it.pageInfo.Token = req.GetPageToken()
3151
3152 return it
3153 }
3154
3155 func (c *warehouseGRPCClient) UpdateAnnotation(ctx context.Context, req *visionaipb.UpdateAnnotationRequest, opts ...gax.CallOption) (*visionaipb.Annotation, error) {
3156 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "annotation.name", url.QueryEscape(req.GetAnnotation().GetName()))}
3157
3158 hds = append(c.xGoogHeaders, hds...)
3159 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3160 opts = append((*c.CallOptions).UpdateAnnotation[0:len((*c.CallOptions).UpdateAnnotation):len((*c.CallOptions).UpdateAnnotation)], opts...)
3161 var resp *visionaipb.Annotation
3162 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3163 var err error
3164 resp, err = executeRPC(ctx, c.warehouseClient.UpdateAnnotation, req, settings.GRPC, c.logger, "UpdateAnnotation")
3165 return err
3166 }, opts...)
3167 if err != nil {
3168 return nil, err
3169 }
3170 return resp, nil
3171 }
3172
3173 func (c *warehouseGRPCClient) DeleteAnnotation(ctx context.Context, req *visionaipb.DeleteAnnotationRequest, opts ...gax.CallOption) error {
3174 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3175
3176 hds = append(c.xGoogHeaders, hds...)
3177 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3178 opts = append((*c.CallOptions).DeleteAnnotation[0:len((*c.CallOptions).DeleteAnnotation):len((*c.CallOptions).DeleteAnnotation)], opts...)
3179 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3180 var err error
3181 _, err = executeRPC(ctx, c.warehouseClient.DeleteAnnotation, req, settings.GRPC, c.logger, "DeleteAnnotation")
3182 return err
3183 }, opts...)
3184 return err
3185 }
3186
3187 func (c *warehouseGRPCClient) IngestAsset(ctx context.Context, opts ...gax.CallOption) (visionaipb.Warehouse_IngestAssetClient, error) {
3188 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
3189 var resp visionaipb.Warehouse_IngestAssetClient
3190 opts = append((*c.CallOptions).IngestAsset[0:len((*c.CallOptions).IngestAsset):len((*c.CallOptions).IngestAsset)], opts...)
3191 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3192 var err error
3193 c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "IngestAsset")
3194 resp, err = c.warehouseClient.IngestAsset(ctx, settings.GRPC...)
3195 c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "IngestAsset")
3196 return err
3197 }, opts...)
3198 if err != nil {
3199 return nil, err
3200 }
3201 return resp, nil
3202 }
3203
3204 func (c *warehouseGRPCClient) ClipAsset(ctx context.Context, req *visionaipb.ClipAssetRequest, opts ...gax.CallOption) (*visionaipb.ClipAssetResponse, error) {
3205 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3206
3207 hds = append(c.xGoogHeaders, hds...)
3208 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3209 opts = append((*c.CallOptions).ClipAsset[0:len((*c.CallOptions).ClipAsset):len((*c.CallOptions).ClipAsset)], opts...)
3210 var resp *visionaipb.ClipAssetResponse
3211 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3212 var err error
3213 resp, err = executeRPC(ctx, c.warehouseClient.ClipAsset, req, settings.GRPC, c.logger, "ClipAsset")
3214 return err
3215 }, opts...)
3216 if err != nil {
3217 return nil, err
3218 }
3219 return resp, nil
3220 }
3221
3222 func (c *warehouseGRPCClient) GenerateHlsUri(ctx context.Context, req *visionaipb.GenerateHlsUriRequest, opts ...gax.CallOption) (*visionaipb.GenerateHlsUriResponse, error) {
3223 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3224
3225 hds = append(c.xGoogHeaders, hds...)
3226 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3227 opts = append((*c.CallOptions).GenerateHlsUri[0:len((*c.CallOptions).GenerateHlsUri):len((*c.CallOptions).GenerateHlsUri)], opts...)
3228 var resp *visionaipb.GenerateHlsUriResponse
3229 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3230 var err error
3231 resp, err = executeRPC(ctx, c.warehouseClient.GenerateHlsUri, req, settings.GRPC, c.logger, "GenerateHlsUri")
3232 return err
3233 }, opts...)
3234 if err != nil {
3235 return nil, err
3236 }
3237 return resp, nil
3238 }
3239
3240 func (c *warehouseGRPCClient) ImportAssets(ctx context.Context, req *visionaipb.ImportAssetsRequest, opts ...gax.CallOption) (*ImportAssetsOperation, error) {
3241 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3242
3243 hds = append(c.xGoogHeaders, hds...)
3244 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3245 opts = append((*c.CallOptions).ImportAssets[0:len((*c.CallOptions).ImportAssets):len((*c.CallOptions).ImportAssets)], opts...)
3246 var resp *longrunningpb.Operation
3247 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3248 var err error
3249 resp, err = executeRPC(ctx, c.warehouseClient.ImportAssets, req, settings.GRPC, c.logger, "ImportAssets")
3250 return err
3251 }, opts...)
3252 if err != nil {
3253 return nil, err
3254 }
3255 return &ImportAssetsOperation{
3256 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3257 }, nil
3258 }
3259
3260 func (c *warehouseGRPCClient) CreateSearchConfig(ctx context.Context, req *visionaipb.CreateSearchConfigRequest, opts ...gax.CallOption) (*visionaipb.SearchConfig, error) {
3261 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3262
3263 hds = append(c.xGoogHeaders, hds...)
3264 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3265 opts = append((*c.CallOptions).CreateSearchConfig[0:len((*c.CallOptions).CreateSearchConfig):len((*c.CallOptions).CreateSearchConfig)], opts...)
3266 var resp *visionaipb.SearchConfig
3267 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3268 var err error
3269 resp, err = executeRPC(ctx, c.warehouseClient.CreateSearchConfig, req, settings.GRPC, c.logger, "CreateSearchConfig")
3270 return err
3271 }, opts...)
3272 if err != nil {
3273 return nil, err
3274 }
3275 return resp, nil
3276 }
3277
3278 func (c *warehouseGRPCClient) UpdateSearchConfig(ctx context.Context, req *visionaipb.UpdateSearchConfigRequest, opts ...gax.CallOption) (*visionaipb.SearchConfig, error) {
3279 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "search_config.name", url.QueryEscape(req.GetSearchConfig().GetName()))}
3280
3281 hds = append(c.xGoogHeaders, hds...)
3282 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3283 opts = append((*c.CallOptions).UpdateSearchConfig[0:len((*c.CallOptions).UpdateSearchConfig):len((*c.CallOptions).UpdateSearchConfig)], opts...)
3284 var resp *visionaipb.SearchConfig
3285 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3286 var err error
3287 resp, err = executeRPC(ctx, c.warehouseClient.UpdateSearchConfig, req, settings.GRPC, c.logger, "UpdateSearchConfig")
3288 return err
3289 }, opts...)
3290 if err != nil {
3291 return nil, err
3292 }
3293 return resp, nil
3294 }
3295
3296 func (c *warehouseGRPCClient) GetSearchConfig(ctx context.Context, req *visionaipb.GetSearchConfigRequest, opts ...gax.CallOption) (*visionaipb.SearchConfig, error) {
3297 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3298
3299 hds = append(c.xGoogHeaders, hds...)
3300 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3301 opts = append((*c.CallOptions).GetSearchConfig[0:len((*c.CallOptions).GetSearchConfig):len((*c.CallOptions).GetSearchConfig)], opts...)
3302 var resp *visionaipb.SearchConfig
3303 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3304 var err error
3305 resp, err = executeRPC(ctx, c.warehouseClient.GetSearchConfig, req, settings.GRPC, c.logger, "GetSearchConfig")
3306 return err
3307 }, opts...)
3308 if err != nil {
3309 return nil, err
3310 }
3311 return resp, nil
3312 }
3313
3314 func (c *warehouseGRPCClient) DeleteSearchConfig(ctx context.Context, req *visionaipb.DeleteSearchConfigRequest, opts ...gax.CallOption) error {
3315 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3316
3317 hds = append(c.xGoogHeaders, hds...)
3318 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3319 opts = append((*c.CallOptions).DeleteSearchConfig[0:len((*c.CallOptions).DeleteSearchConfig):len((*c.CallOptions).DeleteSearchConfig)], opts...)
3320 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3321 var err error
3322 _, err = executeRPC(ctx, c.warehouseClient.DeleteSearchConfig, req, settings.GRPC, c.logger, "DeleteSearchConfig")
3323 return err
3324 }, opts...)
3325 return err
3326 }
3327
3328 func (c *warehouseGRPCClient) ListSearchConfigs(ctx context.Context, req *visionaipb.ListSearchConfigsRequest, opts ...gax.CallOption) *SearchConfigIterator {
3329 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3330
3331 hds = append(c.xGoogHeaders, hds...)
3332 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3333 opts = append((*c.CallOptions).ListSearchConfigs[0:len((*c.CallOptions).ListSearchConfigs):len((*c.CallOptions).ListSearchConfigs)], opts...)
3334 it := &SearchConfigIterator{}
3335 req = proto.Clone(req).(*visionaipb.ListSearchConfigsRequest)
3336 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.SearchConfig, string, error) {
3337 resp := &visionaipb.ListSearchConfigsResponse{}
3338 if pageToken != "" {
3339 req.PageToken = pageToken
3340 }
3341 if pageSize > math.MaxInt32 {
3342 req.PageSize = math.MaxInt32
3343 } else if pageSize != 0 {
3344 req.PageSize = int32(pageSize)
3345 }
3346 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3347 var err error
3348 resp, err = executeRPC(ctx, c.warehouseClient.ListSearchConfigs, req, settings.GRPC, c.logger, "ListSearchConfigs")
3349 return err
3350 }, opts...)
3351 if err != nil {
3352 return nil, "", err
3353 }
3354
3355 it.Response = resp
3356 return resp.GetSearchConfigs(), resp.GetNextPageToken(), nil
3357 }
3358 fetch := func(pageSize int, pageToken string) (string, error) {
3359 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3360 if err != nil {
3361 return "", err
3362 }
3363 it.items = append(it.items, items...)
3364 return nextPageToken, nil
3365 }
3366
3367 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3368 it.pageInfo.MaxSize = int(req.GetPageSize())
3369 it.pageInfo.Token = req.GetPageToken()
3370
3371 return it
3372 }
3373
3374 func (c *warehouseGRPCClient) CreateSearchHypernym(ctx context.Context, req *visionaipb.CreateSearchHypernymRequest, opts ...gax.CallOption) (*visionaipb.SearchHypernym, error) {
3375 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3376
3377 hds = append(c.xGoogHeaders, hds...)
3378 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3379 opts = append((*c.CallOptions).CreateSearchHypernym[0:len((*c.CallOptions).CreateSearchHypernym):len((*c.CallOptions).CreateSearchHypernym)], opts...)
3380 var resp *visionaipb.SearchHypernym
3381 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3382 var err error
3383 resp, err = executeRPC(ctx, c.warehouseClient.CreateSearchHypernym, req, settings.GRPC, c.logger, "CreateSearchHypernym")
3384 return err
3385 }, opts...)
3386 if err != nil {
3387 return nil, err
3388 }
3389 return resp, nil
3390 }
3391
3392 func (c *warehouseGRPCClient) UpdateSearchHypernym(ctx context.Context, req *visionaipb.UpdateSearchHypernymRequest, opts ...gax.CallOption) (*visionaipb.SearchHypernym, error) {
3393 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "search_hypernym.name", url.QueryEscape(req.GetSearchHypernym().GetName()))}
3394
3395 hds = append(c.xGoogHeaders, hds...)
3396 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3397 opts = append((*c.CallOptions).UpdateSearchHypernym[0:len((*c.CallOptions).UpdateSearchHypernym):len((*c.CallOptions).UpdateSearchHypernym)], opts...)
3398 var resp *visionaipb.SearchHypernym
3399 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3400 var err error
3401 resp, err = executeRPC(ctx, c.warehouseClient.UpdateSearchHypernym, req, settings.GRPC, c.logger, "UpdateSearchHypernym")
3402 return err
3403 }, opts...)
3404 if err != nil {
3405 return nil, err
3406 }
3407 return resp, nil
3408 }
3409
3410 func (c *warehouseGRPCClient) GetSearchHypernym(ctx context.Context, req *visionaipb.GetSearchHypernymRequest, opts ...gax.CallOption) (*visionaipb.SearchHypernym, error) {
3411 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3412
3413 hds = append(c.xGoogHeaders, hds...)
3414 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3415 opts = append((*c.CallOptions).GetSearchHypernym[0:len((*c.CallOptions).GetSearchHypernym):len((*c.CallOptions).GetSearchHypernym)], opts...)
3416 var resp *visionaipb.SearchHypernym
3417 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3418 var err error
3419 resp, err = executeRPC(ctx, c.warehouseClient.GetSearchHypernym, req, settings.GRPC, c.logger, "GetSearchHypernym")
3420 return err
3421 }, opts...)
3422 if err != nil {
3423 return nil, err
3424 }
3425 return resp, nil
3426 }
3427
3428 func (c *warehouseGRPCClient) DeleteSearchHypernym(ctx context.Context, req *visionaipb.DeleteSearchHypernymRequest, opts ...gax.CallOption) error {
3429 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3430
3431 hds = append(c.xGoogHeaders, hds...)
3432 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3433 opts = append((*c.CallOptions).DeleteSearchHypernym[0:len((*c.CallOptions).DeleteSearchHypernym):len((*c.CallOptions).DeleteSearchHypernym)], opts...)
3434 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3435 var err error
3436 _, err = executeRPC(ctx, c.warehouseClient.DeleteSearchHypernym, req, settings.GRPC, c.logger, "DeleteSearchHypernym")
3437 return err
3438 }, opts...)
3439 return err
3440 }
3441
3442 func (c *warehouseGRPCClient) ListSearchHypernyms(ctx context.Context, req *visionaipb.ListSearchHypernymsRequest, opts ...gax.CallOption) *SearchHypernymIterator {
3443 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3444
3445 hds = append(c.xGoogHeaders, hds...)
3446 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3447 opts = append((*c.CallOptions).ListSearchHypernyms[0:len((*c.CallOptions).ListSearchHypernyms):len((*c.CallOptions).ListSearchHypernyms)], opts...)
3448 it := &SearchHypernymIterator{}
3449 req = proto.Clone(req).(*visionaipb.ListSearchHypernymsRequest)
3450 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.SearchHypernym, string, error) {
3451 resp := &visionaipb.ListSearchHypernymsResponse{}
3452 if pageToken != "" {
3453 req.PageToken = pageToken
3454 }
3455 if pageSize > math.MaxInt32 {
3456 req.PageSize = math.MaxInt32
3457 } else if pageSize != 0 {
3458 req.PageSize = int32(pageSize)
3459 }
3460 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3461 var err error
3462 resp, err = executeRPC(ctx, c.warehouseClient.ListSearchHypernyms, req, settings.GRPC, c.logger, "ListSearchHypernyms")
3463 return err
3464 }, opts...)
3465 if err != nil {
3466 return nil, "", err
3467 }
3468
3469 it.Response = resp
3470 return resp.GetSearchHypernyms(), resp.GetNextPageToken(), nil
3471 }
3472 fetch := func(pageSize int, pageToken string) (string, error) {
3473 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3474 if err != nil {
3475 return "", err
3476 }
3477 it.items = append(it.items, items...)
3478 return nextPageToken, nil
3479 }
3480
3481 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3482 it.pageInfo.MaxSize = int(req.GetPageSize())
3483 it.pageInfo.Token = req.GetPageToken()
3484
3485 return it
3486 }
3487
3488 func (c *warehouseGRPCClient) SearchAssets(ctx context.Context, req *visionaipb.SearchAssetsRequest, opts ...gax.CallOption) *SearchResultItemIterator {
3489 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "corpus", url.QueryEscape(req.GetCorpus()))}
3490
3491 hds = append(c.xGoogHeaders, hds...)
3492 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3493 opts = append((*c.CallOptions).SearchAssets[0:len((*c.CallOptions).SearchAssets):len((*c.CallOptions).SearchAssets)], opts...)
3494 it := &SearchResultItemIterator{}
3495 req = proto.Clone(req).(*visionaipb.SearchAssetsRequest)
3496 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.SearchResultItem, string, error) {
3497 resp := &visionaipb.SearchAssetsResponse{}
3498 if pageToken != "" {
3499 req.PageToken = pageToken
3500 }
3501 if pageSize > math.MaxInt32 {
3502 req.PageSize = math.MaxInt32
3503 } else if pageSize != 0 {
3504 req.PageSize = int32(pageSize)
3505 }
3506 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3507 var err error
3508 resp, err = executeRPC(ctx, c.warehouseClient.SearchAssets, req, settings.GRPC, c.logger, "SearchAssets")
3509 return err
3510 }, opts...)
3511 if err != nil {
3512 return nil, "", err
3513 }
3514
3515 it.Response = resp
3516 return resp.GetSearchResultItems(), resp.GetNextPageToken(), nil
3517 }
3518 fetch := func(pageSize int, pageToken string) (string, error) {
3519 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3520 if err != nil {
3521 return "", err
3522 }
3523 it.items = append(it.items, items...)
3524 return nextPageToken, nil
3525 }
3526
3527 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3528 it.pageInfo.MaxSize = int(req.GetPageSize())
3529 it.pageInfo.Token = req.GetPageToken()
3530
3531 return it
3532 }
3533
3534 func (c *warehouseGRPCClient) SearchIndexEndpoint(ctx context.Context, req *visionaipb.SearchIndexEndpointRequest, opts ...gax.CallOption) *SearchResultItemIterator {
3535 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))}
3536
3537 hds = append(c.xGoogHeaders, hds...)
3538 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3539 opts = append((*c.CallOptions).SearchIndexEndpoint[0:len((*c.CallOptions).SearchIndexEndpoint):len((*c.CallOptions).SearchIndexEndpoint)], opts...)
3540 it := &SearchResultItemIterator{}
3541 req = proto.Clone(req).(*visionaipb.SearchIndexEndpointRequest)
3542 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.SearchResultItem, string, error) {
3543 resp := &visionaipb.SearchIndexEndpointResponse{}
3544 if pageToken != "" {
3545 req.PageToken = pageToken
3546 }
3547 if pageSize > math.MaxInt32 {
3548 req.PageSize = math.MaxInt32
3549 } else if pageSize != 0 {
3550 req.PageSize = int32(pageSize)
3551 }
3552 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3553 var err error
3554 resp, err = executeRPC(ctx, c.warehouseClient.SearchIndexEndpoint, req, settings.GRPC, c.logger, "SearchIndexEndpoint")
3555 return err
3556 }, opts...)
3557 if err != nil {
3558 return nil, "", err
3559 }
3560
3561 it.Response = resp
3562 return resp.GetSearchResultItems(), resp.GetNextPageToken(), nil
3563 }
3564 fetch := func(pageSize int, pageToken string) (string, error) {
3565 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3566 if err != nil {
3567 return "", err
3568 }
3569 it.items = append(it.items, items...)
3570 return nextPageToken, nil
3571 }
3572
3573 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3574 it.pageInfo.MaxSize = int(req.GetPageSize())
3575 it.pageInfo.Token = req.GetPageToken()
3576
3577 return it
3578 }
3579
3580 func (c *warehouseGRPCClient) CreateIndexEndpoint(ctx context.Context, req *visionaipb.CreateIndexEndpointRequest, opts ...gax.CallOption) (*CreateIndexEndpointOperation, error) {
3581 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3582
3583 hds = append(c.xGoogHeaders, hds...)
3584 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3585 opts = append((*c.CallOptions).CreateIndexEndpoint[0:len((*c.CallOptions).CreateIndexEndpoint):len((*c.CallOptions).CreateIndexEndpoint)], opts...)
3586 var resp *longrunningpb.Operation
3587 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3588 var err error
3589 resp, err = executeRPC(ctx, c.warehouseClient.CreateIndexEndpoint, req, settings.GRPC, c.logger, "CreateIndexEndpoint")
3590 return err
3591 }, opts...)
3592 if err != nil {
3593 return nil, err
3594 }
3595 return &CreateIndexEndpointOperation{
3596 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3597 }, nil
3598 }
3599
3600 func (c *warehouseGRPCClient) GetIndexEndpoint(ctx context.Context, req *visionaipb.GetIndexEndpointRequest, opts ...gax.CallOption) (*visionaipb.IndexEndpoint, error) {
3601 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3602
3603 hds = append(c.xGoogHeaders, hds...)
3604 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3605 opts = append((*c.CallOptions).GetIndexEndpoint[0:len((*c.CallOptions).GetIndexEndpoint):len((*c.CallOptions).GetIndexEndpoint)], opts...)
3606 var resp *visionaipb.IndexEndpoint
3607 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3608 var err error
3609 resp, err = executeRPC(ctx, c.warehouseClient.GetIndexEndpoint, req, settings.GRPC, c.logger, "GetIndexEndpoint")
3610 return err
3611 }, opts...)
3612 if err != nil {
3613 return nil, err
3614 }
3615 return resp, nil
3616 }
3617
3618 func (c *warehouseGRPCClient) ListIndexEndpoints(ctx context.Context, req *visionaipb.ListIndexEndpointsRequest, opts ...gax.CallOption) *IndexEndpointIterator {
3619 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3620
3621 hds = append(c.xGoogHeaders, hds...)
3622 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3623 opts = append((*c.CallOptions).ListIndexEndpoints[0:len((*c.CallOptions).ListIndexEndpoints):len((*c.CallOptions).ListIndexEndpoints)], opts...)
3624 it := &IndexEndpointIterator{}
3625 req = proto.Clone(req).(*visionaipb.ListIndexEndpointsRequest)
3626 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.IndexEndpoint, string, error) {
3627 resp := &visionaipb.ListIndexEndpointsResponse{}
3628 if pageToken != "" {
3629 req.PageToken = pageToken
3630 }
3631 if pageSize > math.MaxInt32 {
3632 req.PageSize = math.MaxInt32
3633 } else if pageSize != 0 {
3634 req.PageSize = int32(pageSize)
3635 }
3636 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3637 var err error
3638 resp, err = executeRPC(ctx, c.warehouseClient.ListIndexEndpoints, req, settings.GRPC, c.logger, "ListIndexEndpoints")
3639 return err
3640 }, opts...)
3641 if err != nil {
3642 return nil, "", err
3643 }
3644
3645 it.Response = resp
3646 return resp.GetIndexEndpoints(), resp.GetNextPageToken(), nil
3647 }
3648 fetch := func(pageSize int, pageToken string) (string, error) {
3649 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3650 if err != nil {
3651 return "", err
3652 }
3653 it.items = append(it.items, items...)
3654 return nextPageToken, nil
3655 }
3656
3657 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3658 it.pageInfo.MaxSize = int(req.GetPageSize())
3659 it.pageInfo.Token = req.GetPageToken()
3660
3661 return it
3662 }
3663
3664 func (c *warehouseGRPCClient) UpdateIndexEndpoint(ctx context.Context, req *visionaipb.UpdateIndexEndpointRequest, opts ...gax.CallOption) (*UpdateIndexEndpointOperation, error) {
3665 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint.name", url.QueryEscape(req.GetIndexEndpoint().GetName()))}
3666
3667 hds = append(c.xGoogHeaders, hds...)
3668 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3669 opts = append((*c.CallOptions).UpdateIndexEndpoint[0:len((*c.CallOptions).UpdateIndexEndpoint):len((*c.CallOptions).UpdateIndexEndpoint)], opts...)
3670 var resp *longrunningpb.Operation
3671 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3672 var err error
3673 resp, err = executeRPC(ctx, c.warehouseClient.UpdateIndexEndpoint, req, settings.GRPC, c.logger, "UpdateIndexEndpoint")
3674 return err
3675 }, opts...)
3676 if err != nil {
3677 return nil, err
3678 }
3679 return &UpdateIndexEndpointOperation{
3680 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3681 }, nil
3682 }
3683
3684 func (c *warehouseGRPCClient) DeleteIndexEndpoint(ctx context.Context, req *visionaipb.DeleteIndexEndpointRequest, opts ...gax.CallOption) (*DeleteIndexEndpointOperation, error) {
3685 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3686
3687 hds = append(c.xGoogHeaders, hds...)
3688 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3689 opts = append((*c.CallOptions).DeleteIndexEndpoint[0:len((*c.CallOptions).DeleteIndexEndpoint):len((*c.CallOptions).DeleteIndexEndpoint)], opts...)
3690 var resp *longrunningpb.Operation
3691 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3692 var err error
3693 resp, err = executeRPC(ctx, c.warehouseClient.DeleteIndexEndpoint, req, settings.GRPC, c.logger, "DeleteIndexEndpoint")
3694 return err
3695 }, opts...)
3696 if err != nil {
3697 return nil, err
3698 }
3699 return &DeleteIndexEndpointOperation{
3700 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3701 }, nil
3702 }
3703
3704 func (c *warehouseGRPCClient) DeployIndex(ctx context.Context, req *visionaipb.DeployIndexRequest, opts ...gax.CallOption) (*DeployIndexOperation, error) {
3705 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))}
3706
3707 hds = append(c.xGoogHeaders, hds...)
3708 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3709 opts = append((*c.CallOptions).DeployIndex[0:len((*c.CallOptions).DeployIndex):len((*c.CallOptions).DeployIndex)], opts...)
3710 var resp *longrunningpb.Operation
3711 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3712 var err error
3713 resp, err = executeRPC(ctx, c.warehouseClient.DeployIndex, req, settings.GRPC, c.logger, "DeployIndex")
3714 return err
3715 }, opts...)
3716 if err != nil {
3717 return nil, err
3718 }
3719 return &DeployIndexOperation{
3720 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3721 }, nil
3722 }
3723
3724 func (c *warehouseGRPCClient) UndeployIndex(ctx context.Context, req *visionaipb.UndeployIndexRequest, opts ...gax.CallOption) (*UndeployIndexOperation, error) {
3725 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))}
3726
3727 hds = append(c.xGoogHeaders, hds...)
3728 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3729 opts = append((*c.CallOptions).UndeployIndex[0:len((*c.CallOptions).UndeployIndex):len((*c.CallOptions).UndeployIndex)], opts...)
3730 var resp *longrunningpb.Operation
3731 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3732 var err error
3733 resp, err = executeRPC(ctx, c.warehouseClient.UndeployIndex, req, settings.GRPC, c.logger, "UndeployIndex")
3734 return err
3735 }, opts...)
3736 if err != nil {
3737 return nil, err
3738 }
3739 return &UndeployIndexOperation{
3740 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3741 }, nil
3742 }
3743
3744 func (c *warehouseGRPCClient) CreateCollection(ctx context.Context, req *visionaipb.CreateCollectionRequest, opts ...gax.CallOption) (*CreateCollectionOperation, error) {
3745 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3746
3747 hds = append(c.xGoogHeaders, hds...)
3748 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3749 opts = append((*c.CallOptions).CreateCollection[0:len((*c.CallOptions).CreateCollection):len((*c.CallOptions).CreateCollection)], opts...)
3750 var resp *longrunningpb.Operation
3751 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3752 var err error
3753 resp, err = executeRPC(ctx, c.warehouseClient.CreateCollection, req, settings.GRPC, c.logger, "CreateCollection")
3754 return err
3755 }, opts...)
3756 if err != nil {
3757 return nil, err
3758 }
3759 return &CreateCollectionOperation{
3760 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3761 }, nil
3762 }
3763
3764 func (c *warehouseGRPCClient) DeleteCollection(ctx context.Context, req *visionaipb.DeleteCollectionRequest, opts ...gax.CallOption) (*DeleteCollectionOperation, error) {
3765 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3766
3767 hds = append(c.xGoogHeaders, hds...)
3768 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3769 opts = append((*c.CallOptions).DeleteCollection[0:len((*c.CallOptions).DeleteCollection):len((*c.CallOptions).DeleteCollection)], opts...)
3770 var resp *longrunningpb.Operation
3771 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3772 var err error
3773 resp, err = executeRPC(ctx, c.warehouseClient.DeleteCollection, req, settings.GRPC, c.logger, "DeleteCollection")
3774 return err
3775 }, opts...)
3776 if err != nil {
3777 return nil, err
3778 }
3779 return &DeleteCollectionOperation{
3780 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3781 }, nil
3782 }
3783
3784 func (c *warehouseGRPCClient) GetCollection(ctx context.Context, req *visionaipb.GetCollectionRequest, opts ...gax.CallOption) (*visionaipb.Collection, error) {
3785 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3786
3787 hds = append(c.xGoogHeaders, hds...)
3788 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3789 opts = append((*c.CallOptions).GetCollection[0:len((*c.CallOptions).GetCollection):len((*c.CallOptions).GetCollection)], opts...)
3790 var resp *visionaipb.Collection
3791 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3792 var err error
3793 resp, err = executeRPC(ctx, c.warehouseClient.GetCollection, req, settings.GRPC, c.logger, "GetCollection")
3794 return err
3795 }, opts...)
3796 if err != nil {
3797 return nil, err
3798 }
3799 return resp, nil
3800 }
3801
3802 func (c *warehouseGRPCClient) UpdateCollection(ctx context.Context, req *visionaipb.UpdateCollectionRequest, opts ...gax.CallOption) (*visionaipb.Collection, error) {
3803 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "collection.name", url.QueryEscape(req.GetCollection().GetName()))}
3804
3805 hds = append(c.xGoogHeaders, hds...)
3806 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3807 opts = append((*c.CallOptions).UpdateCollection[0:len((*c.CallOptions).UpdateCollection):len((*c.CallOptions).UpdateCollection)], opts...)
3808 var resp *visionaipb.Collection
3809 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3810 var err error
3811 resp, err = executeRPC(ctx, c.warehouseClient.UpdateCollection, req, settings.GRPC, c.logger, "UpdateCollection")
3812 return err
3813 }, opts...)
3814 if err != nil {
3815 return nil, err
3816 }
3817 return resp, nil
3818 }
3819
3820 func (c *warehouseGRPCClient) ListCollections(ctx context.Context, req *visionaipb.ListCollectionsRequest, opts ...gax.CallOption) *CollectionIterator {
3821 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3822
3823 hds = append(c.xGoogHeaders, hds...)
3824 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3825 opts = append((*c.CallOptions).ListCollections[0:len((*c.CallOptions).ListCollections):len((*c.CallOptions).ListCollections)], opts...)
3826 it := &CollectionIterator{}
3827 req = proto.Clone(req).(*visionaipb.ListCollectionsRequest)
3828 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Collection, string, error) {
3829 resp := &visionaipb.ListCollectionsResponse{}
3830 if pageToken != "" {
3831 req.PageToken = pageToken
3832 }
3833 if pageSize > math.MaxInt32 {
3834 req.PageSize = math.MaxInt32
3835 } else if pageSize != 0 {
3836 req.PageSize = int32(pageSize)
3837 }
3838 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3839 var err error
3840 resp, err = executeRPC(ctx, c.warehouseClient.ListCollections, req, settings.GRPC, c.logger, "ListCollections")
3841 return err
3842 }, opts...)
3843 if err != nil {
3844 return nil, "", err
3845 }
3846
3847 it.Response = resp
3848 return resp.GetCollections(), resp.GetNextPageToken(), nil
3849 }
3850 fetch := func(pageSize int, pageToken string) (string, error) {
3851 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3852 if err != nil {
3853 return "", err
3854 }
3855 it.items = append(it.items, items...)
3856 return nextPageToken, nil
3857 }
3858
3859 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3860 it.pageInfo.MaxSize = int(req.GetPageSize())
3861 it.pageInfo.Token = req.GetPageToken()
3862
3863 return it
3864 }
3865
3866 func (c *warehouseGRPCClient) AddCollectionItem(ctx context.Context, req *visionaipb.AddCollectionItemRequest, opts ...gax.CallOption) (*visionaipb.AddCollectionItemResponse, error) {
3867 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "item.collection", url.QueryEscape(req.GetItem().GetCollection()))}
3868
3869 hds = append(c.xGoogHeaders, hds...)
3870 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3871 opts = append((*c.CallOptions).AddCollectionItem[0:len((*c.CallOptions).AddCollectionItem):len((*c.CallOptions).AddCollectionItem)], opts...)
3872 var resp *visionaipb.AddCollectionItemResponse
3873 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3874 var err error
3875 resp, err = executeRPC(ctx, c.warehouseClient.AddCollectionItem, req, settings.GRPC, c.logger, "AddCollectionItem")
3876 return err
3877 }, opts...)
3878 if err != nil {
3879 return nil, err
3880 }
3881 return resp, nil
3882 }
3883
3884 func (c *warehouseGRPCClient) RemoveCollectionItem(ctx context.Context, req *visionaipb.RemoveCollectionItemRequest, opts ...gax.CallOption) (*visionaipb.RemoveCollectionItemResponse, error) {
3885 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "item.collection", url.QueryEscape(req.GetItem().GetCollection()))}
3886
3887 hds = append(c.xGoogHeaders, hds...)
3888 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3889 opts = append((*c.CallOptions).RemoveCollectionItem[0:len((*c.CallOptions).RemoveCollectionItem):len((*c.CallOptions).RemoveCollectionItem)], opts...)
3890 var resp *visionaipb.RemoveCollectionItemResponse
3891 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3892 var err error
3893 resp, err = executeRPC(ctx, c.warehouseClient.RemoveCollectionItem, req, settings.GRPC, c.logger, "RemoveCollectionItem")
3894 return err
3895 }, opts...)
3896 if err != nil {
3897 return nil, err
3898 }
3899 return resp, nil
3900 }
3901
3902 func (c *warehouseGRPCClient) ViewCollectionItems(ctx context.Context, req *visionaipb.ViewCollectionItemsRequest, opts ...gax.CallOption) *CollectionItemIterator {
3903 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "collection", url.QueryEscape(req.GetCollection()))}
3904
3905 hds = append(c.xGoogHeaders, hds...)
3906 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3907 opts = append((*c.CallOptions).ViewCollectionItems[0:len((*c.CallOptions).ViewCollectionItems):len((*c.CallOptions).ViewCollectionItems)], opts...)
3908 it := &CollectionItemIterator{}
3909 req = proto.Clone(req).(*visionaipb.ViewCollectionItemsRequest)
3910 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.CollectionItem, string, error) {
3911 resp := &visionaipb.ViewCollectionItemsResponse{}
3912 if pageToken != "" {
3913 req.PageToken = pageToken
3914 }
3915 if pageSize > math.MaxInt32 {
3916 req.PageSize = math.MaxInt32
3917 } else if pageSize != 0 {
3918 req.PageSize = int32(pageSize)
3919 }
3920 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3921 var err error
3922 resp, err = executeRPC(ctx, c.warehouseClient.ViewCollectionItems, req, settings.GRPC, c.logger, "ViewCollectionItems")
3923 return err
3924 }, opts...)
3925 if err != nil {
3926 return nil, "", err
3927 }
3928
3929 it.Response = resp
3930 return resp.GetItems(), resp.GetNextPageToken(), nil
3931 }
3932 fetch := func(pageSize int, pageToken string) (string, error) {
3933 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3934 if err != nil {
3935 return "", err
3936 }
3937 it.items = append(it.items, items...)
3938 return nextPageToken, nil
3939 }
3940
3941 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3942 it.pageInfo.MaxSize = int(req.GetPageSize())
3943 it.pageInfo.Token = req.GetPageToken()
3944
3945 return it
3946 }
3947
3948 func (c *warehouseGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
3949 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3950
3951 hds = append(c.xGoogHeaders, hds...)
3952 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3953 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
3954 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3955 var err error
3956 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
3957 return err
3958 }, opts...)
3959 return err
3960 }
3961
3962 func (c *warehouseGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
3963 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3964
3965 hds = append(c.xGoogHeaders, hds...)
3966 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3967 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
3968 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3969 var err error
3970 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
3971 return err
3972 }, opts...)
3973 return err
3974 }
3975
3976 func (c *warehouseGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
3977 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3978
3979 hds = append(c.xGoogHeaders, hds...)
3980 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3981 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
3982 var resp *longrunningpb.Operation
3983 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3984 var err error
3985 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
3986 return err
3987 }, opts...)
3988 if err != nil {
3989 return nil, err
3990 }
3991 return resp, nil
3992 }
3993
3994 func (c *warehouseGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
3995 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3996
3997 hds = append(c.xGoogHeaders, hds...)
3998 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
3999 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
4000 it := &OperationIterator{}
4001 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
4002 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
4003 resp := &longrunningpb.ListOperationsResponse{}
4004 if pageToken != "" {
4005 req.PageToken = pageToken
4006 }
4007 if pageSize > math.MaxInt32 {
4008 req.PageSize = math.MaxInt32
4009 } else if pageSize != 0 {
4010 req.PageSize = int32(pageSize)
4011 }
4012 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4013 var err error
4014 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
4015 return err
4016 }, opts...)
4017 if err != nil {
4018 return nil, "", err
4019 }
4020
4021 it.Response = resp
4022 return resp.GetOperations(), resp.GetNextPageToken(), nil
4023 }
4024 fetch := func(pageSize int, pageToken string) (string, error) {
4025 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4026 if err != nil {
4027 return "", err
4028 }
4029 it.items = append(it.items, items...)
4030 return nextPageToken, nil
4031 }
4032
4033 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4034 it.pageInfo.MaxSize = int(req.GetPageSize())
4035 it.pageInfo.Token = req.GetPageToken()
4036
4037 return it
4038 }
4039
4040 // CreateAsset creates an asset inside corpus.
4041 func (c *warehouseRESTClient) CreateAsset(ctx context.Context, req *visionaipb.CreateAssetRequest, opts ...gax.CallOption) (*visionaipb.Asset, error) {
4042 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4043 body := req.GetAsset()
4044 jsonReq, err := m.Marshal(body)
4045 if err != nil {
4046 return nil, err
4047 }
4048
4049 baseUrl, err := url.Parse(c.endpoint)
4050 if err != nil {
4051 return nil, err
4052 }
4053 baseUrl.Path += fmt.Sprintf("/v1/%v/assets", req.GetParent())
4054
4055 params := url.Values{}
4056 params.Add("$alt", "json;enum-encoding=int")
4057 if req != nil && req.AssetId != nil {
4058 params.Add("assetId", fmt.Sprintf("%v", req.GetAssetId()))
4059 }
4060
4061 baseUrl.RawQuery = params.Encode()
4062
4063 // Build HTTP headers from client and context metadata.
4064 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
4065
4066 hds = append(c.xGoogHeaders, hds...)
4067 hds = append(hds, "Content-Type", "application/json")
4068 headers := gax.BuildHeaders(ctx, hds...)
4069 opts = append((*c.CallOptions).CreateAsset[0:len((*c.CallOptions).CreateAsset):len((*c.CallOptions).CreateAsset)], opts...)
4070 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4071 resp := &visionaipb.Asset{}
4072 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4073 if settings.Path != "" {
4074 baseUrl.Path = settings.Path
4075 }
4076 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4077 if err != nil {
4078 return err
4079 }
4080 httpReq = httpReq.WithContext(ctx)
4081 httpReq.Header = headers
4082
4083 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateAsset")
4084 if err != nil {
4085 return err
4086 }
4087
4088 if err := unm.Unmarshal(buf, resp); err != nil {
4089 return err
4090 }
4091
4092 return nil
4093 }, opts...)
4094 if e != nil {
4095 return nil, e
4096 }
4097 return resp, nil
4098 }
4099
4100 // UpdateAsset updates an asset inside corpus.
4101 func (c *warehouseRESTClient) UpdateAsset(ctx context.Context, req *visionaipb.UpdateAssetRequest, opts ...gax.CallOption) (*visionaipb.Asset, error) {
4102 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4103 body := req.GetAsset()
4104 jsonReq, err := m.Marshal(body)
4105 if err != nil {
4106 return nil, err
4107 }
4108
4109 baseUrl, err := url.Parse(c.endpoint)
4110 if err != nil {
4111 return nil, err
4112 }
4113 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetAsset().GetName())
4114
4115 params := url.Values{}
4116 params.Add("$alt", "json;enum-encoding=int")
4117 if req.GetUpdateMask() != nil {
4118 field, err := protojson.Marshal(req.GetUpdateMask())
4119 if err != nil {
4120 return nil, err
4121 }
4122 params.Add("updateMask", string(field[1:len(field)-1]))
4123 }
4124
4125 baseUrl.RawQuery = params.Encode()
4126
4127 // Build HTTP headers from client and context metadata.
4128 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "asset.name", url.QueryEscape(req.GetAsset().GetName()))}
4129
4130 hds = append(c.xGoogHeaders, hds...)
4131 hds = append(hds, "Content-Type", "application/json")
4132 headers := gax.BuildHeaders(ctx, hds...)
4133 opts = append((*c.CallOptions).UpdateAsset[0:len((*c.CallOptions).UpdateAsset):len((*c.CallOptions).UpdateAsset)], opts...)
4134 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4135 resp := &visionaipb.Asset{}
4136 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4137 if settings.Path != "" {
4138 baseUrl.Path = settings.Path
4139 }
4140 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
4141 if err != nil {
4142 return err
4143 }
4144 httpReq = httpReq.WithContext(ctx)
4145 httpReq.Header = headers
4146
4147 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateAsset")
4148 if err != nil {
4149 return err
4150 }
4151
4152 if err := unm.Unmarshal(buf, resp); err != nil {
4153 return err
4154 }
4155
4156 return nil
4157 }, opts...)
4158 if e != nil {
4159 return nil, e
4160 }
4161 return resp, nil
4162 }
4163
4164 // GetAsset reads an asset inside corpus.
4165 func (c *warehouseRESTClient) GetAsset(ctx context.Context, req *visionaipb.GetAssetRequest, opts ...gax.CallOption) (*visionaipb.Asset, error) {
4166 baseUrl, err := url.Parse(c.endpoint)
4167 if err != nil {
4168 return nil, err
4169 }
4170 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4171
4172 params := url.Values{}
4173 params.Add("$alt", "json;enum-encoding=int")
4174
4175 baseUrl.RawQuery = params.Encode()
4176
4177 // Build HTTP headers from client and context metadata.
4178 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4179
4180 hds = append(c.xGoogHeaders, hds...)
4181 hds = append(hds, "Content-Type", "application/json")
4182 headers := gax.BuildHeaders(ctx, hds...)
4183 opts = append((*c.CallOptions).GetAsset[0:len((*c.CallOptions).GetAsset):len((*c.CallOptions).GetAsset)], opts...)
4184 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4185 resp := &visionaipb.Asset{}
4186 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4187 if settings.Path != "" {
4188 baseUrl.Path = settings.Path
4189 }
4190 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4191 if err != nil {
4192 return err
4193 }
4194 httpReq = httpReq.WithContext(ctx)
4195 httpReq.Header = headers
4196
4197 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetAsset")
4198 if err != nil {
4199 return err
4200 }
4201
4202 if err := unm.Unmarshal(buf, resp); err != nil {
4203 return err
4204 }
4205
4206 return nil
4207 }, opts...)
4208 if e != nil {
4209 return nil, e
4210 }
4211 return resp, nil
4212 }
4213
4214 // ListAssets lists an list of assets inside corpus.
4215 func (c *warehouseRESTClient) ListAssets(ctx context.Context, req *visionaipb.ListAssetsRequest, opts ...gax.CallOption) *AssetIterator {
4216 it := &AssetIterator{}
4217 req = proto.Clone(req).(*visionaipb.ListAssetsRequest)
4218 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4219 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Asset, string, error) {
4220 resp := &visionaipb.ListAssetsResponse{}
4221 if pageToken != "" {
4222 req.PageToken = pageToken
4223 }
4224 if pageSize > math.MaxInt32 {
4225 req.PageSize = math.MaxInt32
4226 } else if pageSize != 0 {
4227 req.PageSize = int32(pageSize)
4228 }
4229 baseUrl, err := url.Parse(c.endpoint)
4230 if err != nil {
4231 return nil, "", err
4232 }
4233 baseUrl.Path += fmt.Sprintf("/v1/%v/assets", req.GetParent())
4234
4235 params := url.Values{}
4236 params.Add("$alt", "json;enum-encoding=int")
4237 if req.GetFilter() != "" {
4238 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
4239 }
4240 if req.GetPageSize() != 0 {
4241 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4242 }
4243 if req.GetPageToken() != "" {
4244 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4245 }
4246
4247 baseUrl.RawQuery = params.Encode()
4248
4249 // Build HTTP headers from client and context metadata.
4250 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4251 headers := gax.BuildHeaders(ctx, hds...)
4252 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4253 if settings.Path != "" {
4254 baseUrl.Path = settings.Path
4255 }
4256 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4257 if err != nil {
4258 return err
4259 }
4260 httpReq.Header = headers
4261
4262 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListAssets")
4263 if err != nil {
4264 return err
4265 }
4266 if err := unm.Unmarshal(buf, resp); err != nil {
4267 return err
4268 }
4269
4270 return nil
4271 }, opts...)
4272 if e != nil {
4273 return nil, "", e
4274 }
4275 it.Response = resp
4276 return resp.GetAssets(), resp.GetNextPageToken(), nil
4277 }
4278
4279 fetch := func(pageSize int, pageToken string) (string, error) {
4280 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4281 if err != nil {
4282 return "", err
4283 }
4284 it.items = append(it.items, items...)
4285 return nextPageToken, nil
4286 }
4287
4288 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4289 it.pageInfo.MaxSize = int(req.GetPageSize())
4290 it.pageInfo.Token = req.GetPageToken()
4291
4292 return it
4293 }
4294
4295 // DeleteAsset deletes asset inside corpus.
4296 func (c *warehouseRESTClient) DeleteAsset(ctx context.Context, req *visionaipb.DeleteAssetRequest, opts ...gax.CallOption) (*DeleteAssetOperation, error) {
4297 baseUrl, err := url.Parse(c.endpoint)
4298 if err != nil {
4299 return nil, err
4300 }
4301 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4302
4303 params := url.Values{}
4304 params.Add("$alt", "json;enum-encoding=int")
4305
4306 baseUrl.RawQuery = params.Encode()
4307
4308 // Build HTTP headers from client and context metadata.
4309 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4310
4311 hds = append(c.xGoogHeaders, hds...)
4312 hds = append(hds, "Content-Type", "application/json")
4313 headers := gax.BuildHeaders(ctx, hds...)
4314 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4315 resp := &longrunningpb.Operation{}
4316 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4317 if settings.Path != "" {
4318 baseUrl.Path = settings.Path
4319 }
4320 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
4321 if err != nil {
4322 return err
4323 }
4324 httpReq = httpReq.WithContext(ctx)
4325 httpReq.Header = headers
4326
4327 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteAsset")
4328 if err != nil {
4329 return err
4330 }
4331 if err := unm.Unmarshal(buf, resp); err != nil {
4332 return err
4333 }
4334
4335 return nil
4336 }, opts...)
4337 if e != nil {
4338 return nil, e
4339 }
4340
4341 override := fmt.Sprintf("/v1/%s", resp.GetName())
4342 return &DeleteAssetOperation{
4343 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4344 pollPath: override,
4345 }, nil
4346 }
4347
4348 // UploadAsset upload asset by specifing the asset Cloud Storage uri.
4349 // For video warehouse, it requires users who call this API have read access
4350 // to the cloud storage file. Once it is uploaded, it can be retrieved by
4351 // GenerateRetrievalUrl API which by default, only can retrieve cloud storage
4352 // files from the same project of the warehouse. To allow retrieval cloud
4353 // storage files that are in a separate project, it requires to find the
4354 // vision ai service account (Go to IAM, check checkbox to show “Include
4355 // Google-provided role grants”, search for “Cloud Vision AI Service Agent”)
4356 // and grant the read access of the cloud storage files to that service
4357 // account.
4358 func (c *warehouseRESTClient) UploadAsset(ctx context.Context, req *visionaipb.UploadAssetRequest, opts ...gax.CallOption) (*UploadAssetOperation, error) {
4359 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4360 jsonReq, err := m.Marshal(req)
4361 if err != nil {
4362 return nil, err
4363 }
4364
4365 baseUrl, err := url.Parse(c.endpoint)
4366 if err != nil {
4367 return nil, err
4368 }
4369 baseUrl.Path += fmt.Sprintf("/v1/%v:upload", req.GetName())
4370
4371 params := url.Values{}
4372 params.Add("$alt", "json;enum-encoding=int")
4373
4374 baseUrl.RawQuery = params.Encode()
4375
4376 // Build HTTP headers from client and context metadata.
4377 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4378
4379 hds = append(c.xGoogHeaders, hds...)
4380 hds = append(hds, "Content-Type", "application/json")
4381 headers := gax.BuildHeaders(ctx, hds...)
4382 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4383 resp := &longrunningpb.Operation{}
4384 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4385 if settings.Path != "" {
4386 baseUrl.Path = settings.Path
4387 }
4388 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4389 if err != nil {
4390 return err
4391 }
4392 httpReq = httpReq.WithContext(ctx)
4393 httpReq.Header = headers
4394
4395 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UploadAsset")
4396 if err != nil {
4397 return err
4398 }
4399 if err := unm.Unmarshal(buf, resp); err != nil {
4400 return err
4401 }
4402
4403 return nil
4404 }, opts...)
4405 if e != nil {
4406 return nil, e
4407 }
4408
4409 override := fmt.Sprintf("/v1/%s", resp.GetName())
4410 return &UploadAssetOperation{
4411 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4412 pollPath: override,
4413 }, nil
4414 }
4415
4416 // GenerateRetrievalUrl generates a signed url for downloading the asset.
4417 // For video warehouse, please see comment of UploadAsset about how to allow
4418 // retrieval of cloud storage files in a different project.
4419 func (c *warehouseRESTClient) GenerateRetrievalUrl(ctx context.Context, req *visionaipb.GenerateRetrievalUrlRequest, opts ...gax.CallOption) (*visionaipb.GenerateRetrievalUrlResponse, error) {
4420 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4421 jsonReq, err := m.Marshal(req)
4422 if err != nil {
4423 return nil, err
4424 }
4425
4426 baseUrl, err := url.Parse(c.endpoint)
4427 if err != nil {
4428 return nil, err
4429 }
4430 baseUrl.Path += fmt.Sprintf("/v1/%v:generateRetrievalUrl", req.GetName())
4431
4432 params := url.Values{}
4433 params.Add("$alt", "json;enum-encoding=int")
4434
4435 baseUrl.RawQuery = params.Encode()
4436
4437 // Build HTTP headers from client and context metadata.
4438 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4439
4440 hds = append(c.xGoogHeaders, hds...)
4441 hds = append(hds, "Content-Type", "application/json")
4442 headers := gax.BuildHeaders(ctx, hds...)
4443 opts = append((*c.CallOptions).GenerateRetrievalUrl[0:len((*c.CallOptions).GenerateRetrievalUrl):len((*c.CallOptions).GenerateRetrievalUrl)], opts...)
4444 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4445 resp := &visionaipb.GenerateRetrievalUrlResponse{}
4446 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4447 if settings.Path != "" {
4448 baseUrl.Path = settings.Path
4449 }
4450 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4451 if err != nil {
4452 return err
4453 }
4454 httpReq = httpReq.WithContext(ctx)
4455 httpReq.Header = headers
4456
4457 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GenerateRetrievalUrl")
4458 if err != nil {
4459 return err
4460 }
4461
4462 if err := unm.Unmarshal(buf, resp); err != nil {
4463 return err
4464 }
4465
4466 return nil
4467 }, opts...)
4468 if e != nil {
4469 return nil, e
4470 }
4471 return resp, nil
4472 }
4473
4474 // AnalyzeAsset analyze asset to power search capability.
4475 func (c *warehouseRESTClient) AnalyzeAsset(ctx context.Context, req *visionaipb.AnalyzeAssetRequest, opts ...gax.CallOption) (*AnalyzeAssetOperation, error) {
4476 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4477 jsonReq, err := m.Marshal(req)
4478 if err != nil {
4479 return nil, err
4480 }
4481
4482 baseUrl, err := url.Parse(c.endpoint)
4483 if err != nil {
4484 return nil, err
4485 }
4486 baseUrl.Path += fmt.Sprintf("/v1/%v:analyze", req.GetName())
4487
4488 params := url.Values{}
4489 params.Add("$alt", "json;enum-encoding=int")
4490
4491 baseUrl.RawQuery = params.Encode()
4492
4493 // Build HTTP headers from client and context metadata.
4494 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4495
4496 hds = append(c.xGoogHeaders, hds...)
4497 hds = append(hds, "Content-Type", "application/json")
4498 headers := gax.BuildHeaders(ctx, hds...)
4499 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4500 resp := &longrunningpb.Operation{}
4501 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4502 if settings.Path != "" {
4503 baseUrl.Path = settings.Path
4504 }
4505 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4506 if err != nil {
4507 return err
4508 }
4509 httpReq = httpReq.WithContext(ctx)
4510 httpReq.Header = headers
4511
4512 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AnalyzeAsset")
4513 if err != nil {
4514 return err
4515 }
4516 if err := unm.Unmarshal(buf, resp); err != nil {
4517 return err
4518 }
4519
4520 return nil
4521 }, opts...)
4522 if e != nil {
4523 return nil, e
4524 }
4525
4526 override := fmt.Sprintf("/v1/%s", resp.GetName())
4527 return &AnalyzeAssetOperation{
4528 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4529 pollPath: override,
4530 }, nil
4531 }
4532
4533 // IndexAsset index one asset for search.
4534 // Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND
4535 func (c *warehouseRESTClient) IndexAsset(ctx context.Context, req *visionaipb.IndexAssetRequest, opts ...gax.CallOption) (*IndexAssetOperation, error) {
4536 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4537 jsonReq, err := m.Marshal(req)
4538 if err != nil {
4539 return nil, err
4540 }
4541
4542 baseUrl, err := url.Parse(c.endpoint)
4543 if err != nil {
4544 return nil, err
4545 }
4546 baseUrl.Path += fmt.Sprintf("/v1/%v:index", req.GetName())
4547
4548 params := url.Values{}
4549 params.Add("$alt", "json;enum-encoding=int")
4550
4551 baseUrl.RawQuery = params.Encode()
4552
4553 // Build HTTP headers from client and context metadata.
4554 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4555
4556 hds = append(c.xGoogHeaders, hds...)
4557 hds = append(hds, "Content-Type", "application/json")
4558 headers := gax.BuildHeaders(ctx, hds...)
4559 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4560 resp := &longrunningpb.Operation{}
4561 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4562 if settings.Path != "" {
4563 baseUrl.Path = settings.Path
4564 }
4565 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4566 if err != nil {
4567 return err
4568 }
4569 httpReq = httpReq.WithContext(ctx)
4570 httpReq.Header = headers
4571
4572 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "IndexAsset")
4573 if err != nil {
4574 return err
4575 }
4576 if err := unm.Unmarshal(buf, resp); err != nil {
4577 return err
4578 }
4579
4580 return nil
4581 }, opts...)
4582 if e != nil {
4583 return nil, e
4584 }
4585
4586 override := fmt.Sprintf("/v1/%s", resp.GetName())
4587 return &IndexAssetOperation{
4588 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4589 pollPath: override,
4590 }, nil
4591 }
4592
4593 // RemoveIndexAsset remove one asset’s index data for search.
4594 // Supported corpus type: Corpus.Type.VIDEO_ON_DEMAND
4595 func (c *warehouseRESTClient) RemoveIndexAsset(ctx context.Context, req *visionaipb.RemoveIndexAssetRequest, opts ...gax.CallOption) (*RemoveIndexAssetOperation, error) {
4596 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4597 jsonReq, err := m.Marshal(req)
4598 if err != nil {
4599 return nil, err
4600 }
4601
4602 baseUrl, err := url.Parse(c.endpoint)
4603 if err != nil {
4604 return nil, err
4605 }
4606 baseUrl.Path += fmt.Sprintf("/v1/%v:removeIndex", req.GetName())
4607
4608 params := url.Values{}
4609 params.Add("$alt", "json;enum-encoding=int")
4610
4611 baseUrl.RawQuery = params.Encode()
4612
4613 // Build HTTP headers from client and context metadata.
4614 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4615
4616 hds = append(c.xGoogHeaders, hds...)
4617 hds = append(hds, "Content-Type", "application/json")
4618 headers := gax.BuildHeaders(ctx, hds...)
4619 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4620 resp := &longrunningpb.Operation{}
4621 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4622 if settings.Path != "" {
4623 baseUrl.Path = settings.Path
4624 }
4625 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4626 if err != nil {
4627 return err
4628 }
4629 httpReq = httpReq.WithContext(ctx)
4630 httpReq.Header = headers
4631
4632 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RemoveIndexAsset")
4633 if err != nil {
4634 return err
4635 }
4636 if err := unm.Unmarshal(buf, resp); err != nil {
4637 return err
4638 }
4639
4640 return nil
4641 }, opts...)
4642 if e != nil {
4643 return nil, e
4644 }
4645
4646 override := fmt.Sprintf("/v1/%s", resp.GetName())
4647 return &RemoveIndexAssetOperation{
4648 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4649 pollPath: override,
4650 }, nil
4651 }
4652
4653 // ViewIndexedAssets lists assets inside an index.
4654 func (c *warehouseRESTClient) ViewIndexedAssets(ctx context.Context, req *visionaipb.ViewIndexedAssetsRequest, opts ...gax.CallOption) *IndexedAssetIterator {
4655 it := &IndexedAssetIterator{}
4656 req = proto.Clone(req).(*visionaipb.ViewIndexedAssetsRequest)
4657 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4658 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.IndexedAsset, string, error) {
4659 resp := &visionaipb.ViewIndexedAssetsResponse{}
4660 if pageToken != "" {
4661 req.PageToken = pageToken
4662 }
4663 if pageSize > math.MaxInt32 {
4664 req.PageSize = math.MaxInt32
4665 } else if pageSize != 0 {
4666 req.PageSize = int32(pageSize)
4667 }
4668 baseUrl, err := url.Parse(c.endpoint)
4669 if err != nil {
4670 return nil, "", err
4671 }
4672 baseUrl.Path += fmt.Sprintf("/v1/%v:viewAssets", req.GetIndex())
4673
4674 params := url.Values{}
4675 params.Add("$alt", "json;enum-encoding=int")
4676 if req.GetFilter() != "" {
4677 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
4678 }
4679 if req.GetPageSize() != 0 {
4680 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4681 }
4682 if req.GetPageToken() != "" {
4683 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4684 }
4685
4686 baseUrl.RawQuery = params.Encode()
4687
4688 // Build HTTP headers from client and context metadata.
4689 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4690 headers := gax.BuildHeaders(ctx, hds...)
4691 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4692 if settings.Path != "" {
4693 baseUrl.Path = settings.Path
4694 }
4695 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4696 if err != nil {
4697 return err
4698 }
4699 httpReq.Header = headers
4700
4701 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ViewIndexedAssets")
4702 if err != nil {
4703 return err
4704 }
4705 if err := unm.Unmarshal(buf, resp); err != nil {
4706 return err
4707 }
4708
4709 return nil
4710 }, opts...)
4711 if e != nil {
4712 return nil, "", e
4713 }
4714 it.Response = resp
4715 return resp.GetIndexedAssets(), resp.GetNextPageToken(), nil
4716 }
4717
4718 fetch := func(pageSize int, pageToken string) (string, error) {
4719 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4720 if err != nil {
4721 return "", err
4722 }
4723 it.items = append(it.items, items...)
4724 return nextPageToken, nil
4725 }
4726
4727 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4728 it.pageInfo.MaxSize = int(req.GetPageSize())
4729 it.pageInfo.Token = req.GetPageToken()
4730
4731 return it
4732 }
4733
4734 // CreateIndex creates an Index under the corpus.
4735 func (c *warehouseRESTClient) CreateIndex(ctx context.Context, req *visionaipb.CreateIndexRequest, opts ...gax.CallOption) (*CreateIndexOperation, error) {
4736 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4737 body := req.GetIndex()
4738 jsonReq, err := m.Marshal(body)
4739 if err != nil {
4740 return nil, err
4741 }
4742
4743 baseUrl, err := url.Parse(c.endpoint)
4744 if err != nil {
4745 return nil, err
4746 }
4747 baseUrl.Path += fmt.Sprintf("/v1/%v/indexes", req.GetParent())
4748
4749 params := url.Values{}
4750 params.Add("$alt", "json;enum-encoding=int")
4751 if req.GetIndexId() != "" {
4752 params.Add("indexId", fmt.Sprintf("%v", req.GetIndexId()))
4753 }
4754
4755 baseUrl.RawQuery = params.Encode()
4756
4757 // Build HTTP headers from client and context metadata.
4758 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
4759
4760 hds = append(c.xGoogHeaders, hds...)
4761 hds = append(hds, "Content-Type", "application/json")
4762 headers := gax.BuildHeaders(ctx, hds...)
4763 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4764 resp := &longrunningpb.Operation{}
4765 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4766 if settings.Path != "" {
4767 baseUrl.Path = settings.Path
4768 }
4769 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4770 if err != nil {
4771 return err
4772 }
4773 httpReq = httpReq.WithContext(ctx)
4774 httpReq.Header = headers
4775
4776 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateIndex")
4777 if err != nil {
4778 return err
4779 }
4780 if err := unm.Unmarshal(buf, resp); err != nil {
4781 return err
4782 }
4783
4784 return nil
4785 }, opts...)
4786 if e != nil {
4787 return nil, e
4788 }
4789
4790 override := fmt.Sprintf("/v1/%s", resp.GetName())
4791 return &CreateIndexOperation{
4792 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4793 pollPath: override,
4794 }, nil
4795 }
4796
4797 // UpdateIndex updates an Index under the corpus.
4798 // Users can perform a metadata-only update or trigger a full index rebuild
4799 // with different update_mask values.
4800 func (c *warehouseRESTClient) UpdateIndex(ctx context.Context, req *visionaipb.UpdateIndexRequest, opts ...gax.CallOption) (*UpdateIndexOperation, error) {
4801 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4802 body := req.GetIndex()
4803 jsonReq, err := m.Marshal(body)
4804 if err != nil {
4805 return nil, err
4806 }
4807
4808 baseUrl, err := url.Parse(c.endpoint)
4809 if err != nil {
4810 return nil, err
4811 }
4812 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetIndex().GetName())
4813
4814 params := url.Values{}
4815 params.Add("$alt", "json;enum-encoding=int")
4816 if req.GetUpdateMask() != nil {
4817 field, err := protojson.Marshal(req.GetUpdateMask())
4818 if err != nil {
4819 return nil, err
4820 }
4821 params.Add("updateMask", string(field[1:len(field)-1]))
4822 }
4823
4824 baseUrl.RawQuery = params.Encode()
4825
4826 // Build HTTP headers from client and context metadata.
4827 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index.name", url.QueryEscape(req.GetIndex().GetName()))}
4828
4829 hds = append(c.xGoogHeaders, hds...)
4830 hds = append(hds, "Content-Type", "application/json")
4831 headers := gax.BuildHeaders(ctx, hds...)
4832 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4833 resp := &longrunningpb.Operation{}
4834 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4835 if settings.Path != "" {
4836 baseUrl.Path = settings.Path
4837 }
4838 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
4839 if err != nil {
4840 return err
4841 }
4842 httpReq = httpReq.WithContext(ctx)
4843 httpReq.Header = headers
4844
4845 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateIndex")
4846 if err != nil {
4847 return err
4848 }
4849 if err := unm.Unmarshal(buf, resp); err != nil {
4850 return err
4851 }
4852
4853 return nil
4854 }, opts...)
4855 if e != nil {
4856 return nil, e
4857 }
4858
4859 override := fmt.Sprintf("/v1/%s", resp.GetName())
4860 return &UpdateIndexOperation{
4861 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4862 pollPath: override,
4863 }, nil
4864 }
4865
4866 // GetIndex gets the details of a single Index under a Corpus.
4867 func (c *warehouseRESTClient) GetIndex(ctx context.Context, req *visionaipb.GetIndexRequest, opts ...gax.CallOption) (*visionaipb.Index, error) {
4868 baseUrl, err := url.Parse(c.endpoint)
4869 if err != nil {
4870 return nil, err
4871 }
4872 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4873
4874 params := url.Values{}
4875 params.Add("$alt", "json;enum-encoding=int")
4876
4877 baseUrl.RawQuery = params.Encode()
4878
4879 // Build HTTP headers from client and context metadata.
4880 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4881
4882 hds = append(c.xGoogHeaders, hds...)
4883 hds = append(hds, "Content-Type", "application/json")
4884 headers := gax.BuildHeaders(ctx, hds...)
4885 opts = append((*c.CallOptions).GetIndex[0:len((*c.CallOptions).GetIndex):len((*c.CallOptions).GetIndex)], opts...)
4886 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4887 resp := &visionaipb.Index{}
4888 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4889 if settings.Path != "" {
4890 baseUrl.Path = settings.Path
4891 }
4892 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4893 if err != nil {
4894 return err
4895 }
4896 httpReq = httpReq.WithContext(ctx)
4897 httpReq.Header = headers
4898
4899 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetIndex")
4900 if err != nil {
4901 return err
4902 }
4903
4904 if err := unm.Unmarshal(buf, resp); err != nil {
4905 return err
4906 }
4907
4908 return nil
4909 }, opts...)
4910 if e != nil {
4911 return nil, e
4912 }
4913 return resp, nil
4914 }
4915
4916 // ListIndexes list all Indexes in a given Corpus.
4917 func (c *warehouseRESTClient) ListIndexes(ctx context.Context, req *visionaipb.ListIndexesRequest, opts ...gax.CallOption) *IndexIterator {
4918 it := &IndexIterator{}
4919 req = proto.Clone(req).(*visionaipb.ListIndexesRequest)
4920 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4921 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Index, string, error) {
4922 resp := &visionaipb.ListIndexesResponse{}
4923 if pageToken != "" {
4924 req.PageToken = pageToken
4925 }
4926 if pageSize > math.MaxInt32 {
4927 req.PageSize = math.MaxInt32
4928 } else if pageSize != 0 {
4929 req.PageSize = int32(pageSize)
4930 }
4931 baseUrl, err := url.Parse(c.endpoint)
4932 if err != nil {
4933 return nil, "", err
4934 }
4935 baseUrl.Path += fmt.Sprintf("/v1/%v/indexes", req.GetParent())
4936
4937 params := url.Values{}
4938 params.Add("$alt", "json;enum-encoding=int")
4939 if req.GetPageSize() != 0 {
4940 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4941 }
4942 if req.GetPageToken() != "" {
4943 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4944 }
4945
4946 baseUrl.RawQuery = params.Encode()
4947
4948 // Build HTTP headers from client and context metadata.
4949 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4950 headers := gax.BuildHeaders(ctx, hds...)
4951 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4952 if settings.Path != "" {
4953 baseUrl.Path = settings.Path
4954 }
4955 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4956 if err != nil {
4957 return err
4958 }
4959 httpReq.Header = headers
4960
4961 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListIndexes")
4962 if err != nil {
4963 return err
4964 }
4965 if err := unm.Unmarshal(buf, resp); err != nil {
4966 return err
4967 }
4968
4969 return nil
4970 }, opts...)
4971 if e != nil {
4972 return nil, "", e
4973 }
4974 it.Response = resp
4975 return resp.GetIndexes(), resp.GetNextPageToken(), nil
4976 }
4977
4978 fetch := func(pageSize int, pageToken string) (string, error) {
4979 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4980 if err != nil {
4981 return "", err
4982 }
4983 it.items = append(it.items, items...)
4984 return nextPageToken, nil
4985 }
4986
4987 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4988 it.pageInfo.MaxSize = int(req.GetPageSize())
4989 it.pageInfo.Token = req.GetPageToken()
4990
4991 return it
4992 }
4993
4994 // DeleteIndex delete a single Index. In order to delete an index, the caller must
4995 // make sure that it is not deployed to any index endpoint.
4996 func (c *warehouseRESTClient) DeleteIndex(ctx context.Context, req *visionaipb.DeleteIndexRequest, opts ...gax.CallOption) (*DeleteIndexOperation, error) {
4997 baseUrl, err := url.Parse(c.endpoint)
4998 if err != nil {
4999 return nil, err
5000 }
5001 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5002
5003 params := url.Values{}
5004 params.Add("$alt", "json;enum-encoding=int")
5005
5006 baseUrl.RawQuery = params.Encode()
5007
5008 // Build HTTP headers from client and context metadata.
5009 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5010
5011 hds = append(c.xGoogHeaders, hds...)
5012 hds = append(hds, "Content-Type", "application/json")
5013 headers := gax.BuildHeaders(ctx, hds...)
5014 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5015 resp := &longrunningpb.Operation{}
5016 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5017 if settings.Path != "" {
5018 baseUrl.Path = settings.Path
5019 }
5020 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
5021 if err != nil {
5022 return err
5023 }
5024 httpReq = httpReq.WithContext(ctx)
5025 httpReq.Header = headers
5026
5027 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteIndex")
5028 if err != nil {
5029 return err
5030 }
5031 if err := unm.Unmarshal(buf, resp); err != nil {
5032 return err
5033 }
5034
5035 return nil
5036 }, opts...)
5037 if e != nil {
5038 return nil, e
5039 }
5040
5041 override := fmt.Sprintf("/v1/%s", resp.GetName())
5042 return &DeleteIndexOperation{
5043 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
5044 pollPath: override,
5045 }, nil
5046 }
5047
5048 // CreateCorpus creates a corpus inside a project.
5049 func (c *warehouseRESTClient) CreateCorpus(ctx context.Context, req *visionaipb.CreateCorpusRequest, opts ...gax.CallOption) (*CreateCorpusOperation, error) {
5050 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5051 body := req.GetCorpus()
5052 jsonReq, err := m.Marshal(body)
5053 if err != nil {
5054 return nil, err
5055 }
5056
5057 baseUrl, err := url.Parse(c.endpoint)
5058 if err != nil {
5059 return nil, err
5060 }
5061 baseUrl.Path += fmt.Sprintf("/v1/%v/corpora", req.GetParent())
5062
5063 params := url.Values{}
5064 params.Add("$alt", "json;enum-encoding=int")
5065
5066 baseUrl.RawQuery = params.Encode()
5067
5068 // Build HTTP headers from client and context metadata.
5069 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
5070
5071 hds = append(c.xGoogHeaders, hds...)
5072 hds = append(hds, "Content-Type", "application/json")
5073 headers := gax.BuildHeaders(ctx, hds...)
5074 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5075 resp := &longrunningpb.Operation{}
5076 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5077 if settings.Path != "" {
5078 baseUrl.Path = settings.Path
5079 }
5080 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
5081 if err != nil {
5082 return err
5083 }
5084 httpReq = httpReq.WithContext(ctx)
5085 httpReq.Header = headers
5086
5087 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateCorpus")
5088 if err != nil {
5089 return err
5090 }
5091 if err := unm.Unmarshal(buf, resp); err != nil {
5092 return err
5093 }
5094
5095 return nil
5096 }, opts...)
5097 if e != nil {
5098 return nil, e
5099 }
5100
5101 override := fmt.Sprintf("/v1/%s", resp.GetName())
5102 return &CreateCorpusOperation{
5103 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
5104 pollPath: override,
5105 }, nil
5106 }
5107
5108 // GetCorpus gets corpus details inside a project.
5109 func (c *warehouseRESTClient) GetCorpus(ctx context.Context, req *visionaipb.GetCorpusRequest, opts ...gax.CallOption) (*visionaipb.Corpus, error) {
5110 baseUrl, err := url.Parse(c.endpoint)
5111 if err != nil {
5112 return nil, err
5113 }
5114 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5115
5116 params := url.Values{}
5117 params.Add("$alt", "json;enum-encoding=int")
5118
5119 baseUrl.RawQuery = params.Encode()
5120
5121 // Build HTTP headers from client and context metadata.
5122 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5123
5124 hds = append(c.xGoogHeaders, hds...)
5125 hds = append(hds, "Content-Type", "application/json")
5126 headers := gax.BuildHeaders(ctx, hds...)
5127 opts = append((*c.CallOptions).GetCorpus[0:len((*c.CallOptions).GetCorpus):len((*c.CallOptions).GetCorpus)], opts...)
5128 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5129 resp := &visionaipb.Corpus{}
5130 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5131 if settings.Path != "" {
5132 baseUrl.Path = settings.Path
5133 }
5134 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5135 if err != nil {
5136 return err
5137 }
5138 httpReq = httpReq.WithContext(ctx)
5139 httpReq.Header = headers
5140
5141 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetCorpus")
5142 if err != nil {
5143 return err
5144 }
5145
5146 if err := unm.Unmarshal(buf, resp); err != nil {
5147 return err
5148 }
5149
5150 return nil
5151 }, opts...)
5152 if e != nil {
5153 return nil, e
5154 }
5155 return resp, nil
5156 }
5157
5158 // UpdateCorpus updates a corpus in a project.
5159 func (c *warehouseRESTClient) UpdateCorpus(ctx context.Context, req *visionaipb.UpdateCorpusRequest, opts ...gax.CallOption) (*visionaipb.Corpus, error) {
5160 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5161 body := req.GetCorpus()
5162 jsonReq, err := m.Marshal(body)
5163 if err != nil {
5164 return nil, err
5165 }
5166
5167 baseUrl, err := url.Parse(c.endpoint)
5168 if err != nil {
5169 return nil, err
5170 }
5171 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetCorpus().GetName())
5172
5173 params := url.Values{}
5174 params.Add("$alt", "json;enum-encoding=int")
5175 if req.GetUpdateMask() != nil {
5176 field, err := protojson.Marshal(req.GetUpdateMask())
5177 if err != nil {
5178 return nil, err
5179 }
5180 params.Add("updateMask", string(field[1:len(field)-1]))
5181 }
5182
5183 baseUrl.RawQuery = params.Encode()
5184
5185 // Build HTTP headers from client and context metadata.
5186 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "corpus.name", url.QueryEscape(req.GetCorpus().GetName()))}
5187
5188 hds = append(c.xGoogHeaders, hds...)
5189 hds = append(hds, "Content-Type", "application/json")
5190 headers := gax.BuildHeaders(ctx, hds...)
5191 opts = append((*c.CallOptions).UpdateCorpus[0:len((*c.CallOptions).UpdateCorpus):len((*c.CallOptions).UpdateCorpus)], opts...)
5192 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5193 resp := &visionaipb.Corpus{}
5194 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5195 if settings.Path != "" {
5196 baseUrl.Path = settings.Path
5197 }
5198 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
5199 if err != nil {
5200 return err
5201 }
5202 httpReq = httpReq.WithContext(ctx)
5203 httpReq.Header = headers
5204
5205 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateCorpus")
5206 if err != nil {
5207 return err
5208 }
5209
5210 if err := unm.Unmarshal(buf, resp); err != nil {
5211 return err
5212 }
5213
5214 return nil
5215 }, opts...)
5216 if e != nil {
5217 return nil, e
5218 }
5219 return resp, nil
5220 }
5221
5222 // ListCorpora lists all corpora in a project.
5223 func (c *warehouseRESTClient) ListCorpora(ctx context.Context, req *visionaipb.ListCorporaRequest, opts ...gax.CallOption) *CorpusIterator {
5224 it := &CorpusIterator{}
5225 req = proto.Clone(req).(*visionaipb.ListCorporaRequest)
5226 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5227 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Corpus, string, error) {
5228 resp := &visionaipb.ListCorporaResponse{}
5229 if pageToken != "" {
5230 req.PageToken = pageToken
5231 }
5232 if pageSize > math.MaxInt32 {
5233 req.PageSize = math.MaxInt32
5234 } else if pageSize != 0 {
5235 req.PageSize = int32(pageSize)
5236 }
5237 baseUrl, err := url.Parse(c.endpoint)
5238 if err != nil {
5239 return nil, "", err
5240 }
5241 baseUrl.Path += fmt.Sprintf("/v1/%v/corpora", req.GetParent())
5242
5243 params := url.Values{}
5244 params.Add("$alt", "json;enum-encoding=int")
5245 if req.GetFilter() != "" {
5246 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
5247 }
5248 if req.GetPageSize() != 0 {
5249 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
5250 }
5251 if req.GetPageToken() != "" {
5252 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
5253 }
5254
5255 baseUrl.RawQuery = params.Encode()
5256
5257 // Build HTTP headers from client and context metadata.
5258 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
5259 headers := gax.BuildHeaders(ctx, hds...)
5260 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5261 if settings.Path != "" {
5262 baseUrl.Path = settings.Path
5263 }
5264 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5265 if err != nil {
5266 return err
5267 }
5268 httpReq.Header = headers
5269
5270 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListCorpora")
5271 if err != nil {
5272 return err
5273 }
5274 if err := unm.Unmarshal(buf, resp); err != nil {
5275 return err
5276 }
5277
5278 return nil
5279 }, opts...)
5280 if e != nil {
5281 return nil, "", e
5282 }
5283 it.Response = resp
5284 return resp.GetCorpora(), resp.GetNextPageToken(), nil
5285 }
5286
5287 fetch := func(pageSize int, pageToken string) (string, error) {
5288 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
5289 if err != nil {
5290 return "", err
5291 }
5292 it.items = append(it.items, items...)
5293 return nextPageToken, nil
5294 }
5295
5296 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
5297 it.pageInfo.MaxSize = int(req.GetPageSize())
5298 it.pageInfo.Token = req.GetPageToken()
5299
5300 return it
5301 }
5302
5303 // DeleteCorpus deletes a corpus only if its empty.
5304 // Returns empty response.
5305 func (c *warehouseRESTClient) DeleteCorpus(ctx context.Context, req *visionaipb.DeleteCorpusRequest, opts ...gax.CallOption) error {
5306 baseUrl, err := url.Parse(c.endpoint)
5307 if err != nil {
5308 return err
5309 }
5310 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5311
5312 params := url.Values{}
5313 params.Add("$alt", "json;enum-encoding=int")
5314
5315 baseUrl.RawQuery = params.Encode()
5316
5317 // Build HTTP headers from client and context metadata.
5318 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5319
5320 hds = append(c.xGoogHeaders, hds...)
5321 hds = append(hds, "Content-Type", "application/json")
5322 headers := gax.BuildHeaders(ctx, hds...)
5323 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5324 if settings.Path != "" {
5325 baseUrl.Path = settings.Path
5326 }
5327 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
5328 if err != nil {
5329 return err
5330 }
5331 httpReq = httpReq.WithContext(ctx)
5332 httpReq.Header = headers
5333
5334 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteCorpus")
5335 return err
5336 }, opts...)
5337 }
5338
5339 // AnalyzeCorpus analyzes a corpus.
5340 func (c *warehouseRESTClient) AnalyzeCorpus(ctx context.Context, req *visionaipb.AnalyzeCorpusRequest, opts ...gax.CallOption) (*AnalyzeCorpusOperation, error) {
5341 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5342 jsonReq, err := m.Marshal(req)
5343 if err != nil {
5344 return nil, err
5345 }
5346
5347 baseUrl, err := url.Parse(c.endpoint)
5348 if err != nil {
5349 return nil, err
5350 }
5351 baseUrl.Path += fmt.Sprintf("/v1/%v:analyze", req.GetName())
5352
5353 params := url.Values{}
5354 params.Add("$alt", "json;enum-encoding=int")
5355
5356 baseUrl.RawQuery = params.Encode()
5357
5358 // Build HTTP headers from client and context metadata.
5359 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5360
5361 hds = append(c.xGoogHeaders, hds...)
5362 hds = append(hds, "Content-Type", "application/json")
5363 headers := gax.BuildHeaders(ctx, hds...)
5364 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5365 resp := &longrunningpb.Operation{}
5366 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5367 if settings.Path != "" {
5368 baseUrl.Path = settings.Path
5369 }
5370 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
5371 if err != nil {
5372 return err
5373 }
5374 httpReq = httpReq.WithContext(ctx)
5375 httpReq.Header = headers
5376
5377 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AnalyzeCorpus")
5378 if err != nil {
5379 return err
5380 }
5381 if err := unm.Unmarshal(buf, resp); err != nil {
5382 return err
5383 }
5384
5385 return nil
5386 }, opts...)
5387 if e != nil {
5388 return nil, e
5389 }
5390
5391 override := fmt.Sprintf("/v1/%s", resp.GetName())
5392 return &AnalyzeCorpusOperation{
5393 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
5394 pollPath: override,
5395 }, nil
5396 }
5397
5398 // CreateDataSchema creates data schema inside corpus.
5399 func (c *warehouseRESTClient) CreateDataSchema(ctx context.Context, req *visionaipb.CreateDataSchemaRequest, opts ...gax.CallOption) (*visionaipb.DataSchema, error) {
5400 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5401 body := req.GetDataSchema()
5402 jsonReq, err := m.Marshal(body)
5403 if err != nil {
5404 return nil, err
5405 }
5406
5407 baseUrl, err := url.Parse(c.endpoint)
5408 if err != nil {
5409 return nil, err
5410 }
5411 baseUrl.Path += fmt.Sprintf("/v1/%v/dataSchemas", req.GetParent())
5412
5413 params := url.Values{}
5414 params.Add("$alt", "json;enum-encoding=int")
5415
5416 baseUrl.RawQuery = params.Encode()
5417
5418 // Build HTTP headers from client and context metadata.
5419 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
5420
5421 hds = append(c.xGoogHeaders, hds...)
5422 hds = append(hds, "Content-Type", "application/json")
5423 headers := gax.BuildHeaders(ctx, hds...)
5424 opts = append((*c.CallOptions).CreateDataSchema[0:len((*c.CallOptions).CreateDataSchema):len((*c.CallOptions).CreateDataSchema)], opts...)
5425 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5426 resp := &visionaipb.DataSchema{}
5427 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5428 if settings.Path != "" {
5429 baseUrl.Path = settings.Path
5430 }
5431 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
5432 if err != nil {
5433 return err
5434 }
5435 httpReq = httpReq.WithContext(ctx)
5436 httpReq.Header = headers
5437
5438 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateDataSchema")
5439 if err != nil {
5440 return err
5441 }
5442
5443 if err := unm.Unmarshal(buf, resp); err != nil {
5444 return err
5445 }
5446
5447 return nil
5448 }, opts...)
5449 if e != nil {
5450 return nil, e
5451 }
5452 return resp, nil
5453 }
5454
5455 // UpdateDataSchema updates data schema inside corpus.
5456 func (c *warehouseRESTClient) UpdateDataSchema(ctx context.Context, req *visionaipb.UpdateDataSchemaRequest, opts ...gax.CallOption) (*visionaipb.DataSchema, error) {
5457 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5458 body := req.GetDataSchema()
5459 jsonReq, err := m.Marshal(body)
5460 if err != nil {
5461 return nil, err
5462 }
5463
5464 baseUrl, err := url.Parse(c.endpoint)
5465 if err != nil {
5466 return nil, err
5467 }
5468 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetDataSchema().GetName())
5469
5470 params := url.Values{}
5471 params.Add("$alt", "json;enum-encoding=int")
5472 if req.GetUpdateMask() != nil {
5473 field, err := protojson.Marshal(req.GetUpdateMask())
5474 if err != nil {
5475 return nil, err
5476 }
5477 params.Add("updateMask", string(field[1:len(field)-1]))
5478 }
5479
5480 baseUrl.RawQuery = params.Encode()
5481
5482 // Build HTTP headers from client and context metadata.
5483 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "data_schema.name", url.QueryEscape(req.GetDataSchema().GetName()))}
5484
5485 hds = append(c.xGoogHeaders, hds...)
5486 hds = append(hds, "Content-Type", "application/json")
5487 headers := gax.BuildHeaders(ctx, hds...)
5488 opts = append((*c.CallOptions).UpdateDataSchema[0:len((*c.CallOptions).UpdateDataSchema):len((*c.CallOptions).UpdateDataSchema)], opts...)
5489 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5490 resp := &visionaipb.DataSchema{}
5491 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5492 if settings.Path != "" {
5493 baseUrl.Path = settings.Path
5494 }
5495 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
5496 if err != nil {
5497 return err
5498 }
5499 httpReq = httpReq.WithContext(ctx)
5500 httpReq.Header = headers
5501
5502 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateDataSchema")
5503 if err != nil {
5504 return err
5505 }
5506
5507 if err := unm.Unmarshal(buf, resp); err != nil {
5508 return err
5509 }
5510
5511 return nil
5512 }, opts...)
5513 if e != nil {
5514 return nil, e
5515 }
5516 return resp, nil
5517 }
5518
5519 // GetDataSchema gets data schema inside corpus.
5520 func (c *warehouseRESTClient) GetDataSchema(ctx context.Context, req *visionaipb.GetDataSchemaRequest, opts ...gax.CallOption) (*visionaipb.DataSchema, error) {
5521 baseUrl, err := url.Parse(c.endpoint)
5522 if err != nil {
5523 return nil, err
5524 }
5525 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5526
5527 params := url.Values{}
5528 params.Add("$alt", "json;enum-encoding=int")
5529
5530 baseUrl.RawQuery = params.Encode()
5531
5532 // Build HTTP headers from client and context metadata.
5533 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5534
5535 hds = append(c.xGoogHeaders, hds...)
5536 hds = append(hds, "Content-Type", "application/json")
5537 headers := gax.BuildHeaders(ctx, hds...)
5538 opts = append((*c.CallOptions).GetDataSchema[0:len((*c.CallOptions).GetDataSchema):len((*c.CallOptions).GetDataSchema)], opts...)
5539 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5540 resp := &visionaipb.DataSchema{}
5541 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5542 if settings.Path != "" {
5543 baseUrl.Path = settings.Path
5544 }
5545 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5546 if err != nil {
5547 return err
5548 }
5549 httpReq = httpReq.WithContext(ctx)
5550 httpReq.Header = headers
5551
5552 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetDataSchema")
5553 if err != nil {
5554 return err
5555 }
5556
5557 if err := unm.Unmarshal(buf, resp); err != nil {
5558 return err
5559 }
5560
5561 return nil
5562 }, opts...)
5563 if e != nil {
5564 return nil, e
5565 }
5566 return resp, nil
5567 }
5568
5569 // DeleteDataSchema deletes data schema inside corpus.
5570 func (c *warehouseRESTClient) DeleteDataSchema(ctx context.Context, req *visionaipb.DeleteDataSchemaRequest, opts ...gax.CallOption) error {
5571 baseUrl, err := url.Parse(c.endpoint)
5572 if err != nil {
5573 return err
5574 }
5575 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5576
5577 params := url.Values{}
5578 params.Add("$alt", "json;enum-encoding=int")
5579
5580 baseUrl.RawQuery = params.Encode()
5581
5582 // Build HTTP headers from client and context metadata.
5583 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5584
5585 hds = append(c.xGoogHeaders, hds...)
5586 hds = append(hds, "Content-Type", "application/json")
5587 headers := gax.BuildHeaders(ctx, hds...)
5588 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5589 if settings.Path != "" {
5590 baseUrl.Path = settings.Path
5591 }
5592 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
5593 if err != nil {
5594 return err
5595 }
5596 httpReq = httpReq.WithContext(ctx)
5597 httpReq.Header = headers
5598
5599 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteDataSchema")
5600 return err
5601 }, opts...)
5602 }
5603
5604 // ListDataSchemas lists a list of data schemas inside corpus.
5605 func (c *warehouseRESTClient) ListDataSchemas(ctx context.Context, req *visionaipb.ListDataSchemasRequest, opts ...gax.CallOption) *DataSchemaIterator {
5606 it := &DataSchemaIterator{}
5607 req = proto.Clone(req).(*visionaipb.ListDataSchemasRequest)
5608 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5609 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.DataSchema, string, error) {
5610 resp := &visionaipb.ListDataSchemasResponse{}
5611 if pageToken != "" {
5612 req.PageToken = pageToken
5613 }
5614 if pageSize > math.MaxInt32 {
5615 req.PageSize = math.MaxInt32
5616 } else if pageSize != 0 {
5617 req.PageSize = int32(pageSize)
5618 }
5619 baseUrl, err := url.Parse(c.endpoint)
5620 if err != nil {
5621 return nil, "", err
5622 }
5623 baseUrl.Path += fmt.Sprintf("/v1/%v/dataSchemas", req.GetParent())
5624
5625 params := url.Values{}
5626 params.Add("$alt", "json;enum-encoding=int")
5627 if req.GetPageSize() != 0 {
5628 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
5629 }
5630 if req.GetPageToken() != "" {
5631 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
5632 }
5633
5634 baseUrl.RawQuery = params.Encode()
5635
5636 // Build HTTP headers from client and context metadata.
5637 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
5638 headers := gax.BuildHeaders(ctx, hds...)
5639 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5640 if settings.Path != "" {
5641 baseUrl.Path = settings.Path
5642 }
5643 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5644 if err != nil {
5645 return err
5646 }
5647 httpReq.Header = headers
5648
5649 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDataSchemas")
5650 if err != nil {
5651 return err
5652 }
5653 if err := unm.Unmarshal(buf, resp); err != nil {
5654 return err
5655 }
5656
5657 return nil
5658 }, opts...)
5659 if e != nil {
5660 return nil, "", e
5661 }
5662 it.Response = resp
5663 return resp.GetDataSchemas(), resp.GetNextPageToken(), nil
5664 }
5665
5666 fetch := func(pageSize int, pageToken string) (string, error) {
5667 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
5668 if err != nil {
5669 return "", err
5670 }
5671 it.items = append(it.items, items...)
5672 return nextPageToken, nil
5673 }
5674
5675 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
5676 it.pageInfo.MaxSize = int(req.GetPageSize())
5677 it.pageInfo.Token = req.GetPageToken()
5678
5679 return it
5680 }
5681
5682 // CreateAnnotation creates annotation inside asset.
5683 func (c *warehouseRESTClient) CreateAnnotation(ctx context.Context, req *visionaipb.CreateAnnotationRequest, opts ...gax.CallOption) (*visionaipb.Annotation, error) {
5684 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5685 body := req.GetAnnotation()
5686 jsonReq, err := m.Marshal(body)
5687 if err != nil {
5688 return nil, err
5689 }
5690
5691 baseUrl, err := url.Parse(c.endpoint)
5692 if err != nil {
5693 return nil, err
5694 }
5695 baseUrl.Path += fmt.Sprintf("/v1/%v/annotations", req.GetParent())
5696
5697 params := url.Values{}
5698 params.Add("$alt", "json;enum-encoding=int")
5699 if req != nil && req.AnnotationId != nil {
5700 params.Add("annotationId", fmt.Sprintf("%v", req.GetAnnotationId()))
5701 }
5702
5703 baseUrl.RawQuery = params.Encode()
5704
5705 // Build HTTP headers from client and context metadata.
5706 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
5707
5708 hds = append(c.xGoogHeaders, hds...)
5709 hds = append(hds, "Content-Type", "application/json")
5710 headers := gax.BuildHeaders(ctx, hds...)
5711 opts = append((*c.CallOptions).CreateAnnotation[0:len((*c.CallOptions).CreateAnnotation):len((*c.CallOptions).CreateAnnotation)], opts...)
5712 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5713 resp := &visionaipb.Annotation{}
5714 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5715 if settings.Path != "" {
5716 baseUrl.Path = settings.Path
5717 }
5718 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
5719 if err != nil {
5720 return err
5721 }
5722 httpReq = httpReq.WithContext(ctx)
5723 httpReq.Header = headers
5724
5725 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateAnnotation")
5726 if err != nil {
5727 return err
5728 }
5729
5730 if err := unm.Unmarshal(buf, resp); err != nil {
5731 return err
5732 }
5733
5734 return nil
5735 }, opts...)
5736 if e != nil {
5737 return nil, e
5738 }
5739 return resp, nil
5740 }
5741
5742 // GetAnnotation reads annotation inside asset.
5743 func (c *warehouseRESTClient) GetAnnotation(ctx context.Context, req *visionaipb.GetAnnotationRequest, opts ...gax.CallOption) (*visionaipb.Annotation, error) {
5744 baseUrl, err := url.Parse(c.endpoint)
5745 if err != nil {
5746 return nil, err
5747 }
5748 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5749
5750 params := url.Values{}
5751 params.Add("$alt", "json;enum-encoding=int")
5752
5753 baseUrl.RawQuery = params.Encode()
5754
5755 // Build HTTP headers from client and context metadata.
5756 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5757
5758 hds = append(c.xGoogHeaders, hds...)
5759 hds = append(hds, "Content-Type", "application/json")
5760 headers := gax.BuildHeaders(ctx, hds...)
5761 opts = append((*c.CallOptions).GetAnnotation[0:len((*c.CallOptions).GetAnnotation):len((*c.CallOptions).GetAnnotation)], opts...)
5762 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5763 resp := &visionaipb.Annotation{}
5764 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5765 if settings.Path != "" {
5766 baseUrl.Path = settings.Path
5767 }
5768 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5769 if err != nil {
5770 return err
5771 }
5772 httpReq = httpReq.WithContext(ctx)
5773 httpReq.Header = headers
5774
5775 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetAnnotation")
5776 if err != nil {
5777 return err
5778 }
5779
5780 if err := unm.Unmarshal(buf, resp); err != nil {
5781 return err
5782 }
5783
5784 return nil
5785 }, opts...)
5786 if e != nil {
5787 return nil, e
5788 }
5789 return resp, nil
5790 }
5791
5792 // ListAnnotations lists a list of annotations inside asset.
5793 func (c *warehouseRESTClient) ListAnnotations(ctx context.Context, req *visionaipb.ListAnnotationsRequest, opts ...gax.CallOption) *AnnotationIterator {
5794 it := &AnnotationIterator{}
5795 req = proto.Clone(req).(*visionaipb.ListAnnotationsRequest)
5796 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5797 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Annotation, string, error) {
5798 resp := &visionaipb.ListAnnotationsResponse{}
5799 if pageToken != "" {
5800 req.PageToken = pageToken
5801 }
5802 if pageSize > math.MaxInt32 {
5803 req.PageSize = math.MaxInt32
5804 } else if pageSize != 0 {
5805 req.PageSize = int32(pageSize)
5806 }
5807 baseUrl, err := url.Parse(c.endpoint)
5808 if err != nil {
5809 return nil, "", err
5810 }
5811 baseUrl.Path += fmt.Sprintf("/v1/%v/annotations", req.GetParent())
5812
5813 params := url.Values{}
5814 params.Add("$alt", "json;enum-encoding=int")
5815 if req.GetFilter() != "" {
5816 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
5817 }
5818 if req.GetPageSize() != 0 {
5819 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
5820 }
5821 if req.GetPageToken() != "" {
5822 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
5823 }
5824
5825 baseUrl.RawQuery = params.Encode()
5826
5827 // Build HTTP headers from client and context metadata.
5828 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
5829 headers := gax.BuildHeaders(ctx, hds...)
5830 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5831 if settings.Path != "" {
5832 baseUrl.Path = settings.Path
5833 }
5834 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5835 if err != nil {
5836 return err
5837 }
5838 httpReq.Header = headers
5839
5840 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListAnnotations")
5841 if err != nil {
5842 return err
5843 }
5844 if err := unm.Unmarshal(buf, resp); err != nil {
5845 return err
5846 }
5847
5848 return nil
5849 }, opts...)
5850 if e != nil {
5851 return nil, "", e
5852 }
5853 it.Response = resp
5854 return resp.GetAnnotations(), resp.GetNextPageToken(), nil
5855 }
5856
5857 fetch := func(pageSize int, pageToken string) (string, error) {
5858 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
5859 if err != nil {
5860 return "", err
5861 }
5862 it.items = append(it.items, items...)
5863 return nextPageToken, nil
5864 }
5865
5866 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
5867 it.pageInfo.MaxSize = int(req.GetPageSize())
5868 it.pageInfo.Token = req.GetPageToken()
5869
5870 return it
5871 }
5872
5873 // UpdateAnnotation updates annotation inside asset.
5874 func (c *warehouseRESTClient) UpdateAnnotation(ctx context.Context, req *visionaipb.UpdateAnnotationRequest, opts ...gax.CallOption) (*visionaipb.Annotation, error) {
5875 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5876 body := req.GetAnnotation()
5877 jsonReq, err := m.Marshal(body)
5878 if err != nil {
5879 return nil, err
5880 }
5881
5882 baseUrl, err := url.Parse(c.endpoint)
5883 if err != nil {
5884 return nil, err
5885 }
5886 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetAnnotation().GetName())
5887
5888 params := url.Values{}
5889 params.Add("$alt", "json;enum-encoding=int")
5890 if req.GetUpdateMask() != nil {
5891 field, err := protojson.Marshal(req.GetUpdateMask())
5892 if err != nil {
5893 return nil, err
5894 }
5895 params.Add("updateMask", string(field[1:len(field)-1]))
5896 }
5897
5898 baseUrl.RawQuery = params.Encode()
5899
5900 // Build HTTP headers from client and context metadata.
5901 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "annotation.name", url.QueryEscape(req.GetAnnotation().GetName()))}
5902
5903 hds = append(c.xGoogHeaders, hds...)
5904 hds = append(hds, "Content-Type", "application/json")
5905 headers := gax.BuildHeaders(ctx, hds...)
5906 opts = append((*c.CallOptions).UpdateAnnotation[0:len((*c.CallOptions).UpdateAnnotation):len((*c.CallOptions).UpdateAnnotation)], opts...)
5907 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5908 resp := &visionaipb.Annotation{}
5909 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5910 if settings.Path != "" {
5911 baseUrl.Path = settings.Path
5912 }
5913 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
5914 if err != nil {
5915 return err
5916 }
5917 httpReq = httpReq.WithContext(ctx)
5918 httpReq.Header = headers
5919
5920 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateAnnotation")
5921 if err != nil {
5922 return err
5923 }
5924
5925 if err := unm.Unmarshal(buf, resp); err != nil {
5926 return err
5927 }
5928
5929 return nil
5930 }, opts...)
5931 if e != nil {
5932 return nil, e
5933 }
5934 return resp, nil
5935 }
5936
5937 // DeleteAnnotation deletes annotation inside asset.
5938 func (c *warehouseRESTClient) DeleteAnnotation(ctx context.Context, req *visionaipb.DeleteAnnotationRequest, opts ...gax.CallOption) error {
5939 baseUrl, err := url.Parse(c.endpoint)
5940 if err != nil {
5941 return err
5942 }
5943 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5944
5945 params := url.Values{}
5946 params.Add("$alt", "json;enum-encoding=int")
5947
5948 baseUrl.RawQuery = params.Encode()
5949
5950 // Build HTTP headers from client and context metadata.
5951 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5952
5953 hds = append(c.xGoogHeaders, hds...)
5954 hds = append(hds, "Content-Type", "application/json")
5955 headers := gax.BuildHeaders(ctx, hds...)
5956 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5957 if settings.Path != "" {
5958 baseUrl.Path = settings.Path
5959 }
5960 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
5961 if err != nil {
5962 return err
5963 }
5964 httpReq = httpReq.WithContext(ctx)
5965 httpReq.Header = headers
5966
5967 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteAnnotation")
5968 return err
5969 }, opts...)
5970 }
5971
5972 // IngestAsset ingests data for the asset. It is not allowed to ingest a data chunk which
5973 // is already expired according to TTL.
5974 // This method is only available via the gRPC API (not HTTP since
5975 // bi-directional streaming is not supported via HTTP).
5976 //
5977 // This method is not supported for the REST transport.
5978 func (c *warehouseRESTClient) IngestAsset(ctx context.Context, opts ...gax.CallOption) (visionaipb.Warehouse_IngestAssetClient, error) {
5979 return nil, errors.New("IngestAsset not yet supported for REST clients")
5980 }
5981
5982 // ClipAsset supported by STREAM_VIDEO corpus type.
5983 // Generates clips for downloading. The api takes in a time range, and
5984 // generates a clip of the first content available after start_time and
5985 // before end_time, which may overflow beyond these bounds.
5986 // Returned clips are truncated if the total size of the clips are larger
5987 // than 100MB.
5988 func (c *warehouseRESTClient) ClipAsset(ctx context.Context, req *visionaipb.ClipAssetRequest, opts ...gax.CallOption) (*visionaipb.ClipAssetResponse, error) {
5989 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5990 jsonReq, err := m.Marshal(req)
5991 if err != nil {
5992 return nil, err
5993 }
5994
5995 baseUrl, err := url.Parse(c.endpoint)
5996 if err != nil {
5997 return nil, err
5998 }
5999 baseUrl.Path += fmt.Sprintf("/v1/%v:clip", req.GetName())
6000
6001 params := url.Values{}
6002 params.Add("$alt", "json;enum-encoding=int")
6003
6004 baseUrl.RawQuery = params.Encode()
6005
6006 // Build HTTP headers from client and context metadata.
6007 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
6008
6009 hds = append(c.xGoogHeaders, hds...)
6010 hds = append(hds, "Content-Type", "application/json")
6011 headers := gax.BuildHeaders(ctx, hds...)
6012 opts = append((*c.CallOptions).ClipAsset[0:len((*c.CallOptions).ClipAsset):len((*c.CallOptions).ClipAsset)], opts...)
6013 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6014 resp := &visionaipb.ClipAssetResponse{}
6015 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6016 if settings.Path != "" {
6017 baseUrl.Path = settings.Path
6018 }
6019 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
6020 if err != nil {
6021 return err
6022 }
6023 httpReq = httpReq.WithContext(ctx)
6024 httpReq.Header = headers
6025
6026 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ClipAsset")
6027 if err != nil {
6028 return err
6029 }
6030
6031 if err := unm.Unmarshal(buf, resp); err != nil {
6032 return err
6033 }
6034
6035 return nil
6036 }, opts...)
6037 if e != nil {
6038 return nil, e
6039 }
6040 return resp, nil
6041 }
6042
6043 // GenerateHlsUri generates a uri for an HLS manifest. The api takes in a collection of time
6044 // ranges, and generates a URI for an HLS manifest that covers all the
6045 // requested time ranges.
6046 func (c *warehouseRESTClient) GenerateHlsUri(ctx context.Context, req *visionaipb.GenerateHlsUriRequest, opts ...gax.CallOption) (*visionaipb.GenerateHlsUriResponse, error) {
6047 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
6048 jsonReq, err := m.Marshal(req)
6049 if err != nil {
6050 return nil, err
6051 }
6052
6053 baseUrl, err := url.Parse(c.endpoint)
6054 if err != nil {
6055 return nil, err
6056 }
6057 baseUrl.Path += fmt.Sprintf("/v1/%v:generateHlsUri", req.GetName())
6058
6059 params := url.Values{}
6060 params.Add("$alt", "json;enum-encoding=int")
6061
6062 baseUrl.RawQuery = params.Encode()
6063
6064 // Build HTTP headers from client and context metadata.
6065 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
6066
6067 hds = append(c.xGoogHeaders, hds...)
6068 hds = append(hds, "Content-Type", "application/json")
6069 headers := gax.BuildHeaders(ctx, hds...)
6070 opts = append((*c.CallOptions).GenerateHlsUri[0:len((*c.CallOptions).GenerateHlsUri):len((*c.CallOptions).GenerateHlsUri)], opts...)
6071 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6072 resp := &visionaipb.GenerateHlsUriResponse{}
6073 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6074 if settings.Path != "" {
6075 baseUrl.Path = settings.Path
6076 }
6077 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
6078 if err != nil {
6079 return err
6080 }
6081 httpReq = httpReq.WithContext(ctx)
6082 httpReq.Header = headers
6083
6084 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GenerateHlsUri")
6085 if err != nil {
6086 return err
6087 }
6088
6089 if err := unm.Unmarshal(buf, resp); err != nil {
6090 return err
6091 }
6092
6093 return nil
6094 }, opts...)
6095 if e != nil {
6096 return nil, e
6097 }
6098 return resp, nil
6099 }
6100
6101 // ImportAssets imports assets (images plus annotations) from a meta file on cloud storage.
6102 // Each row in the meta file is corresponding to an image (specified by a
6103 // cloud storage uri) and its annotations.
6104 func (c *warehouseRESTClient) ImportAssets(ctx context.Context, req *visionaipb.ImportAssetsRequest, opts ...gax.CallOption) (*ImportAssetsOperation, error) {
6105 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
6106 jsonReq, err := m.Marshal(req)
6107 if err != nil {
6108 return nil, err
6109 }
6110
6111 baseUrl, err := url.Parse(c.endpoint)
6112 if err != nil {
6113 return nil, err
6114 }
6115 baseUrl.Path += fmt.Sprintf("/v1/%v/assets:import", req.GetParent())
6116
6117 params := url.Values{}
6118 params.Add("$alt", "json;enum-encoding=int")
6119
6120 baseUrl.RawQuery = params.Encode()
6121
6122 // Build HTTP headers from client and context metadata.
6123 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
6124
6125 hds = append(c.xGoogHeaders, hds...)
6126 hds = append(hds, "Content-Type", "application/json")
6127 headers := gax.BuildHeaders(ctx, hds...)
6128 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6129 resp := &longrunningpb.Operation{}
6130 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6131 if settings.Path != "" {
6132 baseUrl.Path = settings.Path
6133 }
6134 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
6135 if err != nil {
6136 return err
6137 }
6138 httpReq = httpReq.WithContext(ctx)
6139 httpReq.Header = headers
6140
6141 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ImportAssets")
6142 if err != nil {
6143 return err
6144 }
6145 if err := unm.Unmarshal(buf, resp); err != nil {
6146 return err
6147 }
6148
6149 return nil
6150 }, opts...)
6151 if e != nil {
6152 return nil, e
6153 }
6154
6155 override := fmt.Sprintf("/v1/%s", resp.GetName())
6156 return &ImportAssetsOperation{
6157 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
6158 pollPath: override,
6159 }, nil
6160 }
6161
6162 // CreateSearchConfig creates a search configuration inside a corpus.
6163 //
6164 // Please follow the rules below to create a valid CreateSearchConfigRequest.
6165 // — General Rules —
6166 //
6167 // Request.search_config_id must not be associated with an existing
6168 // SearchConfig.
6169 //
6170 // Request must contain at least one non-empty search_criteria_property or
6171 // facet_property.
6172 //
6173 // mapped_fields must not be empty, and must map to existing UGA keys.
6174 //
6175 // All mapped_fields must be of the same type.
6176 //
6177 // All mapped_fields must share the same granularity.
6178 //
6179 // All mapped_fields must share the same semantic SearchConfig match
6180 // options.
6181 // For property-specific rules, please reference the comments for
6182 // FacetProperty and SearchCriteriaProperty.
6183 func (c *warehouseRESTClient) CreateSearchConfig(ctx context.Context, req *visionaipb.CreateSearchConfigRequest, opts ...gax.CallOption) (*visionaipb.SearchConfig, error) {
6184 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
6185 body := req.GetSearchConfig()
6186 jsonReq, err := m.Marshal(body)
6187 if err != nil {
6188 return nil, err
6189 }
6190
6191 baseUrl, err := url.Parse(c.endpoint)
6192 if err != nil {
6193 return nil, err
6194 }
6195 baseUrl.Path += fmt.Sprintf("/v1/%v/searchConfigs", req.GetParent())
6196
6197 params := url.Values{}
6198 params.Add("$alt", "json;enum-encoding=int")
6199 params.Add("searchConfigId", fmt.Sprintf("%v", req.GetSearchConfigId()))
6200
6201 baseUrl.RawQuery = params.Encode()
6202
6203 // Build HTTP headers from client and context metadata.
6204 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
6205
6206 hds = append(c.xGoogHeaders, hds...)
6207 hds = append(hds, "Content-Type", "application/json")
6208 headers := gax.BuildHeaders(ctx, hds...)
6209 opts = append((*c.CallOptions).CreateSearchConfig[0:len((*c.CallOptions).CreateSearchConfig):len((*c.CallOptions).CreateSearchConfig)], opts...)
6210 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6211 resp := &visionaipb.SearchConfig{}
6212 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6213 if settings.Path != "" {
6214 baseUrl.Path = settings.Path
6215 }
6216 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
6217 if err != nil {
6218 return err
6219 }
6220 httpReq = httpReq.WithContext(ctx)
6221 httpReq.Header = headers
6222
6223 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateSearchConfig")
6224 if err != nil {
6225 return err
6226 }
6227
6228 if err := unm.Unmarshal(buf, resp); err != nil {
6229 return err
6230 }
6231
6232 return nil
6233 }, opts...)
6234 if e != nil {
6235 return nil, e
6236 }
6237 return resp, nil
6238 }
6239
6240 // UpdateSearchConfig updates a search configuration inside a corpus.
6241 //
6242 // Please follow the rules below to create a valid UpdateSearchConfigRequest.
6243 // — General Rules —
6244 //
6245 // Request.search_configuration.name must already exist.
6246 //
6247 // Request must contain at least one non-empty search_criteria_property or
6248 // facet_property.
6249 //
6250 // mapped_fields must not be empty, and must map to existing UGA keys.
6251 //
6252 // All mapped_fields must be of the same type.
6253 //
6254 // All mapped_fields must share the same granularity.
6255 //
6256 // All mapped_fields must share the same semantic SearchConfig match
6257 // options.
6258 // For property-specific rules, please reference the comments for
6259 // FacetProperty and SearchCriteriaProperty.
6260 func (c *warehouseRESTClient) UpdateSearchConfig(ctx context.Context, req *visionaipb.UpdateSearchConfigRequest, opts ...gax.CallOption) (*visionaipb.SearchConfig, error) {
6261 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
6262 body := req.GetSearchConfig()
6263 jsonReq, err := m.Marshal(body)
6264 if err != nil {
6265 return nil, err
6266 }
6267
6268 baseUrl, err := url.Parse(c.endpoint)
6269 if err != nil {
6270 return nil, err
6271 }
6272 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetSearchConfig().GetName())
6273
6274 params := url.Values{}
6275 params.Add("$alt", "json;enum-encoding=int")
6276 if req.GetUpdateMask() != nil {
6277 field, err := protojson.Marshal(req.GetUpdateMask())
6278 if err != nil {
6279 return nil, err
6280 }
6281 params.Add("updateMask", string(field[1:len(field)-1]))
6282 }
6283
6284 baseUrl.RawQuery = params.Encode()
6285
6286 // Build HTTP headers from client and context metadata.
6287 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "search_config.name", url.QueryEscape(req.GetSearchConfig().GetName()))}
6288
6289 hds = append(c.xGoogHeaders, hds...)
6290 hds = append(hds, "Content-Type", "application/json")
6291 headers := gax.BuildHeaders(ctx, hds...)
6292 opts = append((*c.CallOptions).UpdateSearchConfig[0:len((*c.CallOptions).UpdateSearchConfig):len((*c.CallOptions).UpdateSearchConfig)], opts...)
6293 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6294 resp := &visionaipb.SearchConfig{}
6295 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6296 if settings.Path != "" {
6297 baseUrl.Path = settings.Path
6298 }
6299 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
6300 if err != nil {
6301 return err
6302 }
6303 httpReq = httpReq.WithContext(ctx)
6304 httpReq.Header = headers
6305
6306 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateSearchConfig")
6307 if err != nil {
6308 return err
6309 }
6310
6311 if err := unm.Unmarshal(buf, resp); err != nil {
6312 return err
6313 }
6314
6315 return nil
6316 }, opts...)
6317 if e != nil {
6318 return nil, e
6319 }
6320 return resp, nil
6321 }
6322
6323 // GetSearchConfig gets a search configuration inside a corpus.
6324 func (c *warehouseRESTClient) GetSearchConfig(ctx context.Context, req *visionaipb.GetSearchConfigRequest, opts ...gax.CallOption) (*visionaipb.SearchConfig, error) {
6325 baseUrl, err := url.Parse(c.endpoint)
6326 if err != nil {
6327 return nil, err
6328 }
6329 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
6330
6331 params := url.Values{}
6332 params.Add("$alt", "json;enum-encoding=int")
6333
6334 baseUrl.RawQuery = params.Encode()
6335
6336 // Build HTTP headers from client and context metadata.
6337 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
6338
6339 hds = append(c.xGoogHeaders, hds...)
6340 hds = append(hds, "Content-Type", "application/json")
6341 headers := gax.BuildHeaders(ctx, hds...)
6342 opts = append((*c.CallOptions).GetSearchConfig[0:len((*c.CallOptions).GetSearchConfig):len((*c.CallOptions).GetSearchConfig)], opts...)
6343 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6344 resp := &visionaipb.SearchConfig{}
6345 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6346 if settings.Path != "" {
6347 baseUrl.Path = settings.Path
6348 }
6349 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
6350 if err != nil {
6351 return err
6352 }
6353 httpReq = httpReq.WithContext(ctx)
6354 httpReq.Header = headers
6355
6356 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetSearchConfig")
6357 if err != nil {
6358 return err
6359 }
6360
6361 if err := unm.Unmarshal(buf, resp); err != nil {
6362 return err
6363 }
6364
6365 return nil
6366 }, opts...)
6367 if e != nil {
6368 return nil, e
6369 }
6370 return resp, nil
6371 }
6372
6373 // DeleteSearchConfig deletes a search configuration inside a corpus.
6374 //
6375 // For a DeleteSearchConfigRequest to be valid,
6376 // Request.search_configuration.name must already exist.
6377 func (c *warehouseRESTClient) DeleteSearchConfig(ctx context.Context, req *visionaipb.DeleteSearchConfigRequest, opts ...gax.CallOption) error {
6378 baseUrl, err := url.Parse(c.endpoint)
6379 if err != nil {
6380 return err
6381 }
6382 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
6383
6384 params := url.Values{}
6385 params.Add("$alt", "json;enum-encoding=int")
6386
6387 baseUrl.RawQuery = params.Encode()
6388
6389 // Build HTTP headers from client and context metadata.
6390 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
6391
6392 hds = append(c.xGoogHeaders, hds...)
6393 hds = append(hds, "Content-Type", "application/json")
6394 headers := gax.BuildHeaders(ctx, hds...)
6395 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6396 if settings.Path != "" {
6397 baseUrl.Path = settings.Path
6398 }
6399 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
6400 if err != nil {
6401 return err
6402 }
6403 httpReq = httpReq.WithContext(ctx)
6404 httpReq.Header = headers
6405
6406 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSearchConfig")
6407 return err
6408 }, opts...)
6409 }
6410
6411 // ListSearchConfigs lists all search configurations inside a corpus.
6412 func (c *warehouseRESTClient) ListSearchConfigs(ctx context.Context, req *visionaipb.ListSearchConfigsRequest, opts ...gax.CallOption) *SearchConfigIterator {
6413 it := &SearchConfigIterator{}
6414 req = proto.Clone(req).(*visionaipb.ListSearchConfigsRequest)
6415 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6416 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.SearchConfig, string, error) {
6417 resp := &visionaipb.ListSearchConfigsResponse{}
6418 if pageToken != "" {
6419 req.PageToken = pageToken
6420 }
6421 if pageSize > math.MaxInt32 {
6422 req.PageSize = math.MaxInt32
6423 } else if pageSize != 0 {
6424 req.PageSize = int32(pageSize)
6425 }
6426 baseUrl, err := url.Parse(c.endpoint)
6427 if err != nil {
6428 return nil, "", err
6429 }
6430 baseUrl.Path += fmt.Sprintf("/v1/%v/searchConfigs", req.GetParent())
6431
6432 params := url.Values{}
6433 params.Add("$alt", "json;enum-encoding=int")
6434 if req.GetPageSize() != 0 {
6435 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
6436 }
6437 if req.GetPageToken() != "" {
6438 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
6439 }
6440
6441 baseUrl.RawQuery = params.Encode()
6442
6443 // Build HTTP headers from client and context metadata.
6444 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
6445 headers := gax.BuildHeaders(ctx, hds...)
6446 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6447 if settings.Path != "" {
6448 baseUrl.Path = settings.Path
6449 }
6450 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
6451 if err != nil {
6452 return err
6453 }
6454 httpReq.Header = headers
6455
6456 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListSearchConfigs")
6457 if err != nil {
6458 return err
6459 }
6460 if err := unm.Unmarshal(buf, resp); err != nil {
6461 return err
6462 }
6463
6464 return nil
6465 }, opts...)
6466 if e != nil {
6467 return nil, "", e
6468 }
6469 it.Response = resp
6470 return resp.GetSearchConfigs(), resp.GetNextPageToken(), nil
6471 }
6472
6473 fetch := func(pageSize int, pageToken string) (string, error) {
6474 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
6475 if err != nil {
6476 return "", err
6477 }
6478 it.items = append(it.items, items...)
6479 return nextPageToken, nil
6480 }
6481
6482 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
6483 it.pageInfo.MaxSize = int(req.GetPageSize())
6484 it.pageInfo.Token = req.GetPageToken()
6485
6486 return it
6487 }
6488
6489 // CreateSearchHypernym creates a SearchHypernym inside a corpus.
6490 func (c *warehouseRESTClient) CreateSearchHypernym(ctx context.Context, req *visionaipb.CreateSearchHypernymRequest, opts ...gax.CallOption) (*visionaipb.SearchHypernym, error) {
6491 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
6492 body := req.GetSearchHypernym()
6493 jsonReq, err := m.Marshal(body)
6494 if err != nil {
6495 return nil, err
6496 }
6497
6498 baseUrl, err := url.Parse(c.endpoint)
6499 if err != nil {
6500 return nil, err
6501 }
6502 baseUrl.Path += fmt.Sprintf("/v1/%v/searchHypernyms", req.GetParent())
6503
6504 params := url.Values{}
6505 params.Add("$alt", "json;enum-encoding=int")
6506 if req != nil && req.SearchHypernymId != nil {
6507 params.Add("searchHypernymId", fmt.Sprintf("%v", req.GetSearchHypernymId()))
6508 }
6509
6510 baseUrl.RawQuery = params.Encode()
6511
6512 // Build HTTP headers from client and context metadata.
6513 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
6514
6515 hds = append(c.xGoogHeaders, hds...)
6516 hds = append(hds, "Content-Type", "application/json")
6517 headers := gax.BuildHeaders(ctx, hds...)
6518 opts = append((*c.CallOptions).CreateSearchHypernym[0:len((*c.CallOptions).CreateSearchHypernym):len((*c.CallOptions).CreateSearchHypernym)], opts...)
6519 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6520 resp := &visionaipb.SearchHypernym{}
6521 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6522 if settings.Path != "" {
6523 baseUrl.Path = settings.Path
6524 }
6525 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
6526 if err != nil {
6527 return err
6528 }
6529 httpReq = httpReq.WithContext(ctx)
6530 httpReq.Header = headers
6531
6532 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateSearchHypernym")
6533 if err != nil {
6534 return err
6535 }
6536
6537 if err := unm.Unmarshal(buf, resp); err != nil {
6538 return err
6539 }
6540
6541 return nil
6542 }, opts...)
6543 if e != nil {
6544 return nil, e
6545 }
6546 return resp, nil
6547 }
6548
6549 // UpdateSearchHypernym updates a SearchHypernym inside a corpus.
6550 func (c *warehouseRESTClient) UpdateSearchHypernym(ctx context.Context, req *visionaipb.UpdateSearchHypernymRequest, opts ...gax.CallOption) (*visionaipb.SearchHypernym, error) {
6551 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
6552 body := req.GetSearchHypernym()
6553 jsonReq, err := m.Marshal(body)
6554 if err != nil {
6555 return nil, err
6556 }
6557
6558 baseUrl, err := url.Parse(c.endpoint)
6559 if err != nil {
6560 return nil, err
6561 }
6562 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetSearchHypernym().GetName())
6563
6564 params := url.Values{}
6565 params.Add("$alt", "json;enum-encoding=int")
6566 if req.GetUpdateMask() != nil {
6567 field, err := protojson.Marshal(req.GetUpdateMask())
6568 if err != nil {
6569 return nil, err
6570 }
6571 params.Add("updateMask", string(field[1:len(field)-1]))
6572 }
6573
6574 baseUrl.RawQuery = params.Encode()
6575
6576 // Build HTTP headers from client and context metadata.
6577 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "search_hypernym.name", url.QueryEscape(req.GetSearchHypernym().GetName()))}
6578
6579 hds = append(c.xGoogHeaders, hds...)
6580 hds = append(hds, "Content-Type", "application/json")
6581 headers := gax.BuildHeaders(ctx, hds...)
6582 opts = append((*c.CallOptions).UpdateSearchHypernym[0:len((*c.CallOptions).UpdateSearchHypernym):len((*c.CallOptions).UpdateSearchHypernym)], opts...)
6583 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6584 resp := &visionaipb.SearchHypernym{}
6585 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6586 if settings.Path != "" {
6587 baseUrl.Path = settings.Path
6588 }
6589 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
6590 if err != nil {
6591 return err
6592 }
6593 httpReq = httpReq.WithContext(ctx)
6594 httpReq.Header = headers
6595
6596 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateSearchHypernym")
6597 if err != nil {
6598 return err
6599 }
6600
6601 if err := unm.Unmarshal(buf, resp); err != nil {
6602 return err
6603 }
6604
6605 return nil
6606 }, opts...)
6607 if e != nil {
6608 return nil, e
6609 }
6610 return resp, nil
6611 }
6612
6613 // GetSearchHypernym gets a SearchHypernym inside a corpus.
6614 func (c *warehouseRESTClient) GetSearchHypernym(ctx context.Context, req *visionaipb.GetSearchHypernymRequest, opts ...gax.CallOption) (*visionaipb.SearchHypernym, error) {
6615 baseUrl, err := url.Parse(c.endpoint)
6616 if err != nil {
6617 return nil, err
6618 }
6619 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
6620
6621 params := url.Values{}
6622 params.Add("$alt", "json;enum-encoding=int")
6623
6624 baseUrl.RawQuery = params.Encode()
6625
6626 // Build HTTP headers from client and context metadata.
6627 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
6628
6629 hds = append(c.xGoogHeaders, hds...)
6630 hds = append(hds, "Content-Type", "application/json")
6631 headers := gax.BuildHeaders(ctx, hds...)
6632 opts = append((*c.CallOptions).GetSearchHypernym[0:len((*c.CallOptions).GetSearchHypernym):len((*c.CallOptions).GetSearchHypernym)], opts...)
6633 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6634 resp := &visionaipb.SearchHypernym{}
6635 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6636 if settings.Path != "" {
6637 baseUrl.Path = settings.Path
6638 }
6639 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
6640 if err != nil {
6641 return err
6642 }
6643 httpReq = httpReq.WithContext(ctx)
6644 httpReq.Header = headers
6645
6646 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetSearchHypernym")
6647 if err != nil {
6648 return err
6649 }
6650
6651 if err := unm.Unmarshal(buf, resp); err != nil {
6652 return err
6653 }
6654
6655 return nil
6656 }, opts...)
6657 if e != nil {
6658 return nil, e
6659 }
6660 return resp, nil
6661 }
6662
6663 // DeleteSearchHypernym deletes a SearchHypernym inside a corpus.
6664 func (c *warehouseRESTClient) DeleteSearchHypernym(ctx context.Context, req *visionaipb.DeleteSearchHypernymRequest, opts ...gax.CallOption) error {
6665 baseUrl, err := url.Parse(c.endpoint)
6666 if err != nil {
6667 return err
6668 }
6669 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
6670
6671 params := url.Values{}
6672 params.Add("$alt", "json;enum-encoding=int")
6673
6674 baseUrl.RawQuery = params.Encode()
6675
6676 // Build HTTP headers from client and context metadata.
6677 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
6678
6679 hds = append(c.xGoogHeaders, hds...)
6680 hds = append(hds, "Content-Type", "application/json")
6681 headers := gax.BuildHeaders(ctx, hds...)
6682 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6683 if settings.Path != "" {
6684 baseUrl.Path = settings.Path
6685 }
6686 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
6687 if err != nil {
6688 return err
6689 }
6690 httpReq = httpReq.WithContext(ctx)
6691 httpReq.Header = headers
6692
6693 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSearchHypernym")
6694 return err
6695 }, opts...)
6696 }
6697
6698 // ListSearchHypernyms lists SearchHypernyms inside a corpus.
6699 func (c *warehouseRESTClient) ListSearchHypernyms(ctx context.Context, req *visionaipb.ListSearchHypernymsRequest, opts ...gax.CallOption) *SearchHypernymIterator {
6700 it := &SearchHypernymIterator{}
6701 req = proto.Clone(req).(*visionaipb.ListSearchHypernymsRequest)
6702 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6703 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.SearchHypernym, string, error) {
6704 resp := &visionaipb.ListSearchHypernymsResponse{}
6705 if pageToken != "" {
6706 req.PageToken = pageToken
6707 }
6708 if pageSize > math.MaxInt32 {
6709 req.PageSize = math.MaxInt32
6710 } else if pageSize != 0 {
6711 req.PageSize = int32(pageSize)
6712 }
6713 baseUrl, err := url.Parse(c.endpoint)
6714 if err != nil {
6715 return nil, "", err
6716 }
6717 baseUrl.Path += fmt.Sprintf("/v1/%v/searchHypernyms", req.GetParent())
6718
6719 params := url.Values{}
6720 params.Add("$alt", "json;enum-encoding=int")
6721 if req.GetPageSize() != 0 {
6722 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
6723 }
6724 if req.GetPageToken() != "" {
6725 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
6726 }
6727
6728 baseUrl.RawQuery = params.Encode()
6729
6730 // Build HTTP headers from client and context metadata.
6731 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
6732 headers := gax.BuildHeaders(ctx, hds...)
6733 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6734 if settings.Path != "" {
6735 baseUrl.Path = settings.Path
6736 }
6737 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
6738 if err != nil {
6739 return err
6740 }
6741 httpReq.Header = headers
6742
6743 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListSearchHypernyms")
6744 if err != nil {
6745 return err
6746 }
6747 if err := unm.Unmarshal(buf, resp); err != nil {
6748 return err
6749 }
6750
6751 return nil
6752 }, opts...)
6753 if e != nil {
6754 return nil, "", e
6755 }
6756 it.Response = resp
6757 return resp.GetSearchHypernyms(), resp.GetNextPageToken(), nil
6758 }
6759
6760 fetch := func(pageSize int, pageToken string) (string, error) {
6761 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
6762 if err != nil {
6763 return "", err
6764 }
6765 it.items = append(it.items, items...)
6766 return nextPageToken, nil
6767 }
6768
6769 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
6770 it.pageInfo.MaxSize = int(req.GetPageSize())
6771 it.pageInfo.Token = req.GetPageToken()
6772
6773 return it
6774 }
6775
6776 // SearchAssets search media asset.
6777 func (c *warehouseRESTClient) SearchAssets(ctx context.Context, req *visionaipb.SearchAssetsRequest, opts ...gax.CallOption) *SearchResultItemIterator {
6778 it := &SearchResultItemIterator{}
6779 req = proto.Clone(req).(*visionaipb.SearchAssetsRequest)
6780 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
6781 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6782 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.SearchResultItem, string, error) {
6783 resp := &visionaipb.SearchAssetsResponse{}
6784 if pageToken != "" {
6785 req.PageToken = pageToken
6786 }
6787 if pageSize > math.MaxInt32 {
6788 req.PageSize = math.MaxInt32
6789 } else if pageSize != 0 {
6790 req.PageSize = int32(pageSize)
6791 }
6792 jsonReq, err := m.Marshal(req)
6793 if err != nil {
6794 return nil, "", err
6795 }
6796
6797 baseUrl, err := url.Parse(c.endpoint)
6798 if err != nil {
6799 return nil, "", err
6800 }
6801 baseUrl.Path += fmt.Sprintf("/v1/%v:searchAssets", req.GetCorpus())
6802
6803 params := url.Values{}
6804 params.Add("$alt", "json;enum-encoding=int")
6805
6806 baseUrl.RawQuery = params.Encode()
6807
6808 // Build HTTP headers from client and context metadata.
6809 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
6810 headers := gax.BuildHeaders(ctx, hds...)
6811 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6812 if settings.Path != "" {
6813 baseUrl.Path = settings.Path
6814 }
6815 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
6816 if err != nil {
6817 return err
6818 }
6819 httpReq.Header = headers
6820
6821 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SearchAssets")
6822 if err != nil {
6823 return err
6824 }
6825 if err := unm.Unmarshal(buf, resp); err != nil {
6826 return err
6827 }
6828
6829 return nil
6830 }, opts...)
6831 if e != nil {
6832 return nil, "", e
6833 }
6834 it.Response = resp
6835 return resp.GetSearchResultItems(), resp.GetNextPageToken(), nil
6836 }
6837
6838 fetch := func(pageSize int, pageToken string) (string, error) {
6839 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
6840 if err != nil {
6841 return "", err
6842 }
6843 it.items = append(it.items, items...)
6844 return nextPageToken, nil
6845 }
6846
6847 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
6848 it.pageInfo.MaxSize = int(req.GetPageSize())
6849 it.pageInfo.Token = req.GetPageToken()
6850
6851 return it
6852 }
6853
6854 // SearchIndexEndpoint search a deployed index endpoint (IMAGE corpus type only).
6855 func (c *warehouseRESTClient) SearchIndexEndpoint(ctx context.Context, req *visionaipb.SearchIndexEndpointRequest, opts ...gax.CallOption) *SearchResultItemIterator {
6856 it := &SearchResultItemIterator{}
6857 req = proto.Clone(req).(*visionaipb.SearchIndexEndpointRequest)
6858 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
6859 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6860 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.SearchResultItem, string, error) {
6861 resp := &visionaipb.SearchIndexEndpointResponse{}
6862 if pageToken != "" {
6863 req.PageToken = pageToken
6864 }
6865 if pageSize > math.MaxInt32 {
6866 req.PageSize = math.MaxInt32
6867 } else if pageSize != 0 {
6868 req.PageSize = int32(pageSize)
6869 }
6870 jsonReq, err := m.Marshal(req)
6871 if err != nil {
6872 return nil, "", err
6873 }
6874
6875 baseUrl, err := url.Parse(c.endpoint)
6876 if err != nil {
6877 return nil, "", err
6878 }
6879 baseUrl.Path += fmt.Sprintf("/v1/%v:searchIndexEndpoint", req.GetIndexEndpoint())
6880
6881 params := url.Values{}
6882 params.Add("$alt", "json;enum-encoding=int")
6883
6884 baseUrl.RawQuery = params.Encode()
6885
6886 // Build HTTP headers from client and context metadata.
6887 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
6888 headers := gax.BuildHeaders(ctx, hds...)
6889 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6890 if settings.Path != "" {
6891 baseUrl.Path = settings.Path
6892 }
6893 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
6894 if err != nil {
6895 return err
6896 }
6897 httpReq.Header = headers
6898
6899 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SearchIndexEndpoint")
6900 if err != nil {
6901 return err
6902 }
6903 if err := unm.Unmarshal(buf, resp); err != nil {
6904 return err
6905 }
6906
6907 return nil
6908 }, opts...)
6909 if e != nil {
6910 return nil, "", e
6911 }
6912 it.Response = resp
6913 return resp.GetSearchResultItems(), resp.GetNextPageToken(), nil
6914 }
6915
6916 fetch := func(pageSize int, pageToken string) (string, error) {
6917 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
6918 if err != nil {
6919 return "", err
6920 }
6921 it.items = append(it.items, items...)
6922 return nextPageToken, nil
6923 }
6924
6925 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
6926 it.pageInfo.MaxSize = int(req.GetPageSize())
6927 it.pageInfo.Token = req.GetPageToken()
6928
6929 return it
6930 }
6931
6932 // CreateIndexEndpoint creates an IndexEndpoint.
6933 func (c *warehouseRESTClient) CreateIndexEndpoint(ctx context.Context, req *visionaipb.CreateIndexEndpointRequest, opts ...gax.CallOption) (*CreateIndexEndpointOperation, error) {
6934 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
6935 body := req.GetIndexEndpoint()
6936 jsonReq, err := m.Marshal(body)
6937 if err != nil {
6938 return nil, err
6939 }
6940
6941 baseUrl, err := url.Parse(c.endpoint)
6942 if err != nil {
6943 return nil, err
6944 }
6945 baseUrl.Path += fmt.Sprintf("/v1/%v/indexEndpoints", req.GetParent())
6946
6947 params := url.Values{}
6948 params.Add("$alt", "json;enum-encoding=int")
6949 if req.GetIndexEndpointId() != "" {
6950 params.Add("indexEndpointId", fmt.Sprintf("%v", req.GetIndexEndpointId()))
6951 }
6952
6953 baseUrl.RawQuery = params.Encode()
6954
6955 // Build HTTP headers from client and context metadata.
6956 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
6957
6958 hds = append(c.xGoogHeaders, hds...)
6959 hds = append(hds, "Content-Type", "application/json")
6960 headers := gax.BuildHeaders(ctx, hds...)
6961 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
6962 resp := &longrunningpb.Operation{}
6963 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
6964 if settings.Path != "" {
6965 baseUrl.Path = settings.Path
6966 }
6967 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
6968 if err != nil {
6969 return err
6970 }
6971 httpReq = httpReq.WithContext(ctx)
6972 httpReq.Header = headers
6973
6974 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateIndexEndpoint")
6975 if err != nil {
6976 return err
6977 }
6978 if err := unm.Unmarshal(buf, resp); err != nil {
6979 return err
6980 }
6981
6982 return nil
6983 }, opts...)
6984 if e != nil {
6985 return nil, e
6986 }
6987
6988 override := fmt.Sprintf("/v1/%s", resp.GetName())
6989 return &CreateIndexEndpointOperation{
6990 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
6991 pollPath: override,
6992 }, nil
6993 }
6994
6995 // GetIndexEndpoint gets an IndexEndpoint.
6996 func (c *warehouseRESTClient) GetIndexEndpoint(ctx context.Context, req *visionaipb.GetIndexEndpointRequest, opts ...gax.CallOption) (*visionaipb.IndexEndpoint, error) {
6997 baseUrl, err := url.Parse(c.endpoint)
6998 if err != nil {
6999 return nil, err
7000 }
7001 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
7002
7003 params := url.Values{}
7004 params.Add("$alt", "json;enum-encoding=int")
7005
7006 baseUrl.RawQuery = params.Encode()
7007
7008 // Build HTTP headers from client and context metadata.
7009 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
7010
7011 hds = append(c.xGoogHeaders, hds...)
7012 hds = append(hds, "Content-Type", "application/json")
7013 headers := gax.BuildHeaders(ctx, hds...)
7014 opts = append((*c.CallOptions).GetIndexEndpoint[0:len((*c.CallOptions).GetIndexEndpoint):len((*c.CallOptions).GetIndexEndpoint)], opts...)
7015 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7016 resp := &visionaipb.IndexEndpoint{}
7017 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7018 if settings.Path != "" {
7019 baseUrl.Path = settings.Path
7020 }
7021 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
7022 if err != nil {
7023 return err
7024 }
7025 httpReq = httpReq.WithContext(ctx)
7026 httpReq.Header = headers
7027
7028 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetIndexEndpoint")
7029 if err != nil {
7030 return err
7031 }
7032
7033 if err := unm.Unmarshal(buf, resp); err != nil {
7034 return err
7035 }
7036
7037 return nil
7038 }, opts...)
7039 if e != nil {
7040 return nil, e
7041 }
7042 return resp, nil
7043 }
7044
7045 // ListIndexEndpoints lists all IndexEndpoints in a project.
7046 func (c *warehouseRESTClient) ListIndexEndpoints(ctx context.Context, req *visionaipb.ListIndexEndpointsRequest, opts ...gax.CallOption) *IndexEndpointIterator {
7047 it := &IndexEndpointIterator{}
7048 req = proto.Clone(req).(*visionaipb.ListIndexEndpointsRequest)
7049 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7050 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.IndexEndpoint, string, error) {
7051 resp := &visionaipb.ListIndexEndpointsResponse{}
7052 if pageToken != "" {
7053 req.PageToken = pageToken
7054 }
7055 if pageSize > math.MaxInt32 {
7056 req.PageSize = math.MaxInt32
7057 } else if pageSize != 0 {
7058 req.PageSize = int32(pageSize)
7059 }
7060 baseUrl, err := url.Parse(c.endpoint)
7061 if err != nil {
7062 return nil, "", err
7063 }
7064 baseUrl.Path += fmt.Sprintf("/v1/%v/indexEndpoints", req.GetParent())
7065
7066 params := url.Values{}
7067 params.Add("$alt", "json;enum-encoding=int")
7068 if req.GetFilter() != "" {
7069 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
7070 }
7071 if req.GetPageSize() != 0 {
7072 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
7073 }
7074 if req.GetPageToken() != "" {
7075 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
7076 }
7077
7078 baseUrl.RawQuery = params.Encode()
7079
7080 // Build HTTP headers from client and context metadata.
7081 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
7082 headers := gax.BuildHeaders(ctx, hds...)
7083 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7084 if settings.Path != "" {
7085 baseUrl.Path = settings.Path
7086 }
7087 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
7088 if err != nil {
7089 return err
7090 }
7091 httpReq.Header = headers
7092
7093 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListIndexEndpoints")
7094 if err != nil {
7095 return err
7096 }
7097 if err := unm.Unmarshal(buf, resp); err != nil {
7098 return err
7099 }
7100
7101 return nil
7102 }, opts...)
7103 if e != nil {
7104 return nil, "", e
7105 }
7106 it.Response = resp
7107 return resp.GetIndexEndpoints(), resp.GetNextPageToken(), nil
7108 }
7109
7110 fetch := func(pageSize int, pageToken string) (string, error) {
7111 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
7112 if err != nil {
7113 return "", err
7114 }
7115 it.items = append(it.items, items...)
7116 return nextPageToken, nil
7117 }
7118
7119 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
7120 it.pageInfo.MaxSize = int(req.GetPageSize())
7121 it.pageInfo.Token = req.GetPageToken()
7122
7123 return it
7124 }
7125
7126 // UpdateIndexEndpoint updates an IndexEndpoint.
7127 func (c *warehouseRESTClient) UpdateIndexEndpoint(ctx context.Context, req *visionaipb.UpdateIndexEndpointRequest, opts ...gax.CallOption) (*UpdateIndexEndpointOperation, error) {
7128 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
7129 body := req.GetIndexEndpoint()
7130 jsonReq, err := m.Marshal(body)
7131 if err != nil {
7132 return nil, err
7133 }
7134
7135 baseUrl, err := url.Parse(c.endpoint)
7136 if err != nil {
7137 return nil, err
7138 }
7139 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetIndexEndpoint().GetName())
7140
7141 params := url.Values{}
7142 params.Add("$alt", "json;enum-encoding=int")
7143 if req.GetUpdateMask() != nil {
7144 field, err := protojson.Marshal(req.GetUpdateMask())
7145 if err != nil {
7146 return nil, err
7147 }
7148 params.Add("updateMask", string(field[1:len(field)-1]))
7149 }
7150
7151 baseUrl.RawQuery = params.Encode()
7152
7153 // Build HTTP headers from client and context metadata.
7154 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint.name", url.QueryEscape(req.GetIndexEndpoint().GetName()))}
7155
7156 hds = append(c.xGoogHeaders, hds...)
7157 hds = append(hds, "Content-Type", "application/json")
7158 headers := gax.BuildHeaders(ctx, hds...)
7159 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7160 resp := &longrunningpb.Operation{}
7161 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7162 if settings.Path != "" {
7163 baseUrl.Path = settings.Path
7164 }
7165 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
7166 if err != nil {
7167 return err
7168 }
7169 httpReq = httpReq.WithContext(ctx)
7170 httpReq.Header = headers
7171
7172 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateIndexEndpoint")
7173 if err != nil {
7174 return err
7175 }
7176 if err := unm.Unmarshal(buf, resp); err != nil {
7177 return err
7178 }
7179
7180 return nil
7181 }, opts...)
7182 if e != nil {
7183 return nil, e
7184 }
7185
7186 override := fmt.Sprintf("/v1/%s", resp.GetName())
7187 return &UpdateIndexEndpointOperation{
7188 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
7189 pollPath: override,
7190 }, nil
7191 }
7192
7193 // DeleteIndexEndpoint deletes an IndexEndpoint.
7194 func (c *warehouseRESTClient) DeleteIndexEndpoint(ctx context.Context, req *visionaipb.DeleteIndexEndpointRequest, opts ...gax.CallOption) (*DeleteIndexEndpointOperation, error) {
7195 baseUrl, err := url.Parse(c.endpoint)
7196 if err != nil {
7197 return nil, err
7198 }
7199 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
7200
7201 params := url.Values{}
7202 params.Add("$alt", "json;enum-encoding=int")
7203
7204 baseUrl.RawQuery = params.Encode()
7205
7206 // Build HTTP headers from client and context metadata.
7207 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
7208
7209 hds = append(c.xGoogHeaders, hds...)
7210 hds = append(hds, "Content-Type", "application/json")
7211 headers := gax.BuildHeaders(ctx, hds...)
7212 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7213 resp := &longrunningpb.Operation{}
7214 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7215 if settings.Path != "" {
7216 baseUrl.Path = settings.Path
7217 }
7218 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
7219 if err != nil {
7220 return err
7221 }
7222 httpReq = httpReq.WithContext(ctx)
7223 httpReq.Header = headers
7224
7225 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteIndexEndpoint")
7226 if err != nil {
7227 return err
7228 }
7229 if err := unm.Unmarshal(buf, resp); err != nil {
7230 return err
7231 }
7232
7233 return nil
7234 }, opts...)
7235 if e != nil {
7236 return nil, e
7237 }
7238
7239 override := fmt.Sprintf("/v1/%s", resp.GetName())
7240 return &DeleteIndexEndpointOperation{
7241 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
7242 pollPath: override,
7243 }, nil
7244 }
7245
7246 // DeployIndex deploys an Index to IndexEndpoint.
7247 func (c *warehouseRESTClient) DeployIndex(ctx context.Context, req *visionaipb.DeployIndexRequest, opts ...gax.CallOption) (*DeployIndexOperation, error) {
7248 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
7249 jsonReq, err := m.Marshal(req)
7250 if err != nil {
7251 return nil, err
7252 }
7253
7254 baseUrl, err := url.Parse(c.endpoint)
7255 if err != nil {
7256 return nil, err
7257 }
7258 baseUrl.Path += fmt.Sprintf("/v1/%v:deployIndex", req.GetIndexEndpoint())
7259
7260 params := url.Values{}
7261 params.Add("$alt", "json;enum-encoding=int")
7262
7263 baseUrl.RawQuery = params.Encode()
7264
7265 // Build HTTP headers from client and context metadata.
7266 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))}
7267
7268 hds = append(c.xGoogHeaders, hds...)
7269 hds = append(hds, "Content-Type", "application/json")
7270 headers := gax.BuildHeaders(ctx, hds...)
7271 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7272 resp := &longrunningpb.Operation{}
7273 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7274 if settings.Path != "" {
7275 baseUrl.Path = settings.Path
7276 }
7277 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
7278 if err != nil {
7279 return err
7280 }
7281 httpReq = httpReq.WithContext(ctx)
7282 httpReq.Header = headers
7283
7284 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "DeployIndex")
7285 if err != nil {
7286 return err
7287 }
7288 if err := unm.Unmarshal(buf, resp); err != nil {
7289 return err
7290 }
7291
7292 return nil
7293 }, opts...)
7294 if e != nil {
7295 return nil, e
7296 }
7297
7298 override := fmt.Sprintf("/v1/%s", resp.GetName())
7299 return &DeployIndexOperation{
7300 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
7301 pollPath: override,
7302 }, nil
7303 }
7304
7305 // UndeployIndex undeploys an Index from IndexEndpoint.
7306 func (c *warehouseRESTClient) UndeployIndex(ctx context.Context, req *visionaipb.UndeployIndexRequest, opts ...gax.CallOption) (*UndeployIndexOperation, error) {
7307 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
7308 jsonReq, err := m.Marshal(req)
7309 if err != nil {
7310 return nil, err
7311 }
7312
7313 baseUrl, err := url.Parse(c.endpoint)
7314 if err != nil {
7315 return nil, err
7316 }
7317 baseUrl.Path += fmt.Sprintf("/v1/%v:undeployIndex", req.GetIndexEndpoint())
7318
7319 params := url.Values{}
7320 params.Add("$alt", "json;enum-encoding=int")
7321
7322 baseUrl.RawQuery = params.Encode()
7323
7324 // Build HTTP headers from client and context metadata.
7325 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "index_endpoint", url.QueryEscape(req.GetIndexEndpoint()))}
7326
7327 hds = append(c.xGoogHeaders, hds...)
7328 hds = append(hds, "Content-Type", "application/json")
7329 headers := gax.BuildHeaders(ctx, hds...)
7330 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7331 resp := &longrunningpb.Operation{}
7332 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7333 if settings.Path != "" {
7334 baseUrl.Path = settings.Path
7335 }
7336 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
7337 if err != nil {
7338 return err
7339 }
7340 httpReq = httpReq.WithContext(ctx)
7341 httpReq.Header = headers
7342
7343 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UndeployIndex")
7344 if err != nil {
7345 return err
7346 }
7347 if err := unm.Unmarshal(buf, resp); err != nil {
7348 return err
7349 }
7350
7351 return nil
7352 }, opts...)
7353 if e != nil {
7354 return nil, e
7355 }
7356
7357 override := fmt.Sprintf("/v1/%s", resp.GetName())
7358 return &UndeployIndexOperation{
7359 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
7360 pollPath: override,
7361 }, nil
7362 }
7363
7364 // CreateCollection creates a collection.
7365 func (c *warehouseRESTClient) CreateCollection(ctx context.Context, req *visionaipb.CreateCollectionRequest, opts ...gax.CallOption) (*CreateCollectionOperation, error) {
7366 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
7367 body := req.GetCollection()
7368 jsonReq, err := m.Marshal(body)
7369 if err != nil {
7370 return nil, err
7371 }
7372
7373 baseUrl, err := url.Parse(c.endpoint)
7374 if err != nil {
7375 return nil, err
7376 }
7377 baseUrl.Path += fmt.Sprintf("/v1/%v/collections", req.GetParent())
7378
7379 params := url.Values{}
7380 params.Add("$alt", "json;enum-encoding=int")
7381 if req != nil && req.CollectionId != nil {
7382 params.Add("collectionId", fmt.Sprintf("%v", req.GetCollectionId()))
7383 }
7384
7385 baseUrl.RawQuery = params.Encode()
7386
7387 // Build HTTP headers from client and context metadata.
7388 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
7389
7390 hds = append(c.xGoogHeaders, hds...)
7391 hds = append(hds, "Content-Type", "application/json")
7392 headers := gax.BuildHeaders(ctx, hds...)
7393 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7394 resp := &longrunningpb.Operation{}
7395 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7396 if settings.Path != "" {
7397 baseUrl.Path = settings.Path
7398 }
7399 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
7400 if err != nil {
7401 return err
7402 }
7403 httpReq = httpReq.WithContext(ctx)
7404 httpReq.Header = headers
7405
7406 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateCollection")
7407 if err != nil {
7408 return err
7409 }
7410 if err := unm.Unmarshal(buf, resp); err != nil {
7411 return err
7412 }
7413
7414 return nil
7415 }, opts...)
7416 if e != nil {
7417 return nil, e
7418 }
7419
7420 override := fmt.Sprintf("/v1/%s", resp.GetName())
7421 return &CreateCollectionOperation{
7422 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
7423 pollPath: override,
7424 }, nil
7425 }
7426
7427 // DeleteCollection deletes a collection.
7428 func (c *warehouseRESTClient) DeleteCollection(ctx context.Context, req *visionaipb.DeleteCollectionRequest, opts ...gax.CallOption) (*DeleteCollectionOperation, error) {
7429 baseUrl, err := url.Parse(c.endpoint)
7430 if err != nil {
7431 return nil, err
7432 }
7433 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
7434
7435 params := url.Values{}
7436 params.Add("$alt", "json;enum-encoding=int")
7437
7438 baseUrl.RawQuery = params.Encode()
7439
7440 // Build HTTP headers from client and context metadata.
7441 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
7442
7443 hds = append(c.xGoogHeaders, hds...)
7444 hds = append(hds, "Content-Type", "application/json")
7445 headers := gax.BuildHeaders(ctx, hds...)
7446 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7447 resp := &longrunningpb.Operation{}
7448 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7449 if settings.Path != "" {
7450 baseUrl.Path = settings.Path
7451 }
7452 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
7453 if err != nil {
7454 return err
7455 }
7456 httpReq = httpReq.WithContext(ctx)
7457 httpReq.Header = headers
7458
7459 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteCollection")
7460 if err != nil {
7461 return err
7462 }
7463 if err := unm.Unmarshal(buf, resp); err != nil {
7464 return err
7465 }
7466
7467 return nil
7468 }, opts...)
7469 if e != nil {
7470 return nil, e
7471 }
7472
7473 override := fmt.Sprintf("/v1/%s", resp.GetName())
7474 return &DeleteCollectionOperation{
7475 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
7476 pollPath: override,
7477 }, nil
7478 }
7479
7480 // GetCollection gets a collection.
7481 func (c *warehouseRESTClient) GetCollection(ctx context.Context, req *visionaipb.GetCollectionRequest, opts ...gax.CallOption) (*visionaipb.Collection, error) {
7482 baseUrl, err := url.Parse(c.endpoint)
7483 if err != nil {
7484 return nil, err
7485 }
7486 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
7487
7488 params := url.Values{}
7489 params.Add("$alt", "json;enum-encoding=int")
7490
7491 baseUrl.RawQuery = params.Encode()
7492
7493 // Build HTTP headers from client and context metadata.
7494 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
7495
7496 hds = append(c.xGoogHeaders, hds...)
7497 hds = append(hds, "Content-Type", "application/json")
7498 headers := gax.BuildHeaders(ctx, hds...)
7499 opts = append((*c.CallOptions).GetCollection[0:len((*c.CallOptions).GetCollection):len((*c.CallOptions).GetCollection)], opts...)
7500 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7501 resp := &visionaipb.Collection{}
7502 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7503 if settings.Path != "" {
7504 baseUrl.Path = settings.Path
7505 }
7506 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
7507 if err != nil {
7508 return err
7509 }
7510 httpReq = httpReq.WithContext(ctx)
7511 httpReq.Header = headers
7512
7513 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetCollection")
7514 if err != nil {
7515 return err
7516 }
7517
7518 if err := unm.Unmarshal(buf, resp); err != nil {
7519 return err
7520 }
7521
7522 return nil
7523 }, opts...)
7524 if e != nil {
7525 return nil, e
7526 }
7527 return resp, nil
7528 }
7529
7530 // UpdateCollection updates a collection.
7531 func (c *warehouseRESTClient) UpdateCollection(ctx context.Context, req *visionaipb.UpdateCollectionRequest, opts ...gax.CallOption) (*visionaipb.Collection, error) {
7532 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
7533 body := req.GetCollection()
7534 jsonReq, err := m.Marshal(body)
7535 if err != nil {
7536 return nil, err
7537 }
7538
7539 baseUrl, err := url.Parse(c.endpoint)
7540 if err != nil {
7541 return nil, err
7542 }
7543 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetCollection().GetName())
7544
7545 params := url.Values{}
7546 params.Add("$alt", "json;enum-encoding=int")
7547 if req.GetUpdateMask() != nil {
7548 field, err := protojson.Marshal(req.GetUpdateMask())
7549 if err != nil {
7550 return nil, err
7551 }
7552 params.Add("updateMask", string(field[1:len(field)-1]))
7553 }
7554
7555 baseUrl.RawQuery = params.Encode()
7556
7557 // Build HTTP headers from client and context metadata.
7558 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "collection.name", url.QueryEscape(req.GetCollection().GetName()))}
7559
7560 hds = append(c.xGoogHeaders, hds...)
7561 hds = append(hds, "Content-Type", "application/json")
7562 headers := gax.BuildHeaders(ctx, hds...)
7563 opts = append((*c.CallOptions).UpdateCollection[0:len((*c.CallOptions).UpdateCollection):len((*c.CallOptions).UpdateCollection)], opts...)
7564 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7565 resp := &visionaipb.Collection{}
7566 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7567 if settings.Path != "" {
7568 baseUrl.Path = settings.Path
7569 }
7570 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
7571 if err != nil {
7572 return err
7573 }
7574 httpReq = httpReq.WithContext(ctx)
7575 httpReq.Header = headers
7576
7577 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateCollection")
7578 if err != nil {
7579 return err
7580 }
7581
7582 if err := unm.Unmarshal(buf, resp); err != nil {
7583 return err
7584 }
7585
7586 return nil
7587 }, opts...)
7588 if e != nil {
7589 return nil, e
7590 }
7591 return resp, nil
7592 }
7593
7594 // ListCollections lists collections inside a corpus.
7595 func (c *warehouseRESTClient) ListCollections(ctx context.Context, req *visionaipb.ListCollectionsRequest, opts ...gax.CallOption) *CollectionIterator {
7596 it := &CollectionIterator{}
7597 req = proto.Clone(req).(*visionaipb.ListCollectionsRequest)
7598 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7599 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.Collection, string, error) {
7600 resp := &visionaipb.ListCollectionsResponse{}
7601 if pageToken != "" {
7602 req.PageToken = pageToken
7603 }
7604 if pageSize > math.MaxInt32 {
7605 req.PageSize = math.MaxInt32
7606 } else if pageSize != 0 {
7607 req.PageSize = int32(pageSize)
7608 }
7609 baseUrl, err := url.Parse(c.endpoint)
7610 if err != nil {
7611 return nil, "", err
7612 }
7613 baseUrl.Path += fmt.Sprintf("/v1/%v/collections", req.GetParent())
7614
7615 params := url.Values{}
7616 params.Add("$alt", "json;enum-encoding=int")
7617 if req.GetPageSize() != 0 {
7618 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
7619 }
7620 if req.GetPageToken() != "" {
7621 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
7622 }
7623
7624 baseUrl.RawQuery = params.Encode()
7625
7626 // Build HTTP headers from client and context metadata.
7627 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
7628 headers := gax.BuildHeaders(ctx, hds...)
7629 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7630 if settings.Path != "" {
7631 baseUrl.Path = settings.Path
7632 }
7633 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
7634 if err != nil {
7635 return err
7636 }
7637 httpReq.Header = headers
7638
7639 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListCollections")
7640 if err != nil {
7641 return err
7642 }
7643 if err := unm.Unmarshal(buf, resp); err != nil {
7644 return err
7645 }
7646
7647 return nil
7648 }, opts...)
7649 if e != nil {
7650 return nil, "", e
7651 }
7652 it.Response = resp
7653 return resp.GetCollections(), resp.GetNextPageToken(), nil
7654 }
7655
7656 fetch := func(pageSize int, pageToken string) (string, error) {
7657 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
7658 if err != nil {
7659 return "", err
7660 }
7661 it.items = append(it.items, items...)
7662 return nextPageToken, nil
7663 }
7664
7665 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
7666 it.pageInfo.MaxSize = int(req.GetPageSize())
7667 it.pageInfo.Token = req.GetPageToken()
7668
7669 return it
7670 }
7671
7672 // AddCollectionItem adds an item into a Collection.
7673 func (c *warehouseRESTClient) AddCollectionItem(ctx context.Context, req *visionaipb.AddCollectionItemRequest, opts ...gax.CallOption) (*visionaipb.AddCollectionItemResponse, error) {
7674 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
7675 jsonReq, err := m.Marshal(req)
7676 if err != nil {
7677 return nil, err
7678 }
7679
7680 baseUrl, err := url.Parse(c.endpoint)
7681 if err != nil {
7682 return nil, err
7683 }
7684 baseUrl.Path += fmt.Sprintf("/v1/%v:addCollectionItem", req.GetItem().GetCollection())
7685
7686 params := url.Values{}
7687 params.Add("$alt", "json;enum-encoding=int")
7688
7689 baseUrl.RawQuery = params.Encode()
7690
7691 // Build HTTP headers from client and context metadata.
7692 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "item.collection", url.QueryEscape(req.GetItem().GetCollection()))}
7693
7694 hds = append(c.xGoogHeaders, hds...)
7695 hds = append(hds, "Content-Type", "application/json")
7696 headers := gax.BuildHeaders(ctx, hds...)
7697 opts = append((*c.CallOptions).AddCollectionItem[0:len((*c.CallOptions).AddCollectionItem):len((*c.CallOptions).AddCollectionItem)], opts...)
7698 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7699 resp := &visionaipb.AddCollectionItemResponse{}
7700 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7701 if settings.Path != "" {
7702 baseUrl.Path = settings.Path
7703 }
7704 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
7705 if err != nil {
7706 return err
7707 }
7708 httpReq = httpReq.WithContext(ctx)
7709 httpReq.Header = headers
7710
7711 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AddCollectionItem")
7712 if err != nil {
7713 return err
7714 }
7715
7716 if err := unm.Unmarshal(buf, resp); err != nil {
7717 return err
7718 }
7719
7720 return nil
7721 }, opts...)
7722 if e != nil {
7723 return nil, e
7724 }
7725 return resp, nil
7726 }
7727
7728 // RemoveCollectionItem removes an item from a collection.
7729 func (c *warehouseRESTClient) RemoveCollectionItem(ctx context.Context, req *visionaipb.RemoveCollectionItemRequest, opts ...gax.CallOption) (*visionaipb.RemoveCollectionItemResponse, error) {
7730 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
7731 jsonReq, err := m.Marshal(req)
7732 if err != nil {
7733 return nil, err
7734 }
7735
7736 baseUrl, err := url.Parse(c.endpoint)
7737 if err != nil {
7738 return nil, err
7739 }
7740 baseUrl.Path += fmt.Sprintf("/v1/%v:removeCollectionItem", req.GetItem().GetCollection())
7741
7742 params := url.Values{}
7743 params.Add("$alt", "json;enum-encoding=int")
7744
7745 baseUrl.RawQuery = params.Encode()
7746
7747 // Build HTTP headers from client and context metadata.
7748 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "item.collection", url.QueryEscape(req.GetItem().GetCollection()))}
7749
7750 hds = append(c.xGoogHeaders, hds...)
7751 hds = append(hds, "Content-Type", "application/json")
7752 headers := gax.BuildHeaders(ctx, hds...)
7753 opts = append((*c.CallOptions).RemoveCollectionItem[0:len((*c.CallOptions).RemoveCollectionItem):len((*c.CallOptions).RemoveCollectionItem)], opts...)
7754 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7755 resp := &visionaipb.RemoveCollectionItemResponse{}
7756 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7757 if settings.Path != "" {
7758 baseUrl.Path = settings.Path
7759 }
7760 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
7761 if err != nil {
7762 return err
7763 }
7764 httpReq = httpReq.WithContext(ctx)
7765 httpReq.Header = headers
7766
7767 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RemoveCollectionItem")
7768 if err != nil {
7769 return err
7770 }
7771
7772 if err := unm.Unmarshal(buf, resp); err != nil {
7773 return err
7774 }
7775
7776 return nil
7777 }, opts...)
7778 if e != nil {
7779 return nil, e
7780 }
7781 return resp, nil
7782 }
7783
7784 // ViewCollectionItems view items inside a collection.
7785 func (c *warehouseRESTClient) ViewCollectionItems(ctx context.Context, req *visionaipb.ViewCollectionItemsRequest, opts ...gax.CallOption) *CollectionItemIterator {
7786 it := &CollectionItemIterator{}
7787 req = proto.Clone(req).(*visionaipb.ViewCollectionItemsRequest)
7788 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7789 it.InternalFetch = func(pageSize int, pageToken string) ([]*visionaipb.CollectionItem, string, error) {
7790 resp := &visionaipb.ViewCollectionItemsResponse{}
7791 if pageToken != "" {
7792 req.PageToken = pageToken
7793 }
7794 if pageSize > math.MaxInt32 {
7795 req.PageSize = math.MaxInt32
7796 } else if pageSize != 0 {
7797 req.PageSize = int32(pageSize)
7798 }
7799 baseUrl, err := url.Parse(c.endpoint)
7800 if err != nil {
7801 return nil, "", err
7802 }
7803 baseUrl.Path += fmt.Sprintf("/v1/%v:viewCollectionItems", req.GetCollection())
7804
7805 params := url.Values{}
7806 params.Add("$alt", "json;enum-encoding=int")
7807 if req.GetPageSize() != 0 {
7808 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
7809 }
7810 if req.GetPageToken() != "" {
7811 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
7812 }
7813
7814 baseUrl.RawQuery = params.Encode()
7815
7816 // Build HTTP headers from client and context metadata.
7817 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
7818 headers := gax.BuildHeaders(ctx, hds...)
7819 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7820 if settings.Path != "" {
7821 baseUrl.Path = settings.Path
7822 }
7823 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
7824 if err != nil {
7825 return err
7826 }
7827 httpReq.Header = headers
7828
7829 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ViewCollectionItems")
7830 if err != nil {
7831 return err
7832 }
7833 if err := unm.Unmarshal(buf, resp); err != nil {
7834 return err
7835 }
7836
7837 return nil
7838 }, opts...)
7839 if e != nil {
7840 return nil, "", e
7841 }
7842 it.Response = resp
7843 return resp.GetItems(), resp.GetNextPageToken(), nil
7844 }
7845
7846 fetch := func(pageSize int, pageToken string) (string, error) {
7847 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
7848 if err != nil {
7849 return "", err
7850 }
7851 it.items = append(it.items, items...)
7852 return nextPageToken, nil
7853 }
7854
7855 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
7856 it.pageInfo.MaxSize = int(req.GetPageSize())
7857 it.pageInfo.Token = req.GetPageToken()
7858
7859 return it
7860 }
7861
7862 // CancelOperation is a utility method from google.longrunning.Operations.
7863 func (c *warehouseRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
7864 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
7865 jsonReq, err := m.Marshal(req)
7866 if err != nil {
7867 return err
7868 }
7869
7870 baseUrl, err := url.Parse(c.endpoint)
7871 if err != nil {
7872 return err
7873 }
7874 baseUrl.Path += fmt.Sprintf("/v1/%v:cancel", req.GetName())
7875
7876 params := url.Values{}
7877 params.Add("$alt", "json;enum-encoding=int")
7878
7879 baseUrl.RawQuery = params.Encode()
7880
7881 // Build HTTP headers from client and context metadata.
7882 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
7883
7884 hds = append(c.xGoogHeaders, hds...)
7885 hds = append(hds, "Content-Type", "application/json")
7886 headers := gax.BuildHeaders(ctx, hds...)
7887 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7888 if settings.Path != "" {
7889 baseUrl.Path = settings.Path
7890 }
7891 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
7892 if err != nil {
7893 return err
7894 }
7895 httpReq = httpReq.WithContext(ctx)
7896 httpReq.Header = headers
7897
7898 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelOperation")
7899 return err
7900 }, opts...)
7901 }
7902
7903 // DeleteOperation is a utility method from google.longrunning.Operations.
7904 func (c *warehouseRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
7905 baseUrl, err := url.Parse(c.endpoint)
7906 if err != nil {
7907 return err
7908 }
7909 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
7910
7911 params := url.Values{}
7912 params.Add("$alt", "json;enum-encoding=int")
7913
7914 baseUrl.RawQuery = params.Encode()
7915
7916 // Build HTTP headers from client and context metadata.
7917 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
7918
7919 hds = append(c.xGoogHeaders, hds...)
7920 hds = append(hds, "Content-Type", "application/json")
7921 headers := gax.BuildHeaders(ctx, hds...)
7922 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7923 if settings.Path != "" {
7924 baseUrl.Path = settings.Path
7925 }
7926 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
7927 if err != nil {
7928 return err
7929 }
7930 httpReq = httpReq.WithContext(ctx)
7931 httpReq.Header = headers
7932
7933 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
7934 return err
7935 }, opts...)
7936 }
7937
7938 // GetOperation is a utility method from google.longrunning.Operations.
7939 func (c *warehouseRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
7940 baseUrl, err := url.Parse(c.endpoint)
7941 if err != nil {
7942 return nil, err
7943 }
7944 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
7945
7946 params := url.Values{}
7947 params.Add("$alt", "json;enum-encoding=int")
7948
7949 baseUrl.RawQuery = params.Encode()
7950
7951 // Build HTTP headers from client and context metadata.
7952 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
7953
7954 hds = append(c.xGoogHeaders, hds...)
7955 hds = append(hds, "Content-Type", "application/json")
7956 headers := gax.BuildHeaders(ctx, hds...)
7957 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
7958 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7959 resp := &longrunningpb.Operation{}
7960 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
7961 if settings.Path != "" {
7962 baseUrl.Path = settings.Path
7963 }
7964 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
7965 if err != nil {
7966 return err
7967 }
7968 httpReq = httpReq.WithContext(ctx)
7969 httpReq.Header = headers
7970
7971 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
7972 if err != nil {
7973 return err
7974 }
7975
7976 if err := unm.Unmarshal(buf, resp); err != nil {
7977 return err
7978 }
7979
7980 return nil
7981 }, opts...)
7982 if e != nil {
7983 return nil, e
7984 }
7985 return resp, nil
7986 }
7987
7988 // ListOperations is a utility method from google.longrunning.Operations.
7989 func (c *warehouseRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
7990 it := &OperationIterator{}
7991 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
7992 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
7993 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
7994 resp := &longrunningpb.ListOperationsResponse{}
7995 if pageToken != "" {
7996 req.PageToken = pageToken
7997 }
7998 if pageSize > math.MaxInt32 {
7999 req.PageSize = math.MaxInt32
8000 } else if pageSize != 0 {
8001 req.PageSize = int32(pageSize)
8002 }
8003 baseUrl, err := url.Parse(c.endpoint)
8004 if err != nil {
8005 return nil, "", err
8006 }
8007 baseUrl.Path += fmt.Sprintf("/v1/%v/operations", req.GetName())
8008
8009 params := url.Values{}
8010 params.Add("$alt", "json;enum-encoding=int")
8011 if req.GetFilter() != "" {
8012 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
8013 }
8014 if req.GetPageSize() != 0 {
8015 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
8016 }
8017 if req.GetPageToken() != "" {
8018 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
8019 }
8020
8021 baseUrl.RawQuery = params.Encode()
8022
8023 // Build HTTP headers from client and context metadata.
8024 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
8025 headers := gax.BuildHeaders(ctx, hds...)
8026 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
8027 if settings.Path != "" {
8028 baseUrl.Path = settings.Path
8029 }
8030 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
8031 if err != nil {
8032 return err
8033 }
8034 httpReq.Header = headers
8035
8036 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
8037 if err != nil {
8038 return err
8039 }
8040 if err := unm.Unmarshal(buf, resp); err != nil {
8041 return err
8042 }
8043
8044 return nil
8045 }, opts...)
8046 if e != nil {
8047 return nil, "", e
8048 }
8049 it.Response = resp
8050 return resp.GetOperations(), resp.GetNextPageToken(), nil
8051 }
8052
8053 fetch := func(pageSize int, pageToken string) (string, error) {
8054 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
8055 if err != nil {
8056 return "", err
8057 }
8058 it.items = append(it.items, items...)
8059 return nextPageToken, nil
8060 }
8061
8062 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
8063 it.pageInfo.MaxSize = int(req.GetPageSize())
8064 it.pageInfo.Token = req.GetPageToken()
8065
8066 return it
8067 }
8068
8069 // AnalyzeAssetOperation returns a new AnalyzeAssetOperation from a given name.
8070 // The name must be that of a previously created AnalyzeAssetOperation, possibly from a different process.
8071 func (c *warehouseGRPCClient) AnalyzeAssetOperation(name string) *AnalyzeAssetOperation {
8072 return &AnalyzeAssetOperation{
8073 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8074 }
8075 }
8076
8077 // AnalyzeAssetOperation returns a new AnalyzeAssetOperation from a given name.
8078 // The name must be that of a previously created AnalyzeAssetOperation, possibly from a different process.
8079 func (c *warehouseRESTClient) AnalyzeAssetOperation(name string) *AnalyzeAssetOperation {
8080 override := fmt.Sprintf("/v1/%s", name)
8081 return &AnalyzeAssetOperation{
8082 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8083 pollPath: override,
8084 }
8085 }
8086
8087 // AnalyzeCorpusOperation returns a new AnalyzeCorpusOperation from a given name.
8088 // The name must be that of a previously created AnalyzeCorpusOperation, possibly from a different process.
8089 func (c *warehouseGRPCClient) AnalyzeCorpusOperation(name string) *AnalyzeCorpusOperation {
8090 return &AnalyzeCorpusOperation{
8091 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8092 }
8093 }
8094
8095 // AnalyzeCorpusOperation returns a new AnalyzeCorpusOperation from a given name.
8096 // The name must be that of a previously created AnalyzeCorpusOperation, possibly from a different process.
8097 func (c *warehouseRESTClient) AnalyzeCorpusOperation(name string) *AnalyzeCorpusOperation {
8098 override := fmt.Sprintf("/v1/%s", name)
8099 return &AnalyzeCorpusOperation{
8100 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8101 pollPath: override,
8102 }
8103 }
8104
8105 // CreateCollectionOperation returns a new CreateCollectionOperation from a given name.
8106 // The name must be that of a previously created CreateCollectionOperation, possibly from a different process.
8107 func (c *warehouseGRPCClient) CreateCollectionOperation(name string) *CreateCollectionOperation {
8108 return &CreateCollectionOperation{
8109 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8110 }
8111 }
8112
8113 // CreateCollectionOperation returns a new CreateCollectionOperation from a given name.
8114 // The name must be that of a previously created CreateCollectionOperation, possibly from a different process.
8115 func (c *warehouseRESTClient) CreateCollectionOperation(name string) *CreateCollectionOperation {
8116 override := fmt.Sprintf("/v1/%s", name)
8117 return &CreateCollectionOperation{
8118 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8119 pollPath: override,
8120 }
8121 }
8122
8123 // CreateCorpusOperation returns a new CreateCorpusOperation from a given name.
8124 // The name must be that of a previously created CreateCorpusOperation, possibly from a different process.
8125 func (c *warehouseGRPCClient) CreateCorpusOperation(name string) *CreateCorpusOperation {
8126 return &CreateCorpusOperation{
8127 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8128 }
8129 }
8130
8131 // CreateCorpusOperation returns a new CreateCorpusOperation from a given name.
8132 // The name must be that of a previously created CreateCorpusOperation, possibly from a different process.
8133 func (c *warehouseRESTClient) CreateCorpusOperation(name string) *CreateCorpusOperation {
8134 override := fmt.Sprintf("/v1/%s", name)
8135 return &CreateCorpusOperation{
8136 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8137 pollPath: override,
8138 }
8139 }
8140
8141 // CreateIndexOperation returns a new CreateIndexOperation from a given name.
8142 // The name must be that of a previously created CreateIndexOperation, possibly from a different process.
8143 func (c *warehouseGRPCClient) CreateIndexOperation(name string) *CreateIndexOperation {
8144 return &CreateIndexOperation{
8145 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8146 }
8147 }
8148
8149 // CreateIndexOperation returns a new CreateIndexOperation from a given name.
8150 // The name must be that of a previously created CreateIndexOperation, possibly from a different process.
8151 func (c *warehouseRESTClient) CreateIndexOperation(name string) *CreateIndexOperation {
8152 override := fmt.Sprintf("/v1/%s", name)
8153 return &CreateIndexOperation{
8154 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8155 pollPath: override,
8156 }
8157 }
8158
8159 // CreateIndexEndpointOperation returns a new CreateIndexEndpointOperation from a given name.
8160 // The name must be that of a previously created CreateIndexEndpointOperation, possibly from a different process.
8161 func (c *warehouseGRPCClient) CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation {
8162 return &CreateIndexEndpointOperation{
8163 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8164 }
8165 }
8166
8167 // CreateIndexEndpointOperation returns a new CreateIndexEndpointOperation from a given name.
8168 // The name must be that of a previously created CreateIndexEndpointOperation, possibly from a different process.
8169 func (c *warehouseRESTClient) CreateIndexEndpointOperation(name string) *CreateIndexEndpointOperation {
8170 override := fmt.Sprintf("/v1/%s", name)
8171 return &CreateIndexEndpointOperation{
8172 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8173 pollPath: override,
8174 }
8175 }
8176
8177 // DeleteAssetOperation returns a new DeleteAssetOperation from a given name.
8178 // The name must be that of a previously created DeleteAssetOperation, possibly from a different process.
8179 func (c *warehouseGRPCClient) DeleteAssetOperation(name string) *DeleteAssetOperation {
8180 return &DeleteAssetOperation{
8181 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8182 }
8183 }
8184
8185 // DeleteAssetOperation returns a new DeleteAssetOperation from a given name.
8186 // The name must be that of a previously created DeleteAssetOperation, possibly from a different process.
8187 func (c *warehouseRESTClient) DeleteAssetOperation(name string) *DeleteAssetOperation {
8188 override := fmt.Sprintf("/v1/%s", name)
8189 return &DeleteAssetOperation{
8190 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8191 pollPath: override,
8192 }
8193 }
8194
8195 // DeleteCollectionOperation returns a new DeleteCollectionOperation from a given name.
8196 // The name must be that of a previously created DeleteCollectionOperation, possibly from a different process.
8197 func (c *warehouseGRPCClient) DeleteCollectionOperation(name string) *DeleteCollectionOperation {
8198 return &DeleteCollectionOperation{
8199 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8200 }
8201 }
8202
8203 // DeleteCollectionOperation returns a new DeleteCollectionOperation from a given name.
8204 // The name must be that of a previously created DeleteCollectionOperation, possibly from a different process.
8205 func (c *warehouseRESTClient) DeleteCollectionOperation(name string) *DeleteCollectionOperation {
8206 override := fmt.Sprintf("/v1/%s", name)
8207 return &DeleteCollectionOperation{
8208 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8209 pollPath: override,
8210 }
8211 }
8212
8213 // DeleteIndexOperation returns a new DeleteIndexOperation from a given name.
8214 // The name must be that of a previously created DeleteIndexOperation, possibly from a different process.
8215 func (c *warehouseGRPCClient) DeleteIndexOperation(name string) *DeleteIndexOperation {
8216 return &DeleteIndexOperation{
8217 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8218 }
8219 }
8220
8221 // DeleteIndexOperation returns a new DeleteIndexOperation from a given name.
8222 // The name must be that of a previously created DeleteIndexOperation, possibly from a different process.
8223 func (c *warehouseRESTClient) DeleteIndexOperation(name string) *DeleteIndexOperation {
8224 override := fmt.Sprintf("/v1/%s", name)
8225 return &DeleteIndexOperation{
8226 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8227 pollPath: override,
8228 }
8229 }
8230
8231 // DeleteIndexEndpointOperation returns a new DeleteIndexEndpointOperation from a given name.
8232 // The name must be that of a previously created DeleteIndexEndpointOperation, possibly from a different process.
8233 func (c *warehouseGRPCClient) DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation {
8234 return &DeleteIndexEndpointOperation{
8235 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8236 }
8237 }
8238
8239 // DeleteIndexEndpointOperation returns a new DeleteIndexEndpointOperation from a given name.
8240 // The name must be that of a previously created DeleteIndexEndpointOperation, possibly from a different process.
8241 func (c *warehouseRESTClient) DeleteIndexEndpointOperation(name string) *DeleteIndexEndpointOperation {
8242 override := fmt.Sprintf("/v1/%s", name)
8243 return &DeleteIndexEndpointOperation{
8244 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8245 pollPath: override,
8246 }
8247 }
8248
8249 // DeployIndexOperation returns a new DeployIndexOperation from a given name.
8250 // The name must be that of a previously created DeployIndexOperation, possibly from a different process.
8251 func (c *warehouseGRPCClient) DeployIndexOperation(name string) *DeployIndexOperation {
8252 return &DeployIndexOperation{
8253 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8254 }
8255 }
8256
8257 // DeployIndexOperation returns a new DeployIndexOperation from a given name.
8258 // The name must be that of a previously created DeployIndexOperation, possibly from a different process.
8259 func (c *warehouseRESTClient) DeployIndexOperation(name string) *DeployIndexOperation {
8260 override := fmt.Sprintf("/v1/%s", name)
8261 return &DeployIndexOperation{
8262 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8263 pollPath: override,
8264 }
8265 }
8266
8267 // ImportAssetsOperation returns a new ImportAssetsOperation from a given name.
8268 // The name must be that of a previously created ImportAssetsOperation, possibly from a different process.
8269 func (c *warehouseGRPCClient) ImportAssetsOperation(name string) *ImportAssetsOperation {
8270 return &ImportAssetsOperation{
8271 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8272 }
8273 }
8274
8275 // ImportAssetsOperation returns a new ImportAssetsOperation from a given name.
8276 // The name must be that of a previously created ImportAssetsOperation, possibly from a different process.
8277 func (c *warehouseRESTClient) ImportAssetsOperation(name string) *ImportAssetsOperation {
8278 override := fmt.Sprintf("/v1/%s", name)
8279 return &ImportAssetsOperation{
8280 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8281 pollPath: override,
8282 }
8283 }
8284
8285 // IndexAssetOperation returns a new IndexAssetOperation from a given name.
8286 // The name must be that of a previously created IndexAssetOperation, possibly from a different process.
8287 func (c *warehouseGRPCClient) IndexAssetOperation(name string) *IndexAssetOperation {
8288 return &IndexAssetOperation{
8289 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8290 }
8291 }
8292
8293 // IndexAssetOperation returns a new IndexAssetOperation from a given name.
8294 // The name must be that of a previously created IndexAssetOperation, possibly from a different process.
8295 func (c *warehouseRESTClient) IndexAssetOperation(name string) *IndexAssetOperation {
8296 override := fmt.Sprintf("/v1/%s", name)
8297 return &IndexAssetOperation{
8298 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8299 pollPath: override,
8300 }
8301 }
8302
8303 // RemoveIndexAssetOperation returns a new RemoveIndexAssetOperation from a given name.
8304 // The name must be that of a previously created RemoveIndexAssetOperation, possibly from a different process.
8305 func (c *warehouseGRPCClient) RemoveIndexAssetOperation(name string) *RemoveIndexAssetOperation {
8306 return &RemoveIndexAssetOperation{
8307 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8308 }
8309 }
8310
8311 // RemoveIndexAssetOperation returns a new RemoveIndexAssetOperation from a given name.
8312 // The name must be that of a previously created RemoveIndexAssetOperation, possibly from a different process.
8313 func (c *warehouseRESTClient) RemoveIndexAssetOperation(name string) *RemoveIndexAssetOperation {
8314 override := fmt.Sprintf("/v1/%s", name)
8315 return &RemoveIndexAssetOperation{
8316 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8317 pollPath: override,
8318 }
8319 }
8320
8321 // UndeployIndexOperation returns a new UndeployIndexOperation from a given name.
8322 // The name must be that of a previously created UndeployIndexOperation, possibly from a different process.
8323 func (c *warehouseGRPCClient) UndeployIndexOperation(name string) *UndeployIndexOperation {
8324 return &UndeployIndexOperation{
8325 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8326 }
8327 }
8328
8329 // UndeployIndexOperation returns a new UndeployIndexOperation from a given name.
8330 // The name must be that of a previously created UndeployIndexOperation, possibly from a different process.
8331 func (c *warehouseRESTClient) UndeployIndexOperation(name string) *UndeployIndexOperation {
8332 override := fmt.Sprintf("/v1/%s", name)
8333 return &UndeployIndexOperation{
8334 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8335 pollPath: override,
8336 }
8337 }
8338
8339 // UpdateIndexOperation returns a new UpdateIndexOperation from a given name.
8340 // The name must be that of a previously created UpdateIndexOperation, possibly from a different process.
8341 func (c *warehouseGRPCClient) UpdateIndexOperation(name string) *UpdateIndexOperation {
8342 return &UpdateIndexOperation{
8343 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8344 }
8345 }
8346
8347 // UpdateIndexOperation returns a new UpdateIndexOperation from a given name.
8348 // The name must be that of a previously created UpdateIndexOperation, possibly from a different process.
8349 func (c *warehouseRESTClient) UpdateIndexOperation(name string) *UpdateIndexOperation {
8350 override := fmt.Sprintf("/v1/%s", name)
8351 return &UpdateIndexOperation{
8352 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8353 pollPath: override,
8354 }
8355 }
8356
8357 // UpdateIndexEndpointOperation returns a new UpdateIndexEndpointOperation from a given name.
8358 // The name must be that of a previously created UpdateIndexEndpointOperation, possibly from a different process.
8359 func (c *warehouseGRPCClient) UpdateIndexEndpointOperation(name string) *UpdateIndexEndpointOperation {
8360 return &UpdateIndexEndpointOperation{
8361 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8362 }
8363 }
8364
8365 // UpdateIndexEndpointOperation returns a new UpdateIndexEndpointOperation from a given name.
8366 // The name must be that of a previously created UpdateIndexEndpointOperation, possibly from a different process.
8367 func (c *warehouseRESTClient) UpdateIndexEndpointOperation(name string) *UpdateIndexEndpointOperation {
8368 override := fmt.Sprintf("/v1/%s", name)
8369 return &UpdateIndexEndpointOperation{
8370 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8371 pollPath: override,
8372 }
8373 }
8374
8375 // UploadAssetOperation returns a new UploadAssetOperation from a given name.
8376 // The name must be that of a previously created UploadAssetOperation, possibly from a different process.
8377 func (c *warehouseGRPCClient) UploadAssetOperation(name string) *UploadAssetOperation {
8378 return &UploadAssetOperation{
8379 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8380 }
8381 }
8382
8383 // UploadAssetOperation returns a new UploadAssetOperation from a given name.
8384 // The name must be that of a previously created UploadAssetOperation, possibly from a different process.
8385 func (c *warehouseRESTClient) UploadAssetOperation(name string) *UploadAssetOperation {
8386 override := fmt.Sprintf("/v1/%s", name)
8387 return &UploadAssetOperation{
8388 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
8389 pollPath: override,
8390 }
8391 }