// Code generated by "internal/generate/listpages/main.go -ListOps=DescribeSpotFleetInstances,DescribeSpotFleetRequestHistory,DescribeVpcEndpointServices"; DO NOT EDIT.

package ec2

import (
	"context"

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

func describeSpotFleetInstancesPages(conn *ec2.EC2, input *ec2.DescribeSpotFleetInstancesInput, fn func(*ec2.DescribeSpotFleetInstancesOutput, bool) bool) error {
	return describeSpotFleetInstancesPagesWithContext(context.Background(), conn, input, fn)
}

func describeSpotFleetInstancesPagesWithContext(ctx context.Context, conn *ec2.EC2, input *ec2.DescribeSpotFleetInstancesInput, fn func(*ec2.DescribeSpotFleetInstancesOutput, bool) bool) error {
	for {
		output, err := conn.DescribeSpotFleetInstancesWithContext(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 describeSpotFleetRequestHistoryPages(conn *ec2.EC2, input *ec2.DescribeSpotFleetRequestHistoryInput, fn func(*ec2.DescribeSpotFleetRequestHistoryOutput, bool) bool) error {
	return describeSpotFleetRequestHistoryPagesWithContext(context.Background(), conn, input, fn)
}

func describeSpotFleetRequestHistoryPagesWithContext(ctx context.Context, conn *ec2.EC2, input *ec2.DescribeSpotFleetRequestHistoryInput, fn func(*ec2.DescribeSpotFleetRequestHistoryOutput, bool) bool) error {
	for {
		output, err := conn.DescribeSpotFleetRequestHistoryWithContext(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 describeVPCEndpointServicesPages(conn *ec2.EC2, input *ec2.DescribeVpcEndpointServicesInput, fn func(*ec2.DescribeVpcEndpointServicesOutput, bool) bool) error {
	return describeVPCEndpointServicesPagesWithContext(context.Background(), conn, input, fn)
}

func describeVPCEndpointServicesPagesWithContext(ctx context.Context, conn *ec2.EC2, input *ec2.DescribeVpcEndpointServicesInput, fn func(*ec2.DescribeVpcEndpointServicesOutput, bool) bool) error {
	for {
		output, err := conn.DescribeVpcEndpointServicesWithContext(ctx, input)
		if err != nil {
			return err
		}

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

		input.NextToken = output.NextToken
	}
	return nil
}
