Debian Codegraph @

streetview/publish/apiv1/auxiliary.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 publish
18
19 import (
20 "context"
21 "time"
22
23 "cloud.google.com/go/longrunning"
24 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
25 publishpb "cloud.google.com/go/streetview/publish/apiv1/publishpb"
26 gax "github.com/googleapis/gax-go/v2"
27 "google.golang.org/api/iterator"
28 emptypb "google.golang.org/protobuf/types/known/emptypb"
29 )
30
31 // CreatePhotoSequenceOperation manages a long-running operation from CreatePhotoSequence.
32 type CreatePhotoSequenceOperation struct {
33 lro *longrunning.Operation
34 pollPath string
35 }
36
37 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
38 //
39 // See documentation of Poll for error-handling information.
40 func (op *CreatePhotoSequenceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*publishpb.PhotoSequence, error) {
41 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
42 var resp publishpb.PhotoSequence
43 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
44 return nil, err
45 }
46 return &resp, nil
47 }
48
49 // Poll fetches the latest state of the long-running operation.
50 //
51 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
52 //
53 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
54 // the operation has completed with failure, the error is returned and op.Done will return true.
55 // If Poll succeeds and the operation has completed successfully,
56 // op.Done will return true, and the response of the operation is returned.
57 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
58 func (op *CreatePhotoSequenceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*publishpb.PhotoSequence, error) {
59 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
60 var resp publishpb.PhotoSequence
61 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
62 return nil, err
63 }
64 if !op.Done() {
65 return nil, nil
66 }
67 return &resp, nil
68 }
69
70 // Metadata returns metadata associated with the long-running operation.
71 // Metadata itself does not contact the server, but Poll does.
72 // To get the latest metadata, call this method after a successful call to Poll.
73 // If the metadata is not available, the returned metadata and error are both nil.
74 func (op *CreatePhotoSequenceOperation) Metadata() (*emptypb.Empty, error) {
75 var meta emptypb.Empty
76 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
77 return nil, nil
78 } else if err != nil {
79 return nil, err
80 }
81 return &meta, nil
82 }
83
84 // Done reports whether the long-running operation has completed.
85 func (op *CreatePhotoSequenceOperation) Done() bool {
86 return op.lro.Done()
87 }
88
89 // Name returns the name of the long-running operation.
90 // The name is assigned by the server and is unique within the service from which the operation is created.
91 func (op *CreatePhotoSequenceOperation) Name() string {
92 return op.lro.Name()
93 }
94
95 // GetPhotoSequenceOperation manages a long-running operation from GetPhotoSequence.
96 type GetPhotoSequenceOperation struct {
97 lro *longrunning.Operation
98 pollPath string
99 }
100
101 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
102 //
103 // See documentation of Poll for error-handling information.
104 func (op *GetPhotoSequenceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*publishpb.PhotoSequence, error) {
105 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
106 var resp publishpb.PhotoSequence
107 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
108 return nil, err
109 }
110 return &resp, nil
111 }
112
113 // Poll fetches the latest state of the long-running operation.
114 //
115 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
116 //
117 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
118 // the operation has completed with failure, the error is returned and op.Done will return true.
119 // If Poll succeeds and the operation has completed successfully,
120 // op.Done will return true, and the response of the operation is returned.
121 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
122 func (op *GetPhotoSequenceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*publishpb.PhotoSequence, error) {
123 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
124 var resp publishpb.PhotoSequence
125 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
126 return nil, err
127 }
128 if !op.Done() {
129 return nil, nil
130 }
131 return &resp, nil
132 }
133
134 // Metadata returns metadata associated with the long-running operation.
135 // Metadata itself does not contact the server, but Poll does.
136 // To get the latest metadata, call this method after a successful call to Poll.
137 // If the metadata is not available, the returned metadata and error are both nil.
138 func (op *GetPhotoSequenceOperation) Metadata() (*emptypb.Empty, error) {
139 var meta emptypb.Empty
140 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
141 return nil, nil
142 } else if err != nil {
143 return nil, err
144 }
145 return &meta, nil
146 }
147
148 // Done reports whether the long-running operation has completed.
149 func (op *GetPhotoSequenceOperation) Done() bool {
150 return op.lro.Done()
151 }
152
153 // Name returns the name of the long-running operation.
154 // The name is assigned by the server and is unique within the service from which the operation is created.
155 func (op *GetPhotoSequenceOperation) Name() string {
156 return op.lro.Name()
157 }
158
159 // OperationIterator manages a stream of *longrunningpb.Operation.
160 type OperationIterator struct {
161 items []*longrunningpb.Operation
162 pageInfo *iterator.PageInfo
163 nextFunc func() error
164
165 // Response is the raw response for the current page.
166 // It must be cast to the RPC response type.
167 // Calling Next() or InternalFetch() updates this value.
168 Response interface{}
169
170 // InternalFetch is for use by the Google Cloud Libraries only.
171 // It is not part of the stable interface of this package.
172 //
173 // InternalFetch returns results from a single call to the underlying RPC.
174 // The number of results is no greater than pageSize.
175 // If there are no more results, nextPageToken is empty and err is nil.
176 InternalFetch func(pageSize int, pageToken string) (results []*longrunningpb.Operation, nextPageToken string, err error)
177 }
178
179 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
180 func (it *OperationIterator) PageInfo() *iterator.PageInfo {
181 return it.pageInfo
182 }
183
184 // Next returns the next result. Its second return value is iterator.Done if there are no more
185 // results. Once Next returns Done, all subsequent calls will return Done.
186 func (it *OperationIterator) Next() (*longrunningpb.Operation, error) {
187 var item *longrunningpb.Operation
188 if err := it.nextFunc(); err != nil {
189 return item, err
190 }
191 item = it.items[0]
192 it.items = it.items[1:]
193 return item, nil
194 }
195
196 func (it *OperationIterator) bufLen() int {
197 return len(it.items)
198 }
199
200 func (it *OperationIterator) takeBuf() interface{} {
201 b := it.items
202 it.items = nil
203 return b
204 }
205
206 // PhotoIterator manages a stream of *publishpb.Photo.
207 type PhotoIterator struct {
208 items []*publishpb.Photo
209 pageInfo *iterator.PageInfo
210 nextFunc func() error
211
212 // Response is the raw response for the current page.
213 // It must be cast to the RPC response type.
214 // Calling Next() or InternalFetch() updates this value.
215 Response interface{}
216
217 // InternalFetch is for use by the Google Cloud Libraries only.
218 // It is not part of the stable interface of this package.
219 //
220 // InternalFetch returns results from a single call to the underlying RPC.
221 // The number of results is no greater than pageSize.
222 // If there are no more results, nextPageToken is empty and err is nil.
223 InternalFetch func(pageSize int, pageToken string) (results []*publishpb.Photo, nextPageToken string, err error)
224 }
225
226 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
227 func (it *PhotoIterator) PageInfo() *iterator.PageInfo {
228 return it.pageInfo
229 }
230
231 // Next returns the next result. Its second return value is iterator.Done if there are no more
232 // results. Once Next returns Done, all subsequent calls will return Done.
233 func (it *PhotoIterator) Next() (*publishpb.Photo, error) {
234 var item *publishpb.Photo
235 if err := it.nextFunc(); err != nil {
236 return item, err
237 }
238 item = it.items[0]
239 it.items = it.items[1:]
240 return item, nil
241 }
242
243 func (it *PhotoIterator) bufLen() int {
244 return len(it.items)
245 }
246
247 func (it *PhotoIterator) takeBuf() interface{} {
248 b := it.items
249 it.items = nil
250 return b
251 }