{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:certificateTransparencyLoggingPreference:CertificateOptions' :: Maybe CertificateTransparencyLoggingPreference
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 :: Lens'
  CertificateOptions (Maybe CertificateTransparencyLoggingPreference)
certificateOptions_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 Data.FromJSON CertificateOptions where
  parseJSON :: Value -> Parser CertificateOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CertificateOptions"
      ( \Object
x ->
          Maybe CertificateTransparencyLoggingPreference
-> CertificateOptions
CertificateOptions'
            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
"CertificateTransparencyLoggingPreference"
                        )
      )

instance Prelude.Hashable CertificateOptions where
  hashWithSalt :: Int -> CertificateOptions -> Int
hashWithSalt Int
_salt CertificateOptions' {Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference :: Maybe CertificateTransparencyLoggingPreference
$sel:certificateTransparencyLoggingPreference:CertificateOptions' :: CertificateOptions
-> Maybe CertificateTransparencyLoggingPreference
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference

instance Prelude.NFData CertificateOptions where
  rnf :: CertificateOptions -> ()
rnf CertificateOptions' {Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference :: Maybe CertificateTransparencyLoggingPreference
$sel:certificateTransparencyLoggingPreference:CertificateOptions' :: CertificateOptions
-> Maybe CertificateTransparencyLoggingPreference
..} =
    forall a. NFData a => a -> ()
Prelude.rnf
      Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference

instance Data.ToJSON CertificateOptions where
  toJSON :: CertificateOptions -> Value
toJSON CertificateOptions' {Maybe CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference :: Maybe CertificateTransparencyLoggingPreference
$sel:certificateTransparencyLoggingPreference:CertificateOptions' :: CertificateOptions
-> Maybe CertificateTransparencyLoggingPreference
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CertificateTransparencyLoggingPreference" 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 CertificateTransparencyLoggingPreference
certificateTransparencyLoggingPreference
          ]
      )