1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package acmpca
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/smithy-go/middleware"
10	smithyhttp "github.com/aws/smithy-go/transport/http"
11)
12
13// Restores a certificate authority (CA) that is in the DELETED state. You can
14// restore a CA during the period that you defined in the
15// PermanentDeletionTimeInDays parameter of the DeleteCertificateAuthority
16// (https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_DeleteCertificateAuthority.html)
17// action. Currently, you can specify 7 to 30 days. If you did not specify a
18// PermanentDeletionTimeInDays value, by default you can restore the CA at any time
19// in a 30 day period. You can check the time remaining in the restoration period
20// of a private CA in the DELETED state by calling the DescribeCertificateAuthority
21// (https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_DescribeCertificateAuthority.html)
22// or ListCertificateAuthorities
23// (https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_ListCertificateAuthorities.html)
24// actions. The status of a restored CA is set to its pre-deletion status when the
25// RestoreCertificateAuthority action returns. To change its status to ACTIVE, call
26// the UpdateCertificateAuthority
27// (https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_UpdateCertificateAuthority.html)
28// action. If the private CA was in the PENDING_CERTIFICATE state at deletion, you
29// must use the ImportCertificateAuthorityCertificate
30// (https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_ImportCertificateAuthorityCertificate.html)
31// action to import a certificate authority into the private CA before it can be
32// activated. You cannot restore a CA after the restoration period has ended.
33func (c *Client) RestoreCertificateAuthority(ctx context.Context, params *RestoreCertificateAuthorityInput, optFns ...func(*Options)) (*RestoreCertificateAuthorityOutput, error) {
34	if params == nil {
35		params = &RestoreCertificateAuthorityInput{}
36	}
37
38	result, metadata, err := c.invokeOperation(ctx, "RestoreCertificateAuthority", params, optFns, addOperationRestoreCertificateAuthorityMiddlewares)
39	if err != nil {
40		return nil, err
41	}
42
43	out := result.(*RestoreCertificateAuthorityOutput)
44	out.ResultMetadata = metadata
45	return out, nil
46}
47
48type RestoreCertificateAuthorityInput struct {
49
50	// The Amazon Resource Name (ARN) that was returned when you called the
51	// CreateCertificateAuthority
52	// (https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CreateCertificateAuthority.html)
53	// action. This must be of the form:
54	// arn:aws:acm-pca:region:account:certificate-authority/12345678-1234-1234-1234-123456789012
55	//
56	// This member is required.
57	CertificateAuthorityArn *string
58}
59
60type RestoreCertificateAuthorityOutput struct {
61	// Metadata pertaining to the operation's result.
62	ResultMetadata middleware.Metadata
63}
64
65func addOperationRestoreCertificateAuthorityMiddlewares(stack *middleware.Stack, options Options) (err error) {
66	err = stack.Serialize.Add(&awsAwsjson11_serializeOpRestoreCertificateAuthority{}, middleware.After)
67	if err != nil {
68		return err
69	}
70	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpRestoreCertificateAuthority{}, middleware.After)
71	if err != nil {
72		return err
73	}
74	if err = addSetLoggerMiddleware(stack, options); err != nil {
75		return err
76	}
77	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
78		return err
79	}
80	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
81		return err
82	}
83	if err = addResolveEndpointMiddleware(stack, options); err != nil {
84		return err
85	}
86	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
87		return err
88	}
89	if err = addRetryMiddlewares(stack, options); err != nil {
90		return err
91	}
92	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
93		return err
94	}
95	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
96		return err
97	}
98	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
99		return err
100	}
101	if err = addClientUserAgent(stack); err != nil {
102		return err
103	}
104	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
105		return err
106	}
107	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
108		return err
109	}
110	if err = addOpRestoreCertificateAuthorityValidationMiddleware(stack); err != nil {
111		return err
112	}
113	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opRestoreCertificateAuthority(options.Region), middleware.Before); err != nil {
114		return err
115	}
116	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
117		return err
118	}
119	if err = addResponseErrorMiddleware(stack); err != nil {
120		return err
121	}
122	if err = addRequestResponseLogging(stack, options); err != nil {
123		return err
124	}
125	return nil
126}
127
128func newServiceMetadataMiddleware_opRestoreCertificateAuthority(region string) *awsmiddleware.RegisterServiceMetadata {
129	return &awsmiddleware.RegisterServiceMetadata{
130		Region:        region,
131		ServiceID:     ServiceID,
132		SigningName:   "acm-pca",
133		OperationName: "RestoreCertificateAuthority",
134	}
135}
136