{-# 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.CertificateManager.Types.CertificateOptions
-- 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.CertificateManager.Types.CertificateOptions where

import Amazonka.CertificateManager.Types.CertificateTransparencyLoggingPreference
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Structure that contains options for your certificate. Currently, you can
-- use this only to specify whether to opt in to or out of certificate
-- transparency logging. Some browsers require that public certificates
-- issued for your domain be recorded in a log. Certificates that are not
-- logged typically generate a browser error. Transparency makes it
-- possible for you to detect SSL\/TLS certificates that have been
-- mistakenly or maliciously issued for your domain. For general
-- information, see
-- <https://docs.aws.amazon.com/acm/latest/userguide/acm-concepts.html#concept-transparency Certificate Transparency Logging>.
--
-- /See:/ 'newCertificateOptions' smart constructor.
data CertificateOptions = CertificateOptions'
  { -- | You can opt out of certificate transparency logging by specifying the
    -- @DISABLED@ option. Opt in by specifying @ENABLED@.
    CertificateOptions
-> Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference :: Prelude.Maybe CertificateTransparencyLoggingPreference
  }
  deriving (CertificateOptions -> CertificateOptions -> Bool
(CertificateOptions -> CertificateOptions -> Bool)
-> (CertificateOptions -> CertificateOptions -> Bool)
-> Eq CertificateOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CertificateOptions -> CertificateOptions -> Bool
$c/= :: CertificateOptions -> CertificateOptions -> Bool
== :: CertificateOptions -> CertificateOptions -> Bool
$c== :: CertificateOptions -> CertificateOptions -> Bool
Prelude.Eq, ReadPrec [CertificateOptions]
ReadPrec CertificateOptions
Int -> ReadS CertificateOptions
ReadS [CertificateOptions]
(Int -> ReadS CertificateOptions)
-> ReadS [CertificateOptions]
-> ReadPrec CertificateOptions
-> ReadPrec [CertificateOptions]
-> Read CertificateOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CertificateOptions]
$creadListPrec :: ReadPrec [CertificateOptions]
readPrec :: ReadPrec CertificateOptions
$creadPrec :: ReadPrec CertificateOptions
readList :: ReadS [CertificateOptions]
$creadList :: ReadS [CertificateOptions]
readsPrec :: Int -> ReadS CertificateOptions
$creadsPrec :: Int -> ReadS CertificateOptions
Prelude.Read, Int -> CertificateOptions -> ShowS
[CertificateOptions] -> ShowS
CertificateOptions -> String
(Int -> CertificateOptions -> ShowS)
-> (CertificateOptions -> String)
-> ([CertificateOptions] -> ShowS)
-> Show CertificateOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CertificateOptions] -> ShowS
$cshowList :: [CertificateOptions] -> ShowS
show :: CertificateOptions -> String
$cshow :: CertificateOptions -> String
showsPrec :: Int -> CertificateOptions -> ShowS
$cshowsPrec :: Int -> CertificateOptions -> ShowS
Prelude.Show, (forall x. CertificateOptions -> Rep CertificateOptions x)
-> (forall x. Rep CertificateOptions x -> CertificateOptions)
-> Generic CertificateOptions
forall x. Rep CertificateOptions x -> CertificateOptions
forall x. CertificateOptions -> Rep CertificateOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CertificateOptions x -> CertificateOptions
$cfrom :: forall x. CertificateOptions -> Rep CertificateOptions x
Prelude.Generic)

-- |
-- Create a value of 'CertificateOptions' 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:
--
-- 'certificateTransparencyLoggingPreference', 'certificateOptions_certificateTransparencyLoggingPreference' - You can opt out of certificate transparency logging by specifying the
-- @DISABLED@ option. Opt in by specifying @ENABLED@.
newCertificateOptions ::
  CertificateOptions
newCertificateOptions :: CertificateOptions
newCertificateOptions =
  CertificateOptions' :: Maybe CertificateTransparencyLoggingPreference
-> CertificateOptions
CertificateOptions'
    { $sel:certificateTransparencyLoggingPreference:CertificateOptions' :: Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference =
        Maybe CertificateTransparencyLoggingPreference
forall a. Maybe a
Prelude.Nothing
    }

-- | You can opt out of certificate transparency logging by specifying the
-- @DISABLED@ option. Opt in by specifying @ENABLED@.
certificateOptions_certificateTransparencyLoggingPreference :: Lens.Lens' CertificateOptions (Prelude.Maybe CertificateTransparencyLoggingPreference)
certificateOptions_certificateTransparencyLoggingPreference :: (Maybe CertificateTransparencyLoggingPreference
 -> f (Maybe CertificateTransparencyLoggingPreference))
-> CertificateOptions -> f CertificateOptions
certificateOptions_certificateTransparencyLoggingPreference = (CertificateOptions
 -> Maybe CertificateTransparencyLoggingPreference)
-> (CertificateOptions
    -> Maybe CertificateTransparencyLoggingPreference
    -> CertificateOptions)
-> Lens
     CertificateOptions
     CertificateOptions
     (Maybe CertificateTransparencyLoggingPreference)
     (Maybe CertificateTransparencyLoggingPreference)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CertificateOptions' {Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference :: Maybe CertificateTransparencyLoggingPreference
$sel:certificateTransparencyLoggingPreference:CertificateOptions' :: CertificateOptions
-> Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference} -> Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference) (\s :: CertificateOptions
s@CertificateOptions' {} Maybe CertificateTransparencyLoggingPreference
a -> CertificateOptions
s {$sel:certificateTransparencyLoggingPreference:CertificateOptions' :: Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference = Maybe CertificateTransparencyLoggingPreference
a} :: CertificateOptions)

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

instance Prelude.Hashable CertificateOptions

instance Prelude.NFData CertificateOptions

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