{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.RevocationConfiguration
-- 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)
module Amazonka.CertificateManagerPCA.Types.RevocationConfiguration where

import Amazonka.CertificateManagerPCA.Types.CrlConfiguration
import Amazonka.CertificateManagerPCA.Types.OcspConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Certificate revocation information used by the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CreateCertificateAuthority.html CreateCertificateAuthority>
-- and
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_UpdateCertificateAuthority.html UpdateCertificateAuthority>
-- actions. Your private certificate authority (CA) can configure Online
-- Certificate Status Protocol (OCSP) support and\/or maintain a
-- certificate revocation list (CRL). OCSP returns validation information
-- about certificates as requested by clients, and a CRL contains an
-- updated list of certificates revoked by your CA. For more information,
-- see
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_RevokeCertificate.html RevokeCertificate>
-- and
-- <https://docs.aws.amazon.com/acm-pca/latest/userguide/revocation-setup.html Setting up a certificate revocation method>
-- in the /AWS Certificate Manager Private Certificate Authority (PCA) User
-- Guide/.
--
-- /See:/ 'newRevocationConfiguration' smart constructor.
data RevocationConfiguration = RevocationConfiguration'
  { -- | Configuration of the certificate revocation list (CRL), if any,
    -- maintained by your private CA. A CRL is typically updated approximately
    -- 30 minutes after a certificate is revoked. If for any reason a CRL
    -- update fails, ACM Private CA makes further attempts every 15 minutes.
    RevocationConfiguration -> Maybe CrlConfiguration
crlConfiguration :: Prelude.Maybe CrlConfiguration,
    -- | Configuration of Online Certificate Status Protocol (OCSP) support, if
    -- any, maintained by your private CA. When you revoke a certificate, OCSP
    -- responses may take up to 60 minutes to reflect the new status.
    RevocationConfiguration -> Maybe OcspConfiguration
ocspConfiguration :: Prelude.Maybe OcspConfiguration
  }
  deriving (RevocationConfiguration -> RevocationConfiguration -> Bool
(RevocationConfiguration -> RevocationConfiguration -> Bool)
-> (RevocationConfiguration -> RevocationConfiguration -> Bool)
-> Eq RevocationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RevocationConfiguration -> RevocationConfiguration -> Bool
$c/= :: RevocationConfiguration -> RevocationConfiguration -> Bool
== :: RevocationConfiguration -> RevocationConfiguration -> Bool
$c== :: RevocationConfiguration -> RevocationConfiguration -> Bool
Prelude.Eq, ReadPrec [RevocationConfiguration]
ReadPrec RevocationConfiguration
Int -> ReadS RevocationConfiguration
ReadS [RevocationConfiguration]
(Int -> ReadS RevocationConfiguration)
-> ReadS [RevocationConfiguration]
-> ReadPrec RevocationConfiguration
-> ReadPrec [RevocationConfiguration]
-> Read RevocationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RevocationConfiguration]
$creadListPrec :: ReadPrec [RevocationConfiguration]
readPrec :: ReadPrec RevocationConfiguration
$creadPrec :: ReadPrec RevocationConfiguration
readList :: ReadS [RevocationConfiguration]
$creadList :: ReadS [RevocationConfiguration]
readsPrec :: Int -> ReadS RevocationConfiguration
$creadsPrec :: Int -> ReadS RevocationConfiguration
Prelude.Read, Int -> RevocationConfiguration -> ShowS
[RevocationConfiguration] -> ShowS
RevocationConfiguration -> String
(Int -> RevocationConfiguration -> ShowS)
-> (RevocationConfiguration -> String)
-> ([RevocationConfiguration] -> ShowS)
-> Show RevocationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RevocationConfiguration] -> ShowS
$cshowList :: [RevocationConfiguration] -> ShowS
show :: RevocationConfiguration -> String
$cshow :: RevocationConfiguration -> String
showsPrec :: Int -> RevocationConfiguration -> ShowS
$cshowsPrec :: Int -> RevocationConfiguration -> ShowS
Prelude.Show, (forall x.
 RevocationConfiguration -> Rep RevocationConfiguration x)
-> (forall x.
    Rep RevocationConfiguration x -> RevocationConfiguration)
-> Generic RevocationConfiguration
forall x. Rep RevocationConfiguration x -> RevocationConfiguration
forall x. RevocationConfiguration -> Rep RevocationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RevocationConfiguration x -> RevocationConfiguration
$cfrom :: forall x. RevocationConfiguration -> Rep RevocationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'RevocationConfiguration' 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:
--
-- 'crlConfiguration', 'revocationConfiguration_crlConfiguration' - Configuration of the certificate revocation list (CRL), if any,
-- maintained by your private CA. A CRL is typically updated approximately
-- 30 minutes after a certificate is revoked. If for any reason a CRL
-- update fails, ACM Private CA makes further attempts every 15 minutes.
--
-- 'ocspConfiguration', 'revocationConfiguration_ocspConfiguration' - Configuration of Online Certificate Status Protocol (OCSP) support, if
-- any, maintained by your private CA. When you revoke a certificate, OCSP
-- responses may take up to 60 minutes to reflect the new status.
newRevocationConfiguration ::
  RevocationConfiguration
newRevocationConfiguration :: RevocationConfiguration
newRevocationConfiguration =
  RevocationConfiguration' :: Maybe CrlConfiguration
-> Maybe OcspConfiguration -> RevocationConfiguration
RevocationConfiguration'
    { $sel:crlConfiguration:RevocationConfiguration' :: Maybe CrlConfiguration
crlConfiguration =
        Maybe CrlConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:ocspConfiguration:RevocationConfiguration' :: Maybe OcspConfiguration
ocspConfiguration = Maybe OcspConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | Configuration of the certificate revocation list (CRL), if any,
-- maintained by your private CA. A CRL is typically updated approximately
-- 30 minutes after a certificate is revoked. If for any reason a CRL
-- update fails, ACM Private CA makes further attempts every 15 minutes.
revocationConfiguration_crlConfiguration :: Lens.Lens' RevocationConfiguration (Prelude.Maybe CrlConfiguration)
revocationConfiguration_crlConfiguration :: (Maybe CrlConfiguration -> f (Maybe CrlConfiguration))
-> RevocationConfiguration -> f RevocationConfiguration
revocationConfiguration_crlConfiguration = (RevocationConfiguration -> Maybe CrlConfiguration)
-> (RevocationConfiguration
    -> Maybe CrlConfiguration -> RevocationConfiguration)
-> Lens
     RevocationConfiguration
     RevocationConfiguration
     (Maybe CrlConfiguration)
     (Maybe CrlConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevocationConfiguration' {Maybe CrlConfiguration
crlConfiguration :: Maybe CrlConfiguration
$sel:crlConfiguration:RevocationConfiguration' :: RevocationConfiguration -> Maybe CrlConfiguration
crlConfiguration} -> Maybe CrlConfiguration
crlConfiguration) (\s :: RevocationConfiguration
s@RevocationConfiguration' {} Maybe CrlConfiguration
a -> RevocationConfiguration
s {$sel:crlConfiguration:RevocationConfiguration' :: Maybe CrlConfiguration
crlConfiguration = Maybe CrlConfiguration
a} :: RevocationConfiguration)

-- | Configuration of Online Certificate Status Protocol (OCSP) support, if
-- any, maintained by your private CA. When you revoke a certificate, OCSP
-- responses may take up to 60 minutes to reflect the new status.
revocationConfiguration_ocspConfiguration :: Lens.Lens' RevocationConfiguration (Prelude.Maybe OcspConfiguration)
revocationConfiguration_ocspConfiguration :: (Maybe OcspConfiguration -> f (Maybe OcspConfiguration))
-> RevocationConfiguration -> f RevocationConfiguration
revocationConfiguration_ocspConfiguration = (RevocationConfiguration -> Maybe OcspConfiguration)
-> (RevocationConfiguration
    -> Maybe OcspConfiguration -> RevocationConfiguration)
-> Lens
     RevocationConfiguration
     RevocationConfiguration
     (Maybe OcspConfiguration)
     (Maybe OcspConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevocationConfiguration' {Maybe OcspConfiguration
ocspConfiguration :: Maybe OcspConfiguration
$sel:ocspConfiguration:RevocationConfiguration' :: RevocationConfiguration -> Maybe OcspConfiguration
ocspConfiguration} -> Maybe OcspConfiguration
ocspConfiguration) (\s :: RevocationConfiguration
s@RevocationConfiguration' {} Maybe OcspConfiguration
a -> RevocationConfiguration
s {$sel:ocspConfiguration:RevocationConfiguration' :: Maybe OcspConfiguration
ocspConfiguration = Maybe OcspConfiguration
a} :: RevocationConfiguration)

instance Core.FromJSON RevocationConfiguration where
  parseJSON :: Value -> Parser RevocationConfiguration
parseJSON =
    String
-> (Object -> Parser RevocationConfiguration)
-> Value
-> Parser RevocationConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RevocationConfiguration"
      ( \Object
x ->
          Maybe CrlConfiguration
-> Maybe OcspConfiguration -> RevocationConfiguration
RevocationConfiguration'
            (Maybe CrlConfiguration
 -> Maybe OcspConfiguration -> RevocationConfiguration)
-> Parser (Maybe CrlConfiguration)
-> Parser (Maybe OcspConfiguration -> RevocationConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CrlConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CrlConfiguration")
            Parser (Maybe OcspConfiguration -> RevocationConfiguration)
-> Parser (Maybe OcspConfiguration)
-> Parser RevocationConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe OcspConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OcspConfiguration")
      )

instance Prelude.Hashable RevocationConfiguration

instance Prelude.NFData RevocationConfiguration

instance Core.ToJSON RevocationConfiguration where
  toJSON :: RevocationConfiguration -> Value
toJSON RevocationConfiguration' {Maybe OcspConfiguration
Maybe CrlConfiguration
ocspConfiguration :: Maybe OcspConfiguration
crlConfiguration :: Maybe CrlConfiguration
$sel:ocspConfiguration:RevocationConfiguration' :: RevocationConfiguration -> Maybe OcspConfiguration
$sel:crlConfiguration:RevocationConfiguration' :: RevocationConfiguration -> Maybe CrlConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CrlConfiguration" Text -> CrlConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CrlConfiguration -> Pair) -> Maybe CrlConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CrlConfiguration
crlConfiguration,
            (Text
"OcspConfiguration" Text -> OcspConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (OcspConfiguration -> Pair)
-> Maybe OcspConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OcspConfiguration
ocspConfiguration
          ]
      )