Debian Codegraph @

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