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

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

-- | 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, Amazon Web Services Private CA injects an Amazon Web
    -- Services 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.
    --
    -- The content of a Canonical Name (CNAME) record must conform to
    -- <https://www.ietf.org/rfc/rfc2396.txt RFC2396> restrictions on the use
    -- of special characters in URIs. Additionally, 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/privateca/latest/userguide/ocsp-customize.html Customizing Online Certificate Status Protocol (OCSP)>
    -- in the /Amazon Web Services Private Certificate Authority 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
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]
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
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. 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, Amazon Web Services Private CA injects an Amazon Web
-- Services 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.
--
-- The content of a Canonical Name (CNAME) record must conform to
-- <https://www.ietf.org/rfc/rfc2396.txt RFC2396> restrictions on the use
-- of special characters in URIs. Additionally, 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/privateca/latest/userguide/ocsp-customize.html Customizing Online Certificate Status Protocol (OCSP)>
-- in the /Amazon Web Services Private Certificate Authority 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'
    { $sel:ocspCustomCname:OcspConfiguration' :: Maybe Text
ocspCustomCname =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:OcspConfiguration' :: Bool
enabled = Bool
pEnabled_
    }

-- | By default, Amazon Web Services Private CA injects an Amazon Web
-- Services 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.
--
-- The content of a Canonical Name (CNAME) record must conform to
-- <https://www.ietf.org/rfc/rfc2396.txt RFC2396> restrictions on the use
-- of special characters in URIs. Additionally, 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/privateca/latest/userguide/ocsp-customize.html Customizing Online Certificate Status Protocol (OCSP)>
-- in the /Amazon Web Services Private Certificate Authority User Guide/.
ocspConfiguration_ocspCustomCname :: Lens.Lens' OcspConfiguration (Prelude.Maybe Prelude.Text)
ocspConfiguration_ocspCustomCname :: Lens' OcspConfiguration (Maybe Text)
ocspConfiguration_ocspCustomCname = 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 :: Lens' OcspConfiguration Bool
ocspConfiguration_enabled = 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 Data.FromJSON OcspConfiguration where
  parseJSON :: Value -> Parser OcspConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OcspConfiguration"
      ( \Object
x ->
          Maybe Text -> Bool -> OcspConfiguration
OcspConfiguration'
            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
"OcspCustomCname")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Enabled")
      )

instance Prelude.Hashable OcspConfiguration where
  hashWithSalt :: Int -> OcspConfiguration -> Int
hashWithSalt Int
_salt OcspConfiguration' {Bool
Maybe Text
enabled :: Bool
ocspCustomCname :: Maybe Text
$sel:enabled:OcspConfiguration' :: OcspConfiguration -> Bool
$sel:ocspCustomCname:OcspConfiguration' :: OcspConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ocspCustomCname
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enabled

instance Prelude.NFData OcspConfiguration where
  rnf :: OcspConfiguration -> ()
rnf OcspConfiguration' {Bool
Maybe Text
enabled :: Bool
ocspCustomCname :: Maybe Text
$sel:enabled:OcspConfiguration' :: OcspConfiguration -> Bool
$sel:ocspCustomCname:OcspConfiguration' :: OcspConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ocspCustomCname
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
enabled

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"OcspCustomCname" 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 Text
ocspCustomCname,
            forall a. a -> Maybe a
Prelude.Just (Key
"Enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
enabled)
          ]
      )