// 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"
)

// Renews an [eligible ACM certificate]. In order to renew your Amazon Web Services Private CA certificates
// with ACM, you must first [grant the ACM service principal permission to do so]. For more information, see [Testing Managed Renewal] in the ACM User Guide.
//
// [Testing Managed Renewal]: https://docs.aws.amazon.com/acm/latest/userguide/managed-renewal.html
// [grant the ACM service principal permission to do so]: https://docs.aws.amazon.com/privateca/latest/userguide/assign-permissions.html#PcaPermissions
// [eligible ACM certificate]: https://docs.aws.amazon.com/acm/latest/userguide/managed-renewal.html
func (c *Client) RenewCertificate(ctx context.Context, params *RenewCertificateInput, optFns ...func(*Options)) (*RenewCertificateOutput, error) {
	if params == nil {
		params = &RenewCertificateInput{}
	}

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

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

type RenewCertificateInput struct {

	// String that contains the ARN of the ACM certificate to be renewed. 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 *RenewCertificateInput) bindEndpointParams(p *EndpointParameters) {

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

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

	noSmithyDocumentSerde
}

func (c *Client) addOperationRenewCertificateMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsAwsjson11_serializeOpRenewCertificate{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpRenewCertificate{}, 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 = addOpRenewCertificateValidationMiddleware(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
}
