{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Certificate revocation information used by the
-- <https://docs.aws.amazon.com/privateca/latest/APIReference/API_CreateCertificateAuthority.html CreateCertificateAuthority>
-- and
-- <https://docs.aws.amazon.com/privateca/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/privateca/latest/APIReference/API_RevokeCertificate.html RevokeCertificate>
-- and
-- <https://docs.aws.amazon.com/privateca/latest/userguide/revocation-setup.html Setting up a certificate revocation method>
-- in the /Amazon Web Services Private Certificate Authority 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, Amazon Web Services 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
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]
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
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. 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, Amazon Web Services 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'
    { $sel:crlConfiguration:RevocationConfiguration' :: Maybe CrlConfiguration
crlConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:ocspConfiguration:RevocationConfiguration' :: Maybe OcspConfiguration
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, Amazon Web Services Private CA makes further attempts
-- every 15 minutes.
revocationConfiguration_crlConfiguration :: Lens.Lens' RevocationConfiguration (Prelude.Maybe CrlConfiguration)
revocationConfiguration_crlConfiguration :: Lens' RevocationConfiguration (Maybe CrlConfiguration)
revocationConfiguration_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 :: Lens' RevocationConfiguration (Maybe OcspConfiguration)
revocationConfiguration_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 Data.FromJSON RevocationConfiguration where
  parseJSON :: Value -> Parser RevocationConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RevocationConfiguration"
      ( \Object
x ->
          Maybe CrlConfiguration
-> Maybe OcspConfiguration -> RevocationConfiguration
RevocationConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CrlConfiguration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"OcspConfiguration")
      )

instance Prelude.Hashable RevocationConfiguration where
  hashWithSalt :: Int -> RevocationConfiguration -> Int
hashWithSalt Int
_salt RevocationConfiguration' {Maybe OcspConfiguration
Maybe CrlConfiguration
ocspConfiguration :: Maybe OcspConfiguration
crlConfiguration :: Maybe CrlConfiguration
$sel:ocspConfiguration:RevocationConfiguration' :: RevocationConfiguration -> Maybe OcspConfiguration
$sel:crlConfiguration:RevocationConfiguration' :: RevocationConfiguration -> Maybe CrlConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CrlConfiguration
crlConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OcspConfiguration
ocspConfiguration

instance Prelude.NFData RevocationConfiguration where
  rnf :: RevocationConfiguration -> ()
rnf RevocationConfiguration' {Maybe OcspConfiguration
Maybe CrlConfiguration
ocspConfiguration :: Maybe OcspConfiguration
crlConfiguration :: Maybe CrlConfiguration
$sel:ocspConfiguration:RevocationConfiguration' :: RevocationConfiguration -> Maybe OcspConfiguration
$sel:crlConfiguration:RevocationConfiguration' :: RevocationConfiguration -> Maybe CrlConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CrlConfiguration
crlConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OcspConfiguration
ocspConfiguration

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CrlConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CrlConfiguration
crlConfiguration,
            (Key
"OcspConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OcspConfiguration
ocspConfiguration
          ]
      )