Debian Codegraph @

apigeeregistry/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 apigeeregistry
18
19 import (
20 "context"
21 "time"
22
23 apigeeregistrypb "cloud.google.com/go/apigeeregistry/apiv1/apigeeregistrypb"
24 "cloud.google.com/go/longrunning"
25 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
26 gax "github.com/googleapis/gax-go/v2"
27 "google.golang.org/api/iterator"
28 locationpb "google.golang.org/genproto/googleapis/cloud/location"
29 )
30
31 // CreateInstanceOperation manages a long-running operation from CreateInstance.
32 type CreateInstanceOperation struct {
33 lro *longrunning.Operation
34 }
35
36 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
37 //
38 // See documentation of Poll for error-handling information.
39 func (op *CreateInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*apigeeregistrypb.Instance, error) {
40 var resp apigeeregistrypb.Instance
41 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
42 return nil, err
43 }
44 return &resp, nil
45 }
46
47 // Poll fetches the latest state of the long-running operation.
48 //
49 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
50 //
51 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
52 // the operation has completed with failure, the error is returned and op.Done will return true.
53 // If Poll succeeds and the operation has completed successfully,
54 // op.Done will return true, and the response of the operation is returned.
55 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
56 func (op *CreateInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*apigeeregistrypb.Instance, error) {
57 var resp apigeeregistrypb.Instance
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 *CreateInstanceOperation) Metadata() (*apigeeregistrypb.OperationMetadata, error) {
72 var meta apigeeregistrypb.OperationMetadata
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 *CreateInstanceOperation) 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 *CreateInstanceOperation) Name() string {
89 return op.lro.Name()
90 }
91
92 // DeleteInstanceOperation manages a long-running operation from DeleteInstance.
93 type DeleteInstanceOperation struct {
94 lro *longrunning.Operation
95 }
96
97 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
98 //
99 // See documentation of Poll for error-handling information.
100 func (op *DeleteInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
101 return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
102 }
103
104 // Poll fetches the latest state of the long-running operation.
105 //
106 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
107 //
108 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
109 // the operation has completed with failure, the error is returned and op.Done will return true.
110 // If Poll succeeds and the operation has completed successfully,
111 // op.Done will return true, and the response of the operation is returned.
112 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
113 func (op *DeleteInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
114 return op.lro.Poll(ctx, nil, opts...)
115 }
116
117 // Metadata returns metadata associated with the long-running operation.
118 // Metadata itself does not contact the server, but Poll does.
119 // To get the latest metadata, call this method after a successful call to Poll.
120 // If the metadata is not available, the returned metadata and error are both nil.
121 func (op *DeleteInstanceOperation) Metadata() (*apigeeregistrypb.OperationMetadata, error) {
122 var meta apigeeregistrypb.OperationMetadata
123 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
124 return nil, nil
125 } else if err != nil {
126 return nil, err
127 }
128 return &meta, nil
129 }
130
131 // Done reports whether the long-running operation has completed.
132 func (op *DeleteInstanceOperation) Done() bool {
133 return op.lro.Done()
134 }
135
136 // Name returns the name of the long-running operation.
137 // The name is assigned by the server and is unique within the service from which the operation is created.
138 func (op *DeleteInstanceOperation) Name() string {
139 return op.lro.Name()
140 }
141
142 // ApiDeploymentIterator manages a stream of *apigeeregistrypb.ApiDeployment.
143 type ApiDeploymentIterator struct {
144 items []*apigeeregistrypb.ApiDeployment
145 pageInfo *iterator.PageInfo
146 nextFunc func() error
147
148 // Response is the raw response for the current page.
149 // It must be cast to the RPC response type.
150 // Calling Next() or InternalFetch() updates this value.
151 Response interface{}
152
153 // InternalFetch is for use by the Google Cloud Libraries only.
154 // It is not part of the stable interface of this package.
155 //
156 // InternalFetch returns results from a single call to the underlying RPC.
157 // The number of results is no greater than pageSize.
158 // If there are no more results, nextPageToken is empty and err is nil.
159 InternalFetch func(pageSize int, pageToken string) (results []*apigeeregistrypb.ApiDeployment, nextPageToken string, err error)
160 }
161
162 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
163 func (it *ApiDeploymentIterator) PageInfo() *iterator.PageInfo {
164 return it.pageInfo
165 }
166
167 // Next returns the next result. Its second return value is iterator.Done if there are no more
168 // results. Once Next returns Done, all subsequent calls will return Done.
169 func (it *ApiDeploymentIterator) Next() (*apigeeregistrypb.ApiDeployment, error) {
170 var item *apigeeregistrypb.ApiDeployment
171 if err := it.nextFunc(); err != nil {
172 return item, err
173 }
174 item = it.items[0]
175 it.items = it.items[1:]
176 return item, nil
177 }
178
179 func (it *ApiDeploymentIterator) bufLen() int {
180 return len(it.items)
181 }
182
183 func (it *ApiDeploymentIterator) takeBuf() interface{} {
184 b := it.items
185 it.items = nil
186 return b
187 }
188
189 // ApiIterator manages a stream of *apigeeregistrypb.Api.
190 type ApiIterator struct {
191 items []*apigeeregistrypb.Api
192 pageInfo *iterator.PageInfo
193 nextFunc func() error
194
195 // Response is the raw response for the current page.
196 // It must be cast to the RPC response type.
197 // Calling Next() or InternalFetch() updates this value.
198 Response interface{}
199
200 // InternalFetch is for use by the Google Cloud Libraries only.
201 // It is not part of the stable interface of this package.
202 //
203 // InternalFetch returns results from a single call to the underlying RPC.
204 // The number of results is no greater than pageSize.
205 // If there are no more results, nextPageToken is empty and err is nil.
206 InternalFetch func(pageSize int, pageToken string) (results []*apigeeregistrypb.Api, nextPageToken string, err error)
207 }
208
209 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
210 func (it *ApiIterator) PageInfo() *iterator.PageInfo {
211 return it.pageInfo
212 }
213
214 // Next returns the next result. Its second return value is iterator.Done if there are no more
215 // results. Once Next returns Done, all subsequent calls will return Done.
216 func (it *ApiIterator) Next() (*apigeeregistrypb.Api, error) {
217 var item *apigeeregistrypb.Api
218 if err := it.nextFunc(); err != nil {
219 return item, err
220 }
221 item = it.items[0]
222 it.items = it.items[1:]
223 return item, nil
224 }
225
226 func (it *ApiIterator) bufLen() int {
227 return len(it.items)
228 }
229
230 func (it *ApiIterator) takeBuf() interface{} {
231 b := it.items
232 it.items = nil
233 return b
234 }
235
236 // ApiSpecIterator manages a stream of *apigeeregistrypb.ApiSpec.
237 type ApiSpecIterator struct {
238 items []*apigeeregistrypb.ApiSpec
239 pageInfo *iterator.PageInfo
240 nextFunc func() error
241
242 // Response is the raw response for the current page.
243 // It must be cast to the RPC response type.
244 // Calling Next() or InternalFetch() updates this value.
245 Response interface{}
246
247 // InternalFetch is for use by the Google Cloud Libraries only.
248 // It is not part of the stable interface of this package.
249 //
250 // InternalFetch returns results from a single call to the underlying RPC.
251 // The number of results is no greater than pageSize.
252 // If there are no more results, nextPageToken is empty and err is nil.
253 InternalFetch func(pageSize int, pageToken string) (results []*apigeeregistrypb.ApiSpec, nextPageToken string, err error)
254 }
255
256 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
257 func (it *ApiSpecIterator) PageInfo() *iterator.PageInfo {
258 return it.pageInfo
259 }
260
261 // Next returns the next result. Its second return value is iterator.Done if there are no more
262 // results. Once Next returns Done, all subsequent calls will return Done.
263 func (it *ApiSpecIterator) Next() (*apigeeregistrypb.ApiSpec, error) {
264 var item *apigeeregistrypb.ApiSpec
265 if err := it.nextFunc(); err != nil {
266 return item, err
267 }
268 item = it.items[0]
269 it.items = it.items[1:]
270 return item, nil
271 }
272
273 func (it *ApiSpecIterator) bufLen() int {
274 return len(it.items)
275 }
276
277 func (it *ApiSpecIterator) takeBuf() interface{} {
278 b := it.items
279 it.items = nil
280 return b
281 }
282
283 // ApiVersionIterator manages a stream of *apigeeregistrypb.ApiVersion.
284 type ApiVersionIterator struct {
285 items []*apigeeregistrypb.ApiVersion
286 pageInfo *iterator.PageInfo
287 nextFunc func() error
288
289 // Response is the raw response for the current page.
290 // It must be cast to the RPC response type.
291 // Calling Next() or InternalFetch() updates this value.
292 Response interface{}
293
294 // InternalFetch is for use by the Google Cloud Libraries only.
295 // It is not part of the stable interface of this package.
296 //
297 // InternalFetch returns results from a single call to the underlying RPC.
298 // The number of results is no greater than pageSize.
299 // If there are no more results, nextPageToken is empty and err is nil.
300 InternalFetch func(pageSize int, pageToken string) (results []*apigeeregistrypb.ApiVersion, nextPageToken string, err error)
301 }
302
303 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
304 func (it *ApiVersionIterator) PageInfo() *iterator.PageInfo {
305 return it.pageInfo
306 }
307
308 // Next returns the next result. Its second return value is iterator.Done if there are no more
309 // results. Once Next returns Done, all subsequent calls will return Done.
310 func (it *ApiVersionIterator) Next() (*apigeeregistrypb.ApiVersion, error) {
311 var item *apigeeregistrypb.ApiVersion
312 if err := it.nextFunc(); err != nil {
313 return item, err
314 }
315 item = it.items[0]
316 it.items = it.items[1:]
317 return item, nil
318 }
319
320 func (it *ApiVersionIterator) bufLen() int {
321 return len(it.items)
322 }
323
324 func (it *ApiVersionIterator) takeBuf() interface{} {
325 b := it.items
326 it.items = nil
327 return b
328 }
329
330 // ArtifactIterator manages a stream of *apigeeregistrypb.Artifact.
331 type ArtifactIterator struct {
332 items []*apigeeregistrypb.Artifact
333 pageInfo *iterator.PageInfo
334 nextFunc func() error
335
336 // Response is the raw response for the current page.
337 // It must be cast to the RPC response type.
338 // Calling Next() or InternalFetch() updates this value.
339 Response interface{}
340
341 // InternalFetch is for use by the Google Cloud Libraries only.
342 // It is not part of the stable interface of this package.
343 //
344 // InternalFetch returns results from a single call to the underlying RPC.
345 // The number of results is no greater than pageSize.
346 // If there are no more results, nextPageToken is empty and err is nil.
347 InternalFetch func(pageSize int, pageToken string) (results []*apigeeregistrypb.Artifact, nextPageToken string, err error)
348 }
349
350 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
351 func (it *ArtifactIterator) PageInfo() *iterator.PageInfo {
352 return it.pageInfo
353 }
354
355 // Next returns the next result. Its second return value is iterator.Done if there are no more
356 // results. Once Next returns Done, all subsequent calls will return Done.
357 func (it *ArtifactIterator) Next() (*apigeeregistrypb.Artifact, error) {
358 var item *apigeeregistrypb.Artifact
359 if err := it.nextFunc(); err != nil {
360 return item, err
361 }
362 item = it.items[0]
363 it.items = it.items[1:]
364 return item, nil
365 }
366
367 func (it *ArtifactIterator) bufLen() int {
368 return len(it.items)
369 }
370
371 func (it *ArtifactIterator) takeBuf() interface{} {
372 b := it.items
373 it.items = nil
374 return b
375 }
376
377 // LocationIterator manages a stream of *locationpb.Location.
378 type LocationIterator struct {
379 items []*locationpb.Location
380 pageInfo *iterator.PageInfo
381 nextFunc func() error
382
383 // Response is the raw response for the current page.
384 // It must be cast to the RPC response type.
385 // Calling Next() or InternalFetch() updates this value.
386 Response interface{}
387
388 // InternalFetch is for use by the Google Cloud Libraries only.
389 // It is not part of the stable interface of this package.
390 //
391 // InternalFetch returns results from a single call to the underlying RPC.
392 // The number of results is no greater than pageSize.
393 // If there are no more results, nextPageToken is empty and err is nil.
394 InternalFetch func(pageSize int, pageToken string) (results []*locationpb.Location, nextPageToken string, err error)
395 }
396
397 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
398 func (it *LocationIterator) PageInfo() *iterator.PageInfo {
399 return it.pageInfo
400 }
401
402 // Next returns the next result. Its second return value is iterator.Done if there are no more
403 // results. Once Next returns Done, all subsequent calls will return Done.
404 func (it *LocationIterator) Next() (*locationpb.Location, error) {
405 var item *locationpb.Location
406 if err := it.nextFunc(); err != nil {
407 return item, err
408 }
409 item = it.items[0]
410 it.items = it.items[1:]
411 return item, nil
412 }
413
414 func (it *LocationIterator) bufLen() int {
415 return len(it.items)
416 }
417
418 func (it *LocationIterator) takeBuf() interface{} {
419 b := it.items
420 it.items = nil
421 return b
422 }
423
424 // OperationIterator manages a stream of *longrunningpb.Operation.
425 type OperationIterator struct {
426 items []*longrunningpb.Operation
427 pageInfo *iterator.PageInfo
428 nextFunc func() error
429
430 // Response is the raw response for the current page.
431 // It must be cast to the RPC response type.
432 // Calling Next() or InternalFetch() updates this value.
433 Response interface{}
434
435 // InternalFetch is for use by the Google Cloud Libraries only.
436 // It is not part of the stable interface of this package.
437 //
438 // InternalFetch returns results from a single call to the underlying RPC.
439 // The number of results is no greater than pageSize.
440 // If there are no more results, nextPageToken is empty and err is nil.
441 InternalFetch func(pageSize int, pageToken string) (results []*longrunningpb.Operation, nextPageToken string, err error)
442 }
443
444 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
445 func (it *OperationIterator) PageInfo() *iterator.PageInfo {
446 return it.pageInfo
447 }
448
449 // Next returns the next result. Its second return value is iterator.Done if there are no more
450 // results. Once Next returns Done, all subsequent calls will return Done.
451 func (it *OperationIterator) Next() (*longrunningpb.Operation, error) {
452 var item *longrunningpb.Operation
453 if err := it.nextFunc(); err != nil {
454 return item, err
455 }
456 item = it.items[0]
457 it.items = it.items[1:]
458 return item, nil
459 }
460
461 func (it *OperationIterator) bufLen() int {
462 return len(it.items)
463 }
464
465 func (it *OperationIterator) takeBuf() interface{} {
466 b := it.items
467 it.items = nil
468 return b
469 }