Debian Codegraph @

licensemanager/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 licensemanager
18
19 import (
20 "context"
21 "time"
22
23 licensemanagerpb "cloud.google.com/go/licensemanager/apiv1/licensemanagerpb"
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 // CreateConfigurationOperation manages a long-running operation from CreateConfiguration.
32 type CreateConfigurationOperation 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 *CreateConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) {
41 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
42 var resp licensemanagerpb.Configuration
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 *CreateConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) {
59 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
60 var resp licensemanagerpb.Configuration
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 *CreateConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) {
75 var meta licensemanagerpb.OperationMetadata
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 *CreateConfigurationOperation) 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 *CreateConfigurationOperation) Name() string {
92 return op.lro.Name()
93 }
94
95 // DeactivateConfigurationOperation manages a long-running operation from DeactivateConfiguration.
96 type DeactivateConfigurationOperation 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 *DeactivateConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) {
105 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
106 var resp licensemanagerpb.Configuration
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 *DeactivateConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) {
123 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
124 var resp licensemanagerpb.Configuration
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 *DeactivateConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) {
139 var meta licensemanagerpb.OperationMetadata
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 *DeactivateConfigurationOperation) 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 *DeactivateConfigurationOperation) Name() string {
156 return op.lro.Name()
157 }
158
159 // DeleteConfigurationOperation manages a long-running operation from DeleteConfiguration.
160 type DeleteConfigurationOperation struct {
161 lro *longrunning.Operation
162 pollPath string
163 }
164
165 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
166 //
167 // See documentation of Poll for error-handling information.
168 func (op *DeleteConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
169 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
170 return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
171 }
172
173 // Poll fetches the latest state of the long-running operation.
174 //
175 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
176 //
177 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
178 // the operation has completed with failure, the error is returned and op.Done will return true.
179 // If Poll succeeds and the operation has completed successfully,
180 // op.Done will return true, and the response of the operation is returned.
181 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
182 func (op *DeleteConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
183 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
184 return op.lro.Poll(ctx, nil, opts...)
185 }
186
187 // Metadata returns metadata associated with the long-running operation.
188 // Metadata itself does not contact the server, but Poll does.
189 // To get the latest metadata, call this method after a successful call to Poll.
190 // If the metadata is not available, the returned metadata and error are both nil.
191 func (op *DeleteConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) {
192 var meta licensemanagerpb.OperationMetadata
193 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
194 return nil, nil
195 } else if err != nil {
196 return nil, err
197 }
198 return &meta, nil
199 }
200
201 // Done reports whether the long-running operation has completed.
202 func (op *DeleteConfigurationOperation) Done() bool {
203 return op.lro.Done()
204 }
205
206 // Name returns the name of the long-running operation.
207 // The name is assigned by the server and is unique within the service from which the operation is created.
208 func (op *DeleteConfigurationOperation) Name() string {
209 return op.lro.Name()
210 }
211
212 // ReactivateConfigurationOperation manages a long-running operation from ReactivateConfiguration.
213 type ReactivateConfigurationOperation struct {
214 lro *longrunning.Operation
215 pollPath string
216 }
217
218 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
219 //
220 // See documentation of Poll for error-handling information.
221 func (op *ReactivateConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) {
222 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
223 var resp licensemanagerpb.Configuration
224 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
225 return nil, err
226 }
227 return &resp, nil
228 }
229
230 // Poll fetches the latest state of the long-running operation.
231 //
232 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
233 //
234 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
235 // the operation has completed with failure, the error is returned and op.Done will return true.
236 // If Poll succeeds and the operation has completed successfully,
237 // op.Done will return true, and the response of the operation is returned.
238 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
239 func (op *ReactivateConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) {
240 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
241 var resp licensemanagerpb.Configuration
242 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
243 return nil, err
244 }
245 if !op.Done() {
246 return nil, nil
247 }
248 return &resp, nil
249 }
250
251 // Metadata returns metadata associated with the long-running operation.
252 // Metadata itself does not contact the server, but Poll does.
253 // To get the latest metadata, call this method after a successful call to Poll.
254 // If the metadata is not available, the returned metadata and error are both nil.
255 func (op *ReactivateConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) {
256 var meta licensemanagerpb.OperationMetadata
257 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
258 return nil, nil
259 } else if err != nil {
260 return nil, err
261 }
262 return &meta, nil
263 }
264
265 // Done reports whether the long-running operation has completed.
266 func (op *ReactivateConfigurationOperation) Done() bool {
267 return op.lro.Done()
268 }
269
270 // Name returns the name of the long-running operation.
271 // The name is assigned by the server and is unique within the service from which the operation is created.
272 func (op *ReactivateConfigurationOperation) Name() string {
273 return op.lro.Name()
274 }
275
276 // UpdateConfigurationOperation manages a long-running operation from UpdateConfiguration.
277 type UpdateConfigurationOperation struct {
278 lro *longrunning.Operation
279 pollPath string
280 }
281
282 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
283 //
284 // See documentation of Poll for error-handling information.
285 func (op *UpdateConfigurationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) {
286 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
287 var resp licensemanagerpb.Configuration
288 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
289 return nil, err
290 }
291 return &resp, nil
292 }
293
294 // Poll fetches the latest state of the long-running operation.
295 //
296 // Poll also fetches the latest metadata, which can be retrieved by Metadata.
297 //
298 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
299 // the operation has completed with failure, the error is returned and op.Done will return true.
300 // If Poll succeeds and the operation has completed successfully,
301 // op.Done will return true, and the response of the operation is returned.
302 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
303 func (op *UpdateConfigurationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*licensemanagerpb.Configuration, error) {
304 opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
305 var resp licensemanagerpb.Configuration
306 if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
307 return nil, err
308 }
309 if !op.Done() {
310 return nil, nil
311 }
312 return &resp, nil
313 }
314
315 // Metadata returns metadata associated with the long-running operation.
316 // Metadata itself does not contact the server, but Poll does.
317 // To get the latest metadata, call this method after a successful call to Poll.
318 // If the metadata is not available, the returned metadata and error are both nil.
319 func (op *UpdateConfigurationOperation) Metadata() (*licensemanagerpb.OperationMetadata, error) {
320 var meta licensemanagerpb.OperationMetadata
321 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
322 return nil, nil
323 } else if err != nil {
324 return nil, err
325 }
326 return &meta, nil
327 }
328
329 // Done reports whether the long-running operation has completed.
330 func (op *UpdateConfigurationOperation) Done() bool {
331 return op.lro.Done()
332 }
333
334 // Name returns the name of the long-running operation.
335 // The name is assigned by the server and is unique within the service from which the operation is created.
336 func (op *UpdateConfigurationOperation) Name() string {
337 return op.lro.Name()
338 }
339
340 // ConfigurationIterator manages a stream of *licensemanagerpb.Configuration.
341 type ConfigurationIterator struct {
342 items []*licensemanagerpb.Configuration
343 pageInfo *iterator.PageInfo
344 nextFunc func() error
345
346 // Response is the raw response for the current page.
347 // It must be cast to the RPC response type.
348 // Calling Next() or InternalFetch() updates this value.
349 Response interface{}
350
351 // InternalFetch is for use by the Google Cloud Libraries only.
352 // It is not part of the stable interface of this package.
353 //
354 // InternalFetch returns results from a single call to the underlying RPC.
355 // The number of results is no greater than pageSize.
356 // If there are no more results, nextPageToken is empty and err is nil.
357 InternalFetch func(pageSize int, pageToken string) (results []*licensemanagerpb.Configuration, nextPageToken string, err error)
358 }
359
360 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
361 func (it *ConfigurationIterator) PageInfo() *iterator.PageInfo {
362 return it.pageInfo
363 }
364
365 // Next returns the next result. Its second return value is iterator.Done if there are no more
366 // results. Once Next returns Done, all subsequent calls will return Done.
367 func (it *ConfigurationIterator) Next() (*licensemanagerpb.Configuration, error) {
368 var item *licensemanagerpb.Configuration
369 if err := it.nextFunc(); err != nil {
370 return item, err
371 }
372 item = it.items[0]
373 it.items = it.items[1:]
374 return item, nil
375 }
376
377 func (it *ConfigurationIterator) bufLen() int {
378 return len(it.items)
379 }
380
381 func (it *ConfigurationIterator) takeBuf() interface{} {
382 b := it.items
383 it.items = nil
384 return b
385 }
386
387 // InstanceIterator manages a stream of *licensemanagerpb.Instance.
388 type InstanceIterator struct {
389 items []*licensemanagerpb.Instance
390 pageInfo *iterator.PageInfo
391 nextFunc func() error
392
393 // Response is the raw response for the current page.
394 // It must be cast to the RPC response type.
395 // Calling Next() or InternalFetch() updates this value.
396 Response interface{}
397
398 // InternalFetch is for use by the Google Cloud Libraries only.
399 // It is not part of the stable interface of this package.
400 //
401 // InternalFetch returns results from a single call to the underlying RPC.
402 // The number of results is no greater than pageSize.
403 // If there are no more results, nextPageToken is empty and err is nil.
404 InternalFetch func(pageSize int, pageToken string) (results []*licensemanagerpb.Instance, nextPageToken string, err error)
405 }
406
407 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
408 func (it *InstanceIterator) PageInfo() *iterator.PageInfo {
409 return it.pageInfo
410 }
411
412 // Next returns the next result. Its second return value is iterator.Done if there are no more
413 // results. Once Next returns Done, all subsequent calls will return Done.
414 func (it *InstanceIterator) Next() (*licensemanagerpb.Instance, error) {
415 var item *licensemanagerpb.Instance
416 if err := it.nextFunc(); err != nil {
417 return item, err
418 }
419 item = it.items[0]
420 it.items = it.items[1:]
421 return item, nil
422 }
423
424 func (it *InstanceIterator) bufLen() int {
425 return len(it.items)
426 }
427
428 func (it *InstanceIterator) takeBuf() interface{} {
429 b := it.items
430 it.items = nil
431 return b
432 }
433
434 // LocationIterator manages a stream of *locationpb.Location.
435 type LocationIterator struct {
436 items []*locationpb.Location
437 pageInfo *iterator.PageInfo
438 nextFunc func() error
439
440 // Response is the raw response for the current page.
441 // It must be cast to the RPC response type.
442 // Calling Next() or InternalFetch() updates this value.
443 Response interface{}
444
445 // InternalFetch is for use by the Google Cloud Libraries only.
446 // It is not part of the stable interface of this package.
447 //
448 // InternalFetch returns results from a single call to the underlying RPC.
449 // The number of results is no greater than pageSize.
450 // If there are no more results, nextPageToken is empty and err is nil.
451 InternalFetch func(pageSize int, pageToken string) (results []*locationpb.Location, nextPageToken string, err error)
452 }
453
454 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
455 func (it *LocationIterator) PageInfo() *iterator.PageInfo {
456 return it.pageInfo
457 }
458
459 // Next returns the next result. Its second return value is iterator.Done if there are no more
460 // results. Once Next returns Done, all subsequent calls will return Done.
461 func (it *LocationIterator) Next() (*locationpb.Location, error) {
462 var item *locationpb.Location
463 if err := it.nextFunc(); err != nil {
464 return item, err
465 }
466 item = it.items[0]
467 it.items = it.items[1:]
468 return item, nil
469 }
470
471 func (it *LocationIterator) bufLen() int {
472 return len(it.items)
473 }
474
475 func (it *LocationIterator) takeBuf() interface{} {
476 b := it.items
477 it.items = nil
478 return b
479 }
480
481 // OperationIterator manages a stream of *longrunningpb.Operation.
482 type OperationIterator struct {
483 items []*longrunningpb.Operation
484 pageInfo *iterator.PageInfo
485 nextFunc func() error
486
487 // Response is the raw response for the current page.
488 // It must be cast to the RPC response type.
489 // Calling Next() or InternalFetch() updates this value.
490 Response interface{}
491
492 // InternalFetch is for use by the Google Cloud Libraries only.
493 // It is not part of the stable interface of this package.
494 //
495 // InternalFetch returns results from a single call to the underlying RPC.
496 // The number of results is no greater than pageSize.
497 // If there are no more results, nextPageToken is empty and err is nil.
498 InternalFetch func(pageSize int, pageToken string) (results []*longrunningpb.Operation, nextPageToken string, err error)
499 }
500
501 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
502 func (it *OperationIterator) PageInfo() *iterator.PageInfo {
503 return it.pageInfo
504 }
505
506 // Next returns the next result. Its second return value is iterator.Done if there are no more
507 // results. Once Next returns Done, all subsequent calls will return Done.
508 func (it *OperationIterator) Next() (*longrunningpb.Operation, error) {
509 var item *longrunningpb.Operation
510 if err := it.nextFunc(); err != nil {
511 return item, err
512 }
513 item = it.items[0]
514 it.items = it.items[1:]
515 return item, nil
516 }
517
518 func (it *OperationIterator) bufLen() int {
519 return len(it.items)
520 }
521
522 func (it *OperationIterator) takeBuf() interface{} {
523 b := it.items
524 it.items = nil
525 return b
526 }
527
528 // ProductIterator manages a stream of *licensemanagerpb.Product.
529 type ProductIterator struct {
530 items []*licensemanagerpb.Product
531 pageInfo *iterator.PageInfo
532 nextFunc func() error
533
534 // Response is the raw response for the current page.
535 // It must be cast to the RPC response type.
536 // Calling Next() or InternalFetch() updates this value.
537 Response interface{}
538
539 // InternalFetch is for use by the Google Cloud Libraries only.
540 // It is not part of the stable interface of this package.
541 //
542 // InternalFetch returns results from a single call to the underlying RPC.
543 // The number of results is no greater than pageSize.
544 // If there are no more results, nextPageToken is empty and err is nil.
545 InternalFetch func(pageSize int, pageToken string) (results []*licensemanagerpb.Product, nextPageToken string, err error)
546 }
547
548 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
549 func (it *ProductIterator) PageInfo() *iterator.PageInfo {
550 return it.pageInfo
551 }
552
553 // Next returns the next result. Its second return value is iterator.Done if there are no more
554 // results. Once Next returns Done, all subsequent calls will return Done.
555 func (it *ProductIterator) Next() (*licensemanagerpb.Product, error) {
556 var item *licensemanagerpb.Product
557 if err := it.nextFunc(); err != nil {
558 return item, err
559 }
560 item = it.items[0]
561 it.items = it.items[1:]
562 return item, nil
563 }
564
565 func (it *ProductIterator) bufLen() int {
566 return len(it.items)
567 }
568
569 func (it *ProductIterator) takeBuf() interface{} {
570 b := it.items
571 it.items = nil
572 return b
573 }
574
575 // UsageIterator manages a stream of *licensemanagerpb.Usage.
576 type UsageIterator struct {
577 items []*licensemanagerpb.Usage
578 pageInfo *iterator.PageInfo
579 nextFunc func() error
580
581 // Response is the raw response for the current page.
582 // It must be cast to the RPC response type.
583 // Calling Next() or InternalFetch() updates this value.
584 Response interface{}
585
586 // InternalFetch is for use by the Google Cloud Libraries only.
587 // It is not part of the stable interface of this package.
588 //
589 // InternalFetch returns results from a single call to the underlying RPC.
590 // The number of results is no greater than pageSize.
591 // If there are no more results, nextPageToken is empty and err is nil.
592 InternalFetch func(pageSize int, pageToken string) (results []*licensemanagerpb.Usage, nextPageToken string, err error)
593 }
594
595 // PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
596 func (it *UsageIterator) PageInfo() *iterator.PageInfo {
597 return it.pageInfo
598 }
599
600 // Next returns the next result. Its second return value is iterator.Done if there are no more
601 // results. Once Next returns Done, all subsequent calls will return Done.
602 func (it *UsageIterator) Next() (*licensemanagerpb.Usage, error) {
603 var item *licensemanagerpb.Usage
604 if err := it.nextFunc(); err != nil {
605 return item, err
606 }
607 item = it.items[0]
608 it.items = it.items[1:]
609 return item, nil
610 }
611
612 func (it *UsageIterator) bufLen() int {
613 return len(it.items)
614 }
615
616 func (it *UsageIterator) takeBuf() interface{} {
617 b := it.items
618 it.items = nil
619 return b
620 }