{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CertificateManagerPCA.RestoreCertificateAuthority
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Restores a certificate authority (CA) that is in the @DELETED@ state.
-- You can restore a CA during the period that you defined in the
-- __PermanentDeletionTimeInDays__ parameter of the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_DeleteCertificateAuthority.html DeleteCertificateAuthority>
-- action. Currently, you can specify 7 to 30 days. If you did not specify
-- a __PermanentDeletionTimeInDays__ value, by default you can restore the
-- CA at any time in a 30 day period. You can check the time remaining in
-- the restoration period of a private CA in the @DELETED@ state by calling
-- the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_DescribeCertificateAuthority.html DescribeCertificateAuthority>
-- or
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_ListCertificateAuthorities.html ListCertificateAuthorities>
-- actions. The status of a restored CA is set to its pre-deletion status
-- when the __RestoreCertificateAuthority__ action returns. To change its
-- status to @ACTIVE@, call the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_UpdateCertificateAuthority.html UpdateCertificateAuthority>
-- action. If the private CA was in the @PENDING_CERTIFICATE@ state at
-- deletion, you must use the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_ImportCertificateAuthorityCertificate.html ImportCertificateAuthorityCertificate>
-- action to import a certificate authority into the private CA before it
-- can be activated. You cannot restore a CA after the restoration period
-- has ended.
module Amazonka.CertificateManagerPCA.RestoreCertificateAuthority
  ( -- * Creating a Request
    RestoreCertificateAuthority (..),
    newRestoreCertificateAuthority,

    -- * Request Lenses
    restoreCertificateAuthority_certificateAuthorityArn,

    -- * Destructuring the Response
    RestoreCertificateAuthorityResponse (..),
    newRestoreCertificateAuthorityResponse,
  )
where

import Amazonka.CertificateManagerPCA.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newRestoreCertificateAuthority' smart constructor.
data RestoreCertificateAuthority = RestoreCertificateAuthority'
  { -- | The Amazon Resource Name (ARN) that was returned when you called the
    -- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CreateCertificateAuthority.html CreateCertificateAuthority>
    -- action. This must be of the form:
    --
    -- @arn:aws:acm-pca:region:account:certificate-authority\/12345678-1234-1234-1234-123456789012 @
    RestoreCertificateAuthority -> Text
certificateAuthorityArn :: Prelude.Text
  }
  deriving (RestoreCertificateAuthority -> RestoreCertificateAuthority -> Bool
(RestoreCertificateAuthority
 -> RestoreCertificateAuthority -> Bool)
-> (RestoreCertificateAuthority
    -> RestoreCertificateAuthority -> Bool)
-> Eq RestoreCertificateAuthority
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreCertificateAuthority -> RestoreCertificateAuthority -> Bool
$c/= :: RestoreCertificateAuthority -> RestoreCertificateAuthority -> Bool
== :: RestoreCertificateAuthority -> RestoreCertificateAuthority -> Bool
$c== :: RestoreCertificateAuthority -> RestoreCertificateAuthority -> Bool
Prelude.Eq, ReadPrec [RestoreCertificateAuthority]
ReadPrec RestoreCertificateAuthority
Int -> ReadS RestoreCertificateAuthority
ReadS [RestoreCertificateAuthority]
(Int -> ReadS RestoreCertificateAuthority)
-> ReadS [RestoreCertificateAuthority]
-> ReadPrec RestoreCertificateAuthority
-> ReadPrec [RestoreCertificateAuthority]
-> Read RestoreCertificateAuthority
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RestoreCertificateAuthority]
$creadListPrec :: ReadPrec [RestoreCertificateAuthority]
readPrec :: ReadPrec RestoreCertificateAuthority
$creadPrec :: ReadPrec RestoreCertificateAuthority
readList :: ReadS [RestoreCertificateAuthority]
$creadList :: ReadS [RestoreCertificateAuthority]
readsPrec :: Int -> ReadS RestoreCertificateAuthority
$creadsPrec :: Int -> ReadS RestoreCertificateAuthority
Prelude.Read, Int -> RestoreCertificateAuthority -> ShowS
[RestoreCertificateAuthority] -> ShowS
RestoreCertificateAuthority -> String
(Int -> RestoreCertificateAuthority -> ShowS)
-> (RestoreCertificateAuthority -> String)
-> ([RestoreCertificateAuthority] -> ShowS)
-> Show RestoreCertificateAuthority
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreCertificateAuthority] -> ShowS
$cshowList :: [RestoreCertificateAuthority] -> ShowS
show :: RestoreCertificateAuthority -> String
$cshow :: RestoreCertificateAuthority -> String
showsPrec :: Int -> RestoreCertificateAuthority -> ShowS
$cshowsPrec :: Int -> RestoreCertificateAuthority -> ShowS
Prelude.Show, (forall x.
 RestoreCertificateAuthority -> Rep RestoreCertificateAuthority x)
-> (forall x.
    Rep RestoreCertificateAuthority x -> RestoreCertificateAuthority)
-> Generic RestoreCertificateAuthority
forall x.
Rep RestoreCertificateAuthority x -> RestoreCertificateAuthority
forall x.
RestoreCertificateAuthority -> Rep RestoreCertificateAuthority x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RestoreCertificateAuthority x -> RestoreCertificateAuthority
$cfrom :: forall x.
RestoreCertificateAuthority -> Rep RestoreCertificateAuthority x
Prelude.Generic)

-- |
-- Create a value of 'RestoreCertificateAuthority' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'certificateAuthorityArn', 'restoreCertificateAuthority_certificateAuthorityArn' - The Amazon Resource Name (ARN) that was returned when you called the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CreateCertificateAuthority.html CreateCertificateAuthority>
-- action. This must be of the form:
--
-- @arn:aws:acm-pca:region:account:certificate-authority\/12345678-1234-1234-1234-123456789012 @
newRestoreCertificateAuthority ::
  -- | 'certificateAuthorityArn'
  Prelude.Text ->
  RestoreCertificateAuthority
newRestoreCertificateAuthority :: Text -> RestoreCertificateAuthority
newRestoreCertificateAuthority
  Text
pCertificateAuthorityArn_ =
    RestoreCertificateAuthority' :: Text -> RestoreCertificateAuthority
RestoreCertificateAuthority'
      { $sel:certificateAuthorityArn:RestoreCertificateAuthority' :: Text
certificateAuthorityArn =
          Text
pCertificateAuthorityArn_
      }

-- | The Amazon Resource Name (ARN) that was returned when you called the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CreateCertificateAuthority.html CreateCertificateAuthority>
-- action. This must be of the form:
--
-- @arn:aws:acm-pca:region:account:certificate-authority\/12345678-1234-1234-1234-123456789012 @
restoreCertificateAuthority_certificateAuthorityArn :: Lens.Lens' RestoreCertificateAuthority Prelude.Text
restoreCertificateAuthority_certificateAuthorityArn :: (Text -> f Text)
-> RestoreCertificateAuthority -> f RestoreCertificateAuthority
restoreCertificateAuthority_certificateAuthorityArn = (RestoreCertificateAuthority -> Text)
-> (RestoreCertificateAuthority
    -> Text -> RestoreCertificateAuthority)
-> Lens
     RestoreCertificateAuthority RestoreCertificateAuthority Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreCertificateAuthority' {Text
certificateAuthorityArn :: Text
$sel:certificateAuthorityArn:RestoreCertificateAuthority' :: RestoreCertificateAuthority -> Text
certificateAuthorityArn} -> Text
certificateAuthorityArn) (\s :: RestoreCertificateAuthority
s@RestoreCertificateAuthority' {} Text
a -> RestoreCertificateAuthority
s {$sel:certificateAuthorityArn:RestoreCertificateAuthority' :: Text
certificateAuthorityArn = Text
a} :: RestoreCertificateAuthority)

instance Core.AWSRequest RestoreCertificateAuthority where
  type
    AWSResponse RestoreCertificateAuthority =
      RestoreCertificateAuthorityResponse
  request :: RestoreCertificateAuthority -> Request RestoreCertificateAuthority
request = Service
-> RestoreCertificateAuthority
-> Request RestoreCertificateAuthority
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RestoreCertificateAuthority
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RestoreCertificateAuthority)))
response =
    AWSResponse RestoreCertificateAuthority
-> Logger
-> Service
-> Proxy RestoreCertificateAuthority
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RestoreCertificateAuthority)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse RestoreCertificateAuthority
RestoreCertificateAuthorityResponse
RestoreCertificateAuthorityResponse'

instance Prelude.Hashable RestoreCertificateAuthority

instance Prelude.NFData RestoreCertificateAuthority

instance Core.ToHeaders RestoreCertificateAuthority where
  toHeaders :: RestoreCertificateAuthority -> [Header]
toHeaders =
    [Header] -> RestoreCertificateAuthority -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"ACMPrivateCA.RestoreCertificateAuthority" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON RestoreCertificateAuthority where
  toJSON :: RestoreCertificateAuthority -> Value
toJSON RestoreCertificateAuthority' {Text
certificateAuthorityArn :: Text
$sel:certificateAuthorityArn:RestoreCertificateAuthority' :: RestoreCertificateAuthority -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"CertificateAuthorityArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateAuthorityArn
              )
          ]
      )

instance Core.ToPath RestoreCertificateAuthority where
  toPath :: RestoreCertificateAuthority -> ByteString
toPath = ByteString -> RestoreCertificateAuthority -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery RestoreCertificateAuthority where
  toQuery :: RestoreCertificateAuthority -> QueryString
toQuery = QueryString -> RestoreCertificateAuthority -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newRestoreCertificateAuthorityResponse' smart constructor.
data RestoreCertificateAuthorityResponse = RestoreCertificateAuthorityResponse'
  {
  }
  deriving (RestoreCertificateAuthorityResponse
-> RestoreCertificateAuthorityResponse -> Bool
(RestoreCertificateAuthorityResponse
 -> RestoreCertificateAuthorityResponse -> Bool)
-> (RestoreCertificateAuthorityResponse
    -> RestoreCertificateAuthorityResponse -> Bool)
-> Eq RestoreCertificateAuthorityResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreCertificateAuthorityResponse
-> RestoreCertificateAuthorityResponse -> Bool
$c/= :: RestoreCertificateAuthorityResponse
-> RestoreCertificateAuthorityResponse -> Bool
== :: RestoreCertificateAuthorityResponse
-> RestoreCertificateAuthorityResponse -> Bool
$c== :: RestoreCertificateAuthorityResponse
-> RestoreCertificateAuthorityResponse -> Bool
Prelude.Eq, ReadPrec [RestoreCertificateAuthorityResponse]
ReadPrec RestoreCertificateAuthorityResponse
Int -> ReadS RestoreCertificateAuthorityResponse
ReadS [RestoreCertificateAuthorityResponse]
(Int -> ReadS RestoreCertificateAuthorityResponse)
-> ReadS [RestoreCertificateAuthorityResponse]
-> ReadPrec RestoreCertificateAuthorityResponse
-> ReadPrec [RestoreCertificateAuthorityResponse]
-> Read RestoreCertificateAuthorityResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RestoreCertificateAuthorityResponse]
$creadListPrec :: ReadPrec [RestoreCertificateAuthorityResponse]
readPrec :: ReadPrec RestoreCertificateAuthorityResponse
$creadPrec :: ReadPrec RestoreCertificateAuthorityResponse
readList :: ReadS [RestoreCertificateAuthorityResponse]
$creadList :: ReadS [RestoreCertificateAuthorityResponse]
readsPrec :: Int -> ReadS RestoreCertificateAuthorityResponse
$creadsPrec :: Int -> ReadS RestoreCertificateAuthorityResponse
Prelude.Read, Int -> RestoreCertificateAuthorityResponse -> ShowS
[RestoreCertificateAuthorityResponse] -> ShowS
RestoreCertificateAuthorityResponse -> String
(Int -> RestoreCertificateAuthorityResponse -> ShowS)
-> (RestoreCertificateAuthorityResponse -> String)
-> ([RestoreCertificateAuthorityResponse] -> ShowS)
-> Show RestoreCertificateAuthorityResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreCertificateAuthorityResponse] -> ShowS
$cshowList :: [RestoreCertificateAuthorityResponse] -> ShowS
show :: RestoreCertificateAuthorityResponse -> String
$cshow :: RestoreCertificateAuthorityResponse -> String
showsPrec :: Int -> RestoreCertificateAuthorityResponse -> ShowS
$cshowsPrec :: Int -> RestoreCertificateAuthorityResponse -> ShowS
Prelude.Show, (forall x.
 RestoreCertificateAuthorityResponse
 -> Rep RestoreCertificateAuthorityResponse x)
-> (forall x.
    Rep RestoreCertificateAuthorityResponse x
    -> RestoreCertificateAuthorityResponse)
-> Generic RestoreCertificateAuthorityResponse
forall x.
Rep RestoreCertificateAuthorityResponse x
-> RestoreCertificateAuthorityResponse
forall x.
RestoreCertificateAuthorityResponse
-> Rep RestoreCertificateAuthorityResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RestoreCertificateAuthorityResponse x
-> RestoreCertificateAuthorityResponse
$cfrom :: forall x.
RestoreCertificateAuthorityResponse
-> Rep RestoreCertificateAuthorityResponse x
Prelude.Generic)

-- |
-- Create a value of 'RestoreCertificateAuthorityResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
newRestoreCertificateAuthorityResponse ::
  RestoreCertificateAuthorityResponse
newRestoreCertificateAuthorityResponse :: RestoreCertificateAuthorityResponse
newRestoreCertificateAuthorityResponse =
  RestoreCertificateAuthorityResponse
RestoreCertificateAuthorityResponse'

instance
  Prelude.NFData
    RestoreCertificateAuthorityResponse