// Code generated by "internal/generate/listpages/main.go -ListOps=DescribeQueryDefinitions"; DO NOT EDIT.

package logs

import (
	"context"

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

func describeQueryDefinitionsPages(conn *cloudwatchlogs.CloudWatchLogs, input *cloudwatchlogs.DescribeQueryDefinitionsInput, fn func(*cloudwatchlogs.DescribeQueryDefinitionsOutput, bool) bool) error {
	return describeQueryDefinitionsPagesWithContext(context.Background(), conn, input, fn)
}

func describeQueryDefinitionsPagesWithContext(ctx context.Context, conn *cloudwatchlogs.CloudWatchLogs, input *cloudwatchlogs.DescribeQueryDefinitionsInput, fn func(*cloudwatchlogs.DescribeQueryDefinitionsOutput, bool) bool) error {
	for {
		output, err := conn.DescribeQueryDefinitionsWithContext(ctx, input)
		if err != nil {
			return err
		}

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

		input.NextToken = output.NextToken
	}
	return nil
}
