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

package cognitoidentityprovider

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

// Lists all replicas for a user pool, including both primary and secondary
// replicas. We recommend using pagination to ensure that the operation returns
// quickly and successfully.
//
// Amazon Cognito evaluates Identity and Access Management (IAM) policies in
// requests for this API operation. For this operation, you must use IAM
// credentials to authorize requests, and you must grant yourself the corresponding
// IAM permission in a policy.
//
// # Learn more
//
// [Signing Amazon Web Services API Requests]
//
// [Using the Amazon Cognito user pools API and user pool endpoints]
//
// [Using the Amazon Cognito user pools API and user pool endpoints]: https://docs.aws.amazon.com/cognito/latest/developerguide/user-pools-API-operations.html
// [Signing Amazon Web Services API Requests]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-signing.html
func (c *Client) ListUserPoolReplicas(ctx context.Context, params *ListUserPoolReplicasInput, optFns ...func(*Options)) (*ListUserPoolReplicasOutput, error) {
	if params == nil {
		params = &ListUserPoolReplicasInput{}
	}

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

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

type ListUserPoolReplicasInput struct {

	// The ID of the user pool for which to list replicas.
	//
	// This member is required.
	UserPoolId *string

	// A pagination token for retrieving the next page of results. If this parameter
	// is omitted, the operation returns the first page of results.
	NextToken *string

	noSmithyDocumentSerde
}

type ListUserPoolReplicasOutput struct {

	// A pagination token for retrieving the next page of results. If this value is
	// null, there are no more results to retrieve.
	NextToken *string

	// A list of user pool replicas, including information about their status, role,
	// and Region.
	UserPoolReplicas []types.UserPoolReplicaType

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

	noSmithyDocumentSerde
}

func (c *Client) addOperationListUserPoolReplicasMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsAwsjson11_serializeOpListUserPoolReplicas{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListUserPoolReplicas{}, 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 = addOpListUserPoolReplicasValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "ListUserPoolReplicas"), 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
}
