// Code generated by "internal/generate/listpages/main.go -ListOps=DescribeInstanceRefreshes,DescribeLoadBalancers,DescribeLoadBalancerTargetGroups,DescribeWarmPool"; DO NOT EDIT.

package autoscaling

import (
	"context"

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

func describeInstanceRefreshesPages(conn *autoscaling.AutoScaling, input *autoscaling.DescribeInstanceRefreshesInput, fn func(*autoscaling.DescribeInstanceRefreshesOutput, bool) bool) error {
	return describeInstanceRefreshesPagesWithContext(context.Background(), conn, input, fn)
}

func describeInstanceRefreshesPagesWithContext(ctx context.Context, conn *autoscaling.AutoScaling, input *autoscaling.DescribeInstanceRefreshesInput, fn func(*autoscaling.DescribeInstanceRefreshesOutput, bool) bool) error {
	for {
		output, err := conn.DescribeInstanceRefreshesWithContext(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 describeLoadBalancerTargetGroupsPages(conn *autoscaling.AutoScaling, input *autoscaling.DescribeLoadBalancerTargetGroupsInput, fn func(*autoscaling.DescribeLoadBalancerTargetGroupsOutput, bool) bool) error {
	return describeLoadBalancerTargetGroupsPagesWithContext(context.Background(), conn, input, fn)
}

func describeLoadBalancerTargetGroupsPagesWithContext(ctx context.Context, conn *autoscaling.AutoScaling, input *autoscaling.DescribeLoadBalancerTargetGroupsInput, fn func(*autoscaling.DescribeLoadBalancerTargetGroupsOutput, bool) bool) error {
	for {
		output, err := conn.DescribeLoadBalancerTargetGroupsWithContext(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 describeLoadBalancersPages(conn *autoscaling.AutoScaling, input *autoscaling.DescribeLoadBalancersInput, fn func(*autoscaling.DescribeLoadBalancersOutput, bool) bool) error {
	return describeLoadBalancersPagesWithContext(context.Background(), conn, input, fn)
}

func describeLoadBalancersPagesWithContext(ctx context.Context, conn *autoscaling.AutoScaling, input *autoscaling.DescribeLoadBalancersInput, fn func(*autoscaling.DescribeLoadBalancersOutput, bool) bool) error {
	for {
		output, err := conn.DescribeLoadBalancersWithContext(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 describeWarmPoolPages(conn *autoscaling.AutoScaling, input *autoscaling.DescribeWarmPoolInput, fn func(*autoscaling.DescribeWarmPoolOutput, bool) bool) error {
	return describeWarmPoolPagesWithContext(context.Background(), conn, input, fn)
}

func describeWarmPoolPagesWithContext(ctx context.Context, conn *autoscaling.AutoScaling, input *autoscaling.DescribeWarmPoolInput, fn func(*autoscaling.DescribeWarmPoolOutput, bool) bool) error {
	for {
		output, err := conn.DescribeWarmPoolWithContext(ctx, input)
		if err != nil {
			return err
		}

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

		input.NextToken = output.NextToken
	}
	return nil
}
