{-# 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.OcspConfiguration
-- 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.OcspConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information to enable and configure Online Certificate Status
-- Protocol (OCSP) for validating certificate revocation status.
--
-- When you revoke a certificate, OCSP responses may take up to 60 minutes
-- to reflect the new status.
--
-- /See:/ 'newOcspConfiguration' smart constructor.
data OcspConfiguration = OcspConfiguration'
  { -- | By default, ACM Private CA injects an AWS domain into certificates being
    -- validated by the Online Certificate Status Protocol (OCSP). A customer
    -- can alternatively use this object to define a CNAME specifying a
    -- customized OCSP domain.
    --
    -- Note: The value of the CNAME must not include a protocol prefix such as
    -- \"http:\/\/\" or \"https:\/\/\".
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/acm-pca/latest/userguide/ocsp-customize.html Customizing Online Certificate Status Protocol (OCSP)>
    -- in the /AWS Certificate Manager Private Certificate Authority (PCA) User
    -- Guide/.
    OcspConfiguration -> Maybe Text
ocspCustomCname :: Prelude.Maybe Prelude.Text,
    -- | Flag enabling use of the Online Certificate Status Protocol (OCSP) for
    -- validating certificate revocation status.
    OcspConfiguration -> Bool
enabled :: Prelude.Bool
  }
  deriving (OcspConfiguration -> OcspConfiguration -> Bool
(OcspConfiguration -> OcspConfiguration -> Bool)
-> (OcspConfiguration -> OcspConfiguration -> Bool)
-> Eq OcspConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OcspConfiguration -> OcspConfiguration -> Bool
$c/= :: OcspConfiguration -> OcspConfiguration -> Bool
== :: OcspConfiguration -> OcspConfiguration -> Bool
$c== :: OcspConfiguration -> OcspConfiguration -> Bool
Prelude.Eq, ReadPrec [OcspConfiguration]
ReadPrec OcspConfiguration
Int -> ReadS OcspConfiguration
ReadS [OcspConfiguration]
(Int -> ReadS OcspConfiguration)
-> ReadS [OcspConfiguration]
-> ReadPrec OcspConfiguration
-> ReadPrec [OcspConfiguration]
-> Read OcspConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OcspConfiguration]
$creadListPrec :: ReadPrec [OcspConfiguration]
readPrec :: ReadPrec OcspConfiguration
$creadPrec :: ReadPrec OcspConfiguration
readList :: ReadS [OcspConfiguration]
$creadList :: ReadS [OcspConfiguration]
readsPrec :: Int -> ReadS OcspConfiguration
$creadsPrec :: Int -> ReadS OcspConfiguration
Prelude.Read, Int -> OcspConfiguration -> ShowS
[OcspConfiguration] -> ShowS
OcspConfiguration -> String
(Int -> OcspConfiguration -> ShowS)
-> (OcspConfiguration -> String)
-> ([OcspConfiguration] -> ShowS)
-> Show OcspConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OcspConfiguration] -> ShowS
$cshowList :: [OcspConfiguration] -> ShowS
show :: OcspConfiguration -> String
$cshow :: OcspConfiguration -> String
showsPrec :: Int -> OcspConfiguration -> ShowS
$cshowsPrec :: Int -> OcspConfiguration -> ShowS
Prelude.Show, (forall x. OcspConfiguration -> Rep OcspConfiguration x)
-> (forall x. Rep OcspConfiguration x -> OcspConfiguration)
-> Generic OcspConfiguration
forall x. Rep OcspConfiguration x -> OcspConfiguration
forall x. OcspConfiguration -> Rep OcspConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OcspConfiguration x -> OcspConfiguration
$cfrom :: forall x. OcspConfiguration -> Rep OcspConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'OcspConfiguration' 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:
--
-- 'ocspCustomCname', 'ocspConfiguration_ocspCustomCname' - By default, ACM Private CA injects an AWS domain into certificates being
-- validated by the Online Certificate Status Protocol (OCSP). A customer
-- can alternatively use this object to define a CNAME specifying a
-- customized OCSP domain.
--
-- Note: The value of the CNAME must not include a protocol prefix such as
-- \"http:\/\/\" or \"https:\/\/\".
--
-- For more information, see
-- <https://docs.aws.amazon.com/acm-pca/latest/userguide/ocsp-customize.html Customizing Online Certificate Status Protocol (OCSP)>
-- in the /AWS Certificate Manager Private Certificate Authority (PCA) User
-- Guide/.
--
-- 'enabled', 'ocspConfiguration_enabled' - Flag enabling use of the Online Certificate Status Protocol (OCSP) for
-- validating certificate revocation status.
newOcspConfiguration ::
  -- | 'enabled'
  Prelude.Bool ->
  OcspConfiguration
newOcspConfiguration :: Bool -> OcspConfiguration
newOcspConfiguration Bool
pEnabled_ =
  OcspConfiguration' :: Maybe Text -> Bool -> OcspConfiguration
OcspConfiguration'
    { $sel:ocspCustomCname:OcspConfiguration' :: Maybe Text
ocspCustomCname =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:OcspConfiguration' :: Bool
enabled = Bool
pEnabled_
    }

-- | By default, ACM Private CA injects an AWS domain into certificates being
-- validated by the Online Certificate Status Protocol (OCSP). A customer
-- can alternatively use this object to define a CNAME specifying a
-- customized OCSP domain.
--
-- Note: The value of the CNAME must not include a protocol prefix such as
-- \"http:\/\/\" or \"https:\/\/\".
--
-- For more information, see
-- <https://docs.aws.amazon.com/acm-pca/latest/userguide/ocsp-customize.html Customizing Online Certificate Status Protocol (OCSP)>
-- in the /AWS Certificate Manager Private Certificate Authority (PCA) User
-- Guide/.
ocspConfiguration_ocspCustomCname :: Lens.Lens' OcspConfiguration (Prelude.Maybe Prelude.Text)
ocspConfiguration_ocspCustomCname :: (Maybe Text -> f (Maybe Text))
-> OcspConfiguration -> f OcspConfiguration
ocspConfiguration_ocspCustomCname = (OcspConfiguration -> Maybe Text)
-> (OcspConfiguration -> Maybe Text -> OcspConfiguration)
-> Lens
     OcspConfiguration OcspConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OcspConfiguration' {Maybe Text
ocspCustomCname :: Maybe Text
$sel:ocspCustomCname:OcspConfiguration' :: OcspConfiguration -> Maybe Text
ocspCustomCname} -> Maybe Text
ocspCustomCname) (\s :: OcspConfiguration
s@OcspConfiguration' {} Maybe Text
a -> OcspConfiguration
s {$sel:ocspCustomCname:OcspConfiguration' :: Maybe Text
ocspCustomCname = Maybe Text
a} :: OcspConfiguration)

-- | Flag enabling use of the Online Certificate Status Protocol (OCSP) for
-- validating certificate revocation status.
ocspConfiguration_enabled :: Lens.Lens' OcspConfiguration Prelude.Bool
ocspConfiguration_enabled :: (Bool -> f Bool) -> OcspConfiguration -> f OcspConfiguration
ocspConfiguration_enabled = (OcspConfiguration -> Bool)
-> (OcspConfiguration -> Bool -> OcspConfiguration)
-> Lens OcspConfiguration OcspConfiguration Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OcspConfiguration' {Bool
enabled :: Bool
$sel:enabled:OcspConfiguration' :: OcspConfiguration -> Bool
enabled} -> Bool
enabled) (\s :: OcspConfiguration
s@OcspConfiguration' {} Bool
a -> OcspConfiguration
s {$sel:enabled:OcspConfiguration' :: Bool
enabled = Bool
a} :: OcspConfiguration)

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

instance Prelude.Hashable OcspConfiguration

instance Prelude.NFData OcspConfiguration

instance Core.ToJSON OcspConfiguration where
  toJSON :: OcspConfiguration -> Value
toJSON OcspConfiguration' {Bool
Maybe Text
enabled :: Bool
ocspCustomCname :: Maybe Text
$sel:enabled:OcspConfiguration' :: OcspConfiguration -> Bool
$sel:ocspCustomCname:OcspConfiguration' :: OcspConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OcspCustomCname" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ocspCustomCname,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
enabled)
          ]
      )