// Code generated by "internal/generate/listpages/main.go -ListOps=DescribeQueryDefinitions,DescribeResourcePolicies"; 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
}
func describeResourcePoliciesPages(conn *cloudwatchlogs.CloudWatchLogs, input *cloudwatchlogs.DescribeResourcePoliciesInput, fn func(*cloudwatchlogs.DescribeResourcePoliciesOutput, bool) bool) error {
	return describeResourcePoliciesPagesWithContext(context.Background(), conn, input, fn)
}

func describeResourcePoliciesPagesWithContext(ctx context.Context, conn *cloudwatchlogs.CloudWatchLogs, input *cloudwatchlogs.DescribeResourcePoliciesInput, fn func(*cloudwatchlogs.DescribeResourcePoliciesOutput, bool) bool) error {
	for {
		output, err := conn.DescribeResourcePoliciesWithContext(ctx, input)
		if err != nil {
			return err
		}

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

		input.NextToken = output.NextToken
	}
	return nil
}
