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

package cleanrooms

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

// Retrieves the analysis rule for an intermediate table.
func (c *Client) GetIntermediateTableAnalysisRule(ctx context.Context, params *GetIntermediateTableAnalysisRuleInput, optFns ...func(*Options)) (*GetIntermediateTableAnalysisRuleOutput, error) {
	if params == nil {
		params = &GetIntermediateTableAnalysisRuleInput{}
	}

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

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

type GetIntermediateTableAnalysisRuleInput struct {

	// The type of analysis rule to retrieve. Currently, only CUSTOM is supported.
	//
	// This member is required.
	AnalysisRuleType types.IntermediateTableAnalysisRuleType

	// The unique identifier of the intermediate table for which to retrieve the
	// analysis rule.
	//
	// This member is required.
	IntermediateTableIdentifier *string

	// The unique identifier of the membership that contains the intermediate table.
	//
	// This member is required.
	MembershipIdentifier *string

	noSmithyDocumentSerde
}

type GetIntermediateTableAnalysisRuleOutput struct {

	// The analysis rule for the intermediate table.
	//
	// This member is required.
	AnalysisRule *types.IntermediateTableAnalysisRule

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

	noSmithyDocumentSerde
}

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