// Code generated by smithy-go-codegen DO NOT EDIT.

package cloudwatchevents

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/service/cloudwatchevents/types"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Retrieves a list of API destination in the account in the current Region.
func (c *Client) ListApiDestinations(ctx context.Context, params *ListApiDestinationsInput, optFns ...func(*Options)) (*ListApiDestinationsOutput, error) {
	if params == nil {
		params = &ListApiDestinationsInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "ListApiDestinations", params, optFns, c.addOperationListApiDestinationsMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*ListApiDestinationsOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type ListApiDestinationsInput struct {

	// The ARN of the connection specified for the API destination.
	ConnectionArn *string

	// The maximum number of API destinations to include in the response.
	Limit *int32

	// A name prefix to filter results returned. Only API destinations with a name
	// that starts with the prefix are returned.
	NamePrefix *string

	// The token returned by a previous call to retrieve the next set of results.
	NextToken *string

	noSmithyDocumentSerde
}

type ListApiDestinationsOutput struct {

	// An array of ApiDestination objects that include information about an API
	// destination.
	ApiDestinations []types.ApiDestination

	// A token you can use in a subsequent request to retrieve the next set of results.
	NextToken *string

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationListApiDestinationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsAwsjson11_serializeOpListApiDestinations{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListApiDestinations{}, middleware.After)
	if err != nil {
		return err
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addComputeContentLength(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack, options); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListApiDestinations"), middleware.Before); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
