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

package appconfig

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

// Retrieves information about an experiment definition.
func (c *Client) GetExperimentDefinition(ctx context.Context, params *GetExperimentDefinitionInput, optFns ...func(*Options)) (*GetExperimentDefinitionOutput, error) {
	if params == nil {
		params = &GetExperimentDefinitionInput{}
	}

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

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

type GetExperimentDefinitionInput struct {

	// The application ID or name.
	//
	// This member is required.
	ApplicationIdentifier *string

	// The experiment definition ID or name.
	//
	// This member is required.
	ExperimentDefinitionIdentifier *string

	noSmithyDocumentSerde
}

// Describes an experiment definition, including the target audience, feature
// flag, treatments, and current status.
type GetExperimentDefinitionOutput struct {

	// The application ID.
	ApplicationId *string

	// A description of the intended audience for the experiment.
	AudienceDescription *string

	// The rule that defines which users are eligible to be assigned to treatments.
	AudienceRule *string

	// The configuration profile ID associated with the experiment.
	ConfigurationProfileId *string

	// The control treatment used as the baseline for comparison.
	Control *types.Treatment

	// The date and time the experiment definition was created, in ISO 8601 format.
	CreatedAt *time.Time

	// The environment ID where the experiment runs.
	EnvironmentId *string

	// The key of the feature flag used by the experiment.
	FlagKey *string

	// The hypothesis that the experiment is designed to validate.
	Hypothesis *string

	// The experiment definition ID.
	Id *string

	// The Amazon Resource Name (ARN) of the KMS key used to encrypt experiment data.
	KmsKeyIdentifier *string

	// The conditions under which the winning treatment should be launched.
	LaunchCriteria *string

	// The name of the experiment definition.
	Name *string

	// The current status of the experiment definition. Valid values: ACTIVE , IDLE ,
	// ARCHIVED .
	Status types.ExperimentDefinitionStatus

	// The list of treatments defined for the experiment.
	Treatments []types.Treatment

	// The date and time the experiment definition was last updated, in ISO 8601
	// format.
	UpdatedAt *time.Time

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

	noSmithyDocumentSerde
}

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