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

package acm

import (
	"context"
	"github.com/aws/smithy-go/middleware"
	"github.com/aws/smithy-go/ptr"
)

// Deletes a certificate and its associated private key. If this action succeeds,
// the certificate is not available for use by Amazon Web Services services
// integrated with ACM. Deleting a certificate is eventually consistent. The may be
// a short delay before the certificate no longer appears in the list that can be
// displayed by calling the ListCertificatesaction or be retrieved by calling the GetCertificate action.
//
// You cannot delete an ACM certificate that is being used by another Amazon Web
// Services service. To delete a certificate that is in use, you must first remove
// the certificate association using the console or the CLI for the associated
// service.
//
// Deleting a certificate issued by a private certificate authority (CA) has no
// effect on the CA. You will continue to be charged for the CA until it is
// deleted. For more information, see [Deleting Your Private CA]in the Private Certificate Authority User
// Guide.
//
// You cannot delete a certificate with a CertificateKeyPairOrigin of ACME . ACM
// automatically deletes these certificates 1 year after they expire.
//
// Deleting a certificate issued by a private certificate authority (CA) has no
// effect on the CA. You will continue to be charged for the CA until it is
// deleted. For more information, see [Deleting your private CA]in the Amazon Web Services Private
// Certificate Authority User Guide.
//
// [Deleting your private CA]: https://docs.aws.amazon.com/privateca/latest/userguide/PCADeleteCA.html
// [Deleting Your Private CA]: https://docs.aws.amazon.com/privateca/latest/userguide/PCADeleteCA.html
func (c *Client) DeleteCertificate(ctx context.Context, params *DeleteCertificateInput, optFns ...func(*Options)) (*DeleteCertificateOutput, error) {
	if params == nil {
		params = &DeleteCertificateInput{}
	}

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

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

type DeleteCertificateInput struct {

	// String that contains the ARN of the ACM certificate to be deleted. This must be
	// of the form:
	//
	//     arn:aws:acm:region:123456789012:certificate/12345678-1234-1234-1234-123456789012
	//
	// For more information about ARNs, see [Amazon Resource Names (ARNs)].
	//
	// [Amazon Resource Names (ARNs)]: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
	//
	// This member is required.
	CertificateArn *string

	noSmithyDocumentSerde
}

func (in *DeleteCertificateInput) bindEndpointParams(p *EndpointParameters) {

	p.ServiceType = ptr.String("ACM")
}

type DeleteCertificateOutput struct {
	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationDeleteCertificateMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsAwsjson11_serializeOpDeleteCertificate{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDeleteCertificate{}, middleware.After)
	if 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 = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpDeleteCertificateValidationMiddleware(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 = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
