// Code generated by "internal/generate/listpages/main.go -ListOps=DescribeACLs,DescribeClusters,DescribeParameterGroups,DescribeSnapshots,DescribeSubnetGroups,DescribeUsers"; DO NOT EDIT.

package memorydb

import (
	"context"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/memorydb"
)

func describeACLsPages(conn *memorydb.MemoryDB, input *memorydb.DescribeACLsInput, fn func(*memorydb.DescribeACLsOutput, bool) bool) error {
	return describeACLsPagesWithContext(context.Background(), conn, input, fn)
}

func describeACLsPagesWithContext(ctx context.Context, conn *memorydb.MemoryDB, input *memorydb.DescribeACLsInput, fn func(*memorydb.DescribeACLsOutput, bool) bool) error {
	for {
		output, err := conn.DescribeACLsWithContext(ctx, input)
		if err != nil {
			return err
		}

		lastPage := aws.StringValue(output.NextToken) == ""
		if !fn(output, lastPage) || lastPage {
			break
		}

		input.NextToken = output.NextToken
	}
	return nil
}

func describeClustersPages(conn *memorydb.MemoryDB, input *memorydb.DescribeClustersInput, fn func(*memorydb.DescribeClustersOutput, bool) bool) error {
	return describeClustersPagesWithContext(context.Background(), conn, input, fn)
}

func describeClustersPagesWithContext(ctx context.Context, conn *memorydb.MemoryDB, input *memorydb.DescribeClustersInput, fn func(*memorydb.DescribeClustersOutput, bool) bool) error {
	for {
		output, err := conn.DescribeClustersWithContext(ctx, input)
		if err != nil {
			return err
		}

		lastPage := aws.StringValue(output.NextToken) == ""
		if !fn(output, lastPage) || lastPage {
			break
		}

		input.NextToken = output.NextToken
	}
	return nil
}

func describeParameterGroupsPages(conn *memorydb.MemoryDB, input *memorydb.DescribeParameterGroupsInput, fn func(*memorydb.DescribeParameterGroupsOutput, bool) bool) error {
	return describeParameterGroupsPagesWithContext(context.Background(), conn, input, fn)
}

func describeParameterGroupsPagesWithContext(ctx context.Context, conn *memorydb.MemoryDB, input *memorydb.DescribeParameterGroupsInput, fn func(*memorydb.DescribeParameterGroupsOutput, bool) bool) error {
	for {
		output, err := conn.DescribeParameterGroupsWithContext(ctx, input)
		if err != nil {
			return err
		}

		lastPage := aws.StringValue(output.NextToken) == ""
		if !fn(output, lastPage) || lastPage {
			break
		}

		input.NextToken = output.NextToken
	}
	return nil
}

func describeSnapshotsPages(conn *memorydb.MemoryDB, input *memorydb.DescribeSnapshotsInput, fn func(*memorydb.DescribeSnapshotsOutput, bool) bool) error {
	return describeSnapshotsPagesWithContext(context.Background(), conn, input, fn)
}

func describeSnapshotsPagesWithContext(ctx context.Context, conn *memorydb.MemoryDB, input *memorydb.DescribeSnapshotsInput, fn func(*memorydb.DescribeSnapshotsOutput, bool) bool) error {
	for {
		output, err := conn.DescribeSnapshotsWithContext(ctx, input)
		if err != nil {
			return err
		}

		lastPage := aws.StringValue(output.NextToken) == ""
		if !fn(output, lastPage) || lastPage {
			break
		}

		input.NextToken = output.NextToken
	}
	return nil
}

func describeSubnetGroupsPages(conn *memorydb.MemoryDB, input *memorydb.DescribeSubnetGroupsInput, fn func(*memorydb.DescribeSubnetGroupsOutput, bool) bool) error {
	return describeSubnetGroupsPagesWithContext(context.Background(), conn, input, fn)
}

func describeSubnetGroupsPagesWithContext(ctx context.Context, conn *memorydb.MemoryDB, input *memorydb.DescribeSubnetGroupsInput, fn func(*memorydb.DescribeSubnetGroupsOutput, bool) bool) error {
	for {
		output, err := conn.DescribeSubnetGroupsWithContext(ctx, input)
		if err != nil {
			return err
		}

		lastPage := aws.StringValue(output.NextToken) == ""
		if !fn(output, lastPage) || lastPage {
			break
		}

		input.NextToken = output.NextToken
	}
	return nil
}

func describeUsersPages(conn *memorydb.MemoryDB, input *memorydb.DescribeUsersInput, fn func(*memorydb.DescribeUsersOutput, bool) bool) error {
	return describeUsersPagesWithContext(context.Background(), conn, input, fn)
}

func describeUsersPagesWithContext(ctx context.Context, conn *memorydb.MemoryDB, input *memorydb.DescribeUsersInput, fn func(*memorydb.DescribeUsersOutput, bool) bool) error {
	for {
		output, err := conn.DescribeUsersWithContext(ctx, input)
		if err != nil {
			return err
		}

		lastPage := aws.StringValue(output.NextToken) == ""
		if !fn(output, lastPage) || lastPage {
			break
		}

		input.NextToken = output.NextToken
	}
	return nil
}
