Debian Codegraph @

videointelligence/apiv1p3beta1/auxiliary.go

raw symbols SCIP
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 videointelligence
18
19 import (
20 "context"
21 "time"
22
23 "cloud.google.com/go/longrunning"
24 videointelligencepb "cloud.google.com/go/videointelligence/apiv1p3beta1/videointelligencepb"
25 gax "github.com/googleapis/gax-go/v2"
26 )
27
28 // AnnotateVideoOperation manages a long-running operation from AnnotateVideo.
29 type AnnotateVideoOperation struct {
30 lro *longrunning.Operation
31 pollPath string
32 }
33
34 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
35 //
36 // See documentation of Poll for error-handling information.
37 func (op *AnnotateVideoOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*videointelligencepb.AnnotateVideoResponse, error) {
38 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
39 var resp videointelligencepb.AnnotateVideoResponse
40 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
41 return nil, err
42 }
43 return &resp, nil
44 }
45
46 // Poll fetches the latest state of the long-running operation.
47 //
48 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
49 //
50 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
51 // the operation has completed with failure, the error is returned and op.Done will return true.
52 // If Poll succeeds and the operation has completed successfully,
53 // op.Done will return true, and the response of the operation is returned.
54 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
55 func (op *AnnotateVideoOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*videointelligencepb.AnnotateVideoResponse, error) {
56 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
57 var resp videointelligencepb.AnnotateVideoResponse
58 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
59 return nil, err
60 }
61 if !op.Done() {
62 return nil, nil
63 }
64 return &resp, nil
65 }
66
67 // Metadata returns metadata associated with the long-running operation.
68 // Metadata itself does not contact the server, but Poll does.
69 // To get the latest metadata, call this method after a successful call to Poll.
70 // If the metadata is not available, the returned metadata and error are both nil.
71 func (op *AnnotateVideoOperation) Metadata() (*videointelligencepb.AnnotateVideoProgress, error) {
72 var meta videointelligencepb.AnnotateVideoProgress
73 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
74 return nil, nil
75 } else if err != nil {
76 return nil, err
77 }
78 return &meta, nil
79 }
80
81 // Done reports whether the long-running operation has completed.
82 func (op *AnnotateVideoOperation) Done() bool {
83 return op.lro.Done()
84 }
85
86 // Name returns the name of the long-running operation.
87 // The name is assigned by the server and is unique within the service from which the operation is created.
88 func (op *AnnotateVideoOperation) Name() string {
89 return op.lro.Name()
90 }