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

package ec2

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

// Suppresses application status checks for the specified instances. While
// suppressed, health checks continue to run but do not affect the instance-level
// application status. The following rules apply:
//
//   - Maximum 100 instance IDs per request.
//
//   - Use DisableApplicationStatusCheckSuppression to resume normal health check
//     reporting.
//
//   - If you do not specify DurationSeconds , suppression continues indefinitely
//     until you call DisableApplicationStatusCheckSuppression .
func (c *Client) EnableApplicationStatusCheckSuppression(ctx context.Context, params *EnableApplicationStatusCheckSuppressionInput, optFns ...func(*Options)) (*EnableApplicationStatusCheckSuppressionOutput, error) {
	if params == nil {
		params = &EnableApplicationStatusCheckSuppressionInput{}
	}

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

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

type EnableApplicationStatusCheckSuppressionInput struct {

	// Unique, case-sensitive identifier that you provide to ensure the idempotency of
	// the request. For more information, see [Ensuring idempotency].
	//
	// [Ensuring idempotency]: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html
	ClientToken *string

	// Checks whether you have the required permissions for the operation, without
	// actually making the request, and provides an error response. If you have the
	// required permissions, the error response is DryRunOperation . Otherwise, it is
	// UnauthorizedOperation .
	DryRun *bool

	// The duration, in seconds, for which to suppress application status checks. If
	// omitted, the application status check is suppressed indefinitely until you call
	// DisableApplicationStatusCheckSuppression .
	DurationSeconds *int32

	// The IDs of the instances for which to suppress application status checks.
	InstanceIds []string

	noSmithyDocumentSerde
}

type EnableApplicationStatusCheckSuppressionOutput struct {

	// The instances for which suppression was successfully enabled.
	SuccessfulResults []types.SuccessfulSuppressionResponseObject

	// The instances for which suppression failed to be enabled.
	UnsuccessfulResults []types.UnsuccessfulSuppressionResponseObject

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

	noSmithyDocumentSerde
}

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

type idempotencyToken_initializeOpEnableApplicationStatusCheckSuppression struct {
	tokenProvider IdempotencyTokenProvider
}

func (*idempotencyToken_initializeOpEnableApplicationStatusCheckSuppression) ID() string {
	return "OperationIdempotencyTokenAutoFill"
}

func (m *idempotencyToken_initializeOpEnableApplicationStatusCheckSuppression) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
	if m.tokenProvider == nil {
		return next.HandleInitialize(ctx, in)
	}

	input, ok := in.Parameters.(*EnableApplicationStatusCheckSuppressionInput)
	if !ok {
		return out, metadata, fmt.Errorf("expected middleware input to be of type *EnableApplicationStatusCheckSuppressionInput ")
	}

	if input.ClientToken == nil {
		t, err := m.tokenProvider.GetIdempotencyToken()
		if err != nil {
			return out, metadata, err
		}
		input.ClientToken = &t
	}
	return next.HandleInitialize(ctx, in)
}
func addIdempotencyToken_opEnableApplicationStatusCheckSuppressionMiddleware(stack *middleware.Stack, cfg Options) error {
	return stack.Initialize.Add(&idempotencyToken_initializeOpEnableApplicationStatusCheckSuppression{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
}
