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

package cloudtrail

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

// Retrieves the current event configuration settings for the specified event data
// store or trail. The response includes maximum event size configuration, the
// context key selectors configured for the event data store, and any aggregation
// settings configured for the trail.
func (c *Client) GetEventConfiguration(ctx context.Context, params *GetEventConfigurationInput, optFns ...func(*Options)) (*GetEventConfigurationOutput, error) {
	if params == nil {
		params = &GetEventConfigurationInput{}
	}

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

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

type GetEventConfigurationInput struct {

	// The Amazon Resource Name (ARN) or ID suffix of the ARN of the event data store
	// for which you want to retrieve event configuration settings.
	EventDataStore *string

	// The name of the trail for which you want to retrieve event configuration
	// settings.
	TrailName *string

	noSmithyDocumentSerde
}

type GetEventConfigurationOutput struct {

	// The list of aggregation configurations that are configured for the trail.
	AggregationConfigurations []types.AggregationConfiguration

	// The list of context key selectors that are configured for the event data store.
	ContextKeySelectors []types.ContextKeySelector

	// The Amazon Resource Name (ARN) or ID suffix of the ARN of the event data store
	// for which the event configuration settings are returned.
	EventDataStoreArn *string

	// The maximum allowed size for events stored in the specified event data store.
	MaxEventSize types.MaxEventSize

	// The Amazon Resource Name (ARN) of the trail for which the event configuration
	// settings are returned.
	TrailARN *string

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

	noSmithyDocumentSerde
}

func (c *Client) addOperationGetEventConfigurationMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
		return err
	}
	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetEventConfiguration{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetEventConfiguration{}, middleware.After)
	if err != nil {
		return err
	}
	if err := addProtocolFinalizerMiddlewares(stack, options, "GetEventConfiguration"); err != nil {
		return fmt.Errorf("add protocol finalizers: %v", err)
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addSetLoggerMiddleware(stack, options); err != nil {
		return err
	}
	if err = addClientRequestID(stack); 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 = addRetry(stack, options); err != nil {
		return err
	}
	if err = addRawResponseToMetadata(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack); err != nil {
		return err
	}
	if err = addSpanRetryLoop(stack, options); err != nil {
		return err
	}
	if err = addClientUserAgent(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 = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
		return err
	}
	if err = addTimeOffsetBuild(stack, c); err != nil {
		return err
	}
	if err = addUserAgentRetryMode(stack, options); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetEventConfiguration(options.Region), middleware.Before); err != nil {
		return err
	}
	if err = addRecursionDetection(stack); 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 = addInterceptBeforeRetryLoop(stack, options); err != nil {
		return err
	}
	if err = addInterceptAttempt(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}

func newServiceMetadataMiddleware_opGetEventConfiguration(region string) *awsmiddleware.RegisterServiceMetadata {
	return &awsmiddleware.RegisterServiceMetadata{
		Region:        region,
		ServiceID:     ServiceID,
		OperationName: "GetEventConfiguration",
	}
}
