2019-03-26 08:48:37 -04:00
|
|
|
// Code generated by sdkgen. DO NOT EDIT.
|
|
|
|
|
2019-04-11 18:29:34 -04:00
|
|
|
//nolint
|
2019-03-26 08:48:37 -04:00
|
|
|
package redis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
2020-06-09 09:50:34 -04:00
|
|
|
redis "github.com/yandex-cloud/go-genproto/yandex/cloud/mdb/redis/v1"
|
2019-03-26 08:48:37 -04:00
|
|
|
)
|
|
|
|
|
2019-04-11 18:29:34 -04:00
|
|
|
//revive:disable
|
|
|
|
|
2019-03-26 08:48:37 -04:00
|
|
|
// ResourcePresetServiceClient is a redis.ResourcePresetServiceClient with
|
|
|
|
// lazy GRPC connection initialization.
|
|
|
|
type ResourcePresetServiceClient struct {
|
|
|
|
getConn func(ctx context.Context) (*grpc.ClientConn, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get implements redis.ResourcePresetServiceClient
|
|
|
|
func (c *ResourcePresetServiceClient) Get(ctx context.Context, in *redis.GetResourcePresetRequest, opts ...grpc.CallOption) (*redis.ResourcePreset, error) {
|
|
|
|
conn, err := c.getConn(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return redis.NewResourcePresetServiceClient(conn).Get(ctx, in, opts...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// List implements redis.ResourcePresetServiceClient
|
|
|
|
func (c *ResourcePresetServiceClient) List(ctx context.Context, in *redis.ListResourcePresetsRequest, opts ...grpc.CallOption) (*redis.ListResourcePresetsResponse, error) {
|
|
|
|
conn, err := c.getConn(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return redis.NewResourcePresetServiceClient(conn).List(ctx, in, opts...)
|
|
|
|
}
|
2020-06-09 09:50:34 -04:00
|
|
|
|
|
|
|
type ResourcePresetIterator struct {
|
|
|
|
ctx context.Context
|
|
|
|
opts []grpc.CallOption
|
|
|
|
|
|
|
|
err error
|
|
|
|
started bool
|
|
|
|
|
|
|
|
client *ResourcePresetServiceClient
|
|
|
|
request *redis.ListResourcePresetsRequest
|
|
|
|
|
|
|
|
items []*redis.ResourcePreset
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ResourcePresetServiceClient) ResourcePresetIterator(ctx context.Context, opts ...grpc.CallOption) *ResourcePresetIterator {
|
|
|
|
return &ResourcePresetIterator{
|
|
|
|
ctx: ctx,
|
|
|
|
opts: opts,
|
|
|
|
client: c,
|
|
|
|
request: &redis.ListResourcePresetsRequest{
|
|
|
|
PageSize: 1000,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (it *ResourcePresetIterator) Next() bool {
|
|
|
|
if it.err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if len(it.items) > 1 {
|
|
|
|
it.items[0] = nil
|
|
|
|
it.items = it.items[1:]
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
it.items = nil // consume last item, if any
|
|
|
|
|
|
|
|
if it.started && it.request.PageToken == "" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
it.started = true
|
|
|
|
|
|
|
|
response, err := it.client.List(it.ctx, it.request, it.opts...)
|
|
|
|
it.err = err
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
it.items = response.ResourcePresets
|
|
|
|
it.request.PageToken = response.NextPageToken
|
|
|
|
return len(it.items) > 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (it *ResourcePresetIterator) Value() *redis.ResourcePreset {
|
|
|
|
if len(it.items) == 0 {
|
|
|
|
panic("calling Value on empty iterator")
|
|
|
|
}
|
|
|
|
return it.items[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
func (it *ResourcePresetIterator) Error() error {
|
|
|
|
return it.err
|
|
|
|
}
|