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

package mq

import (
	"context"

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

func describeBrokerInstanceOptionsPages(conn *mq.MQ, input *mq.DescribeBrokerInstanceOptionsInput, fn func(*mq.DescribeBrokerInstanceOptionsOutput, bool) bool) error {
	return describeBrokerInstanceOptionsPagesWithContext(context.Background(), conn, input, fn)
}

func describeBrokerInstanceOptionsPagesWithContext(ctx context.Context, conn *mq.MQ, input *mq.DescribeBrokerInstanceOptionsInput, fn func(*mq.DescribeBrokerInstanceOptionsOutput, bool) bool) error {
	for {
		output, err := conn.DescribeBrokerInstanceOptionsWithContext(ctx, input)
		if err != nil {
			return err
		}

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

		input.NextToken = output.NextToken
	}
	return nil
}
