{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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/privateca/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/privateca/latest/APIReference/API_DescribeCertificateAuthority.html DescribeCertificateAuthority>
-- or
-- <https://docs.aws.amazon.com/privateca/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/privateca/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/privateca/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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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/privateca/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
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]
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
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.
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/privateca/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'
      { $sel:certificateAuthorityArn:RestoreCertificateAuthority' :: Text
certificateAuthorityArn =
          Text
pCertificateAuthorityArn_
      }

-- | The Amazon Resource Name (ARN) that was returned when you called the
-- <https://docs.aws.amazon.com/privateca/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 :: Lens' RestoreCertificateAuthority Text
restoreCertificateAuthority_certificateAuthorityArn = 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 :: (Service -> Service)
-> RestoreCertificateAuthority
-> Request RestoreCertificateAuthority
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RestoreCertificateAuthority
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RestoreCertificateAuthority)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      RestoreCertificateAuthorityResponse
RestoreCertificateAuthorityResponse'

instance Prelude.Hashable RestoreCertificateAuthority where
  hashWithSalt :: Int -> RestoreCertificateAuthority -> Int
hashWithSalt Int
_salt RestoreCertificateAuthority' {Text
certificateAuthorityArn :: Text
$sel:certificateAuthorityArn:RestoreCertificateAuthority' :: RestoreCertificateAuthority -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
certificateAuthorityArn

instance Prelude.NFData RestoreCertificateAuthority where
  rnf :: RestoreCertificateAuthority -> ()
rnf RestoreCertificateAuthority' {Text
certificateAuthorityArn :: Text
$sel:certificateAuthorityArn:RestoreCertificateAuthority' :: RestoreCertificateAuthority -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
certificateAuthorityArn

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

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

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

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

-- | /See:/ 'newRestoreCertificateAuthorityResponse' smart constructor.
data RestoreCertificateAuthorityResponse = RestoreCertificateAuthorityResponse'
  {
  }
  deriving (RestoreCertificateAuthorityResponse
-> RestoreCertificateAuthorityResponse -> Bool
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]
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
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.
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
  where
  rnf :: RestoreCertificateAuthorityResponse -> ()
rnf RestoreCertificateAuthorityResponse
_ = ()