...

Source file src/cloud.google.com/go/kms/inventory/apiv1/auxiliary.go

Documentation: cloud.google.com/go/kms/inventory/apiv1

     1  // Copyright 2024 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 inventory
    18  
    19  import (
    20  	kmspb "cloud.google.com/go/kms/apiv1/kmspb"
    21  	inventorypb "cloud.google.com/go/kms/inventory/apiv1/inventorypb"
    22  	"google.golang.org/api/iterator"
    23  )
    24  
    25  // CryptoKeyIterator manages a stream of *kmspb.CryptoKey.
    26  type CryptoKeyIterator struct {
    27  	items    []*kmspb.CryptoKey
    28  	pageInfo *iterator.PageInfo
    29  	nextFunc func() error
    30  
    31  	// Response is the raw response for the current page.
    32  	// It must be cast to the RPC response type.
    33  	// Calling Next() or InternalFetch() updates this value.
    34  	Response interface{}
    35  
    36  	// InternalFetch is for use by the Google Cloud Libraries only.
    37  	// It is not part of the stable interface of this package.
    38  	//
    39  	// InternalFetch returns results from a single call to the underlying RPC.
    40  	// The number of results is no greater than pageSize.
    41  	// If there are no more results, nextPageToken is empty and err is nil.
    42  	InternalFetch func(pageSize int, pageToken string) (results []*kmspb.CryptoKey, nextPageToken string, err error)
    43  }
    44  
    45  // PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
    46  func (it *CryptoKeyIterator) PageInfo() *iterator.PageInfo {
    47  	return it.pageInfo
    48  }
    49  
    50  // Next returns the next result. Its second return value is iterator.Done if there are no more
    51  // results. Once Next returns Done, all subsequent calls will return Done.
    52  func (it *CryptoKeyIterator) Next() (*kmspb.CryptoKey, error) {
    53  	var item *kmspb.CryptoKey
    54  	if err := it.nextFunc(); err != nil {
    55  		return item, err
    56  	}
    57  	item = it.items[0]
    58  	it.items = it.items[1:]
    59  	return item, nil
    60  }
    61  
    62  func (it *CryptoKeyIterator) bufLen() int {
    63  	return len(it.items)
    64  }
    65  
    66  func (it *CryptoKeyIterator) takeBuf() interface{} {
    67  	b := it.items
    68  	it.items = nil
    69  	return b
    70  }
    71  
    72  // ProtectedResourceIterator manages a stream of *inventorypb.ProtectedResource.
    73  type ProtectedResourceIterator struct {
    74  	items    []*inventorypb.ProtectedResource
    75  	pageInfo *iterator.PageInfo
    76  	nextFunc func() error
    77  
    78  	// Response is the raw response for the current page.
    79  	// It must be cast to the RPC response type.
    80  	// Calling Next() or InternalFetch() updates this value.
    81  	Response interface{}
    82  
    83  	// InternalFetch is for use by the Google Cloud Libraries only.
    84  	// It is not part of the stable interface of this package.
    85  	//
    86  	// InternalFetch returns results from a single call to the underlying RPC.
    87  	// The number of results is no greater than pageSize.
    88  	// If there are no more results, nextPageToken is empty and err is nil.
    89  	InternalFetch func(pageSize int, pageToken string) (results []*inventorypb.ProtectedResource, nextPageToken string, err error)
    90  }
    91  
    92  // PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
    93  func (it *ProtectedResourceIterator) PageInfo() *iterator.PageInfo {
    94  	return it.pageInfo
    95  }
    96  
    97  // Next returns the next result. Its second return value is iterator.Done if there are no more
    98  // results. Once Next returns Done, all subsequent calls will return Done.
    99  func (it *ProtectedResourceIterator) Next() (*inventorypb.ProtectedResource, error) {
   100  	var item *inventorypb.ProtectedResource
   101  	if err := it.nextFunc(); err != nil {
   102  		return item, err
   103  	}
   104  	item = it.items[0]
   105  	it.items = it.items[1:]
   106  	return item, nil
   107  }
   108  
   109  func (it *ProtectedResourceIterator) bufLen() int {
   110  	return len(it.items)
   111  }
   112  
   113  func (it *ProtectedResourceIterator) takeBuf() interface{} {
   114  	b := it.items
   115  	it.items = nil
   116  	return b
   117  }
   118  

View as plain text