{-# 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.SES.Types.DeliveryOptions
-- 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.SES.Types.DeliveryOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SES.Types.TlsPolicy

-- | Specifies whether messages that use the configuration set are required
-- to use Transport Layer Security (TLS).
--
-- /See:/ 'newDeliveryOptions' smart constructor.
data DeliveryOptions = DeliveryOptions'
  { -- | Specifies whether messages that use the configuration set are required
    -- to use Transport Layer Security (TLS). If the value is @Require@,
    -- messages are only delivered if a TLS connection can be established. If
    -- the value is @Optional@, messages can be delivered in plain text if a
    -- TLS connection can\'t be established.
    DeliveryOptions -> Maybe TlsPolicy
tlsPolicy :: Prelude.Maybe TlsPolicy
  }
  deriving (DeliveryOptions -> DeliveryOptions -> Bool
(DeliveryOptions -> DeliveryOptions -> Bool)
-> (DeliveryOptions -> DeliveryOptions -> Bool)
-> Eq DeliveryOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeliveryOptions -> DeliveryOptions -> Bool
$c/= :: DeliveryOptions -> DeliveryOptions -> Bool
== :: DeliveryOptions -> DeliveryOptions -> Bool
$c== :: DeliveryOptions -> DeliveryOptions -> Bool
Prelude.Eq, ReadPrec [DeliveryOptions]
ReadPrec DeliveryOptions
Int -> ReadS DeliveryOptions
ReadS [DeliveryOptions]
(Int -> ReadS DeliveryOptions)
-> ReadS [DeliveryOptions]
-> ReadPrec DeliveryOptions
-> ReadPrec [DeliveryOptions]
-> Read DeliveryOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeliveryOptions]
$creadListPrec :: ReadPrec [DeliveryOptions]
readPrec :: ReadPrec DeliveryOptions
$creadPrec :: ReadPrec DeliveryOptions
readList :: ReadS [DeliveryOptions]
$creadList :: ReadS [DeliveryOptions]
readsPrec :: Int -> ReadS DeliveryOptions
$creadsPrec :: Int -> ReadS DeliveryOptions
Prelude.Read, Int -> DeliveryOptions -> ShowS
[DeliveryOptions] -> ShowS
DeliveryOptions -> String
(Int -> DeliveryOptions -> ShowS)
-> (DeliveryOptions -> String)
-> ([DeliveryOptions] -> ShowS)
-> Show DeliveryOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeliveryOptions] -> ShowS
$cshowList :: [DeliveryOptions] -> ShowS
show :: DeliveryOptions -> String
$cshow :: DeliveryOptions -> String
showsPrec :: Int -> DeliveryOptions -> ShowS
$cshowsPrec :: Int -> DeliveryOptions -> ShowS
Prelude.Show, (forall x. DeliveryOptions -> Rep DeliveryOptions x)
-> (forall x. Rep DeliveryOptions x -> DeliveryOptions)
-> Generic DeliveryOptions
forall x. Rep DeliveryOptions x -> DeliveryOptions
forall x. DeliveryOptions -> Rep DeliveryOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeliveryOptions x -> DeliveryOptions
$cfrom :: forall x. DeliveryOptions -> Rep DeliveryOptions x
Prelude.Generic)

-- |
-- Create a value of 'DeliveryOptions' 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:
--
-- 'tlsPolicy', 'deliveryOptions_tlsPolicy' - Specifies whether messages that use the configuration set are required
-- to use Transport Layer Security (TLS). If the value is @Require@,
-- messages are only delivered if a TLS connection can be established. If
-- the value is @Optional@, messages can be delivered in plain text if a
-- TLS connection can\'t be established.
newDeliveryOptions ::
  DeliveryOptions
newDeliveryOptions :: DeliveryOptions
newDeliveryOptions =
  DeliveryOptions' :: Maybe TlsPolicy -> DeliveryOptions
DeliveryOptions' {$sel:tlsPolicy:DeliveryOptions' :: Maybe TlsPolicy
tlsPolicy = Maybe TlsPolicy
forall a. Maybe a
Prelude.Nothing}

-- | Specifies whether messages that use the configuration set are required
-- to use Transport Layer Security (TLS). If the value is @Require@,
-- messages are only delivered if a TLS connection can be established. If
-- the value is @Optional@, messages can be delivered in plain text if a
-- TLS connection can\'t be established.
deliveryOptions_tlsPolicy :: Lens.Lens' DeliveryOptions (Prelude.Maybe TlsPolicy)
deliveryOptions_tlsPolicy :: (Maybe TlsPolicy -> f (Maybe TlsPolicy))
-> DeliveryOptions -> f DeliveryOptions
deliveryOptions_tlsPolicy = (DeliveryOptions -> Maybe TlsPolicy)
-> (DeliveryOptions -> Maybe TlsPolicy -> DeliveryOptions)
-> Lens
     DeliveryOptions DeliveryOptions (Maybe TlsPolicy) (Maybe TlsPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeliveryOptions' {Maybe TlsPolicy
tlsPolicy :: Maybe TlsPolicy
$sel:tlsPolicy:DeliveryOptions' :: DeliveryOptions -> Maybe TlsPolicy
tlsPolicy} -> Maybe TlsPolicy
tlsPolicy) (\s :: DeliveryOptions
s@DeliveryOptions' {} Maybe TlsPolicy
a -> DeliveryOptions
s {$sel:tlsPolicy:DeliveryOptions' :: Maybe TlsPolicy
tlsPolicy = Maybe TlsPolicy
a} :: DeliveryOptions)

instance Core.FromXML DeliveryOptions where
  parseXML :: [Node] -> Either String DeliveryOptions
parseXML [Node]
x =
    Maybe TlsPolicy -> DeliveryOptions
DeliveryOptions'
      (Maybe TlsPolicy -> DeliveryOptions)
-> Either String (Maybe TlsPolicy) -> Either String DeliveryOptions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe TlsPolicy)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TlsPolicy")

instance Prelude.Hashable DeliveryOptions

instance Prelude.NFData DeliveryOptions

instance Core.ToQuery DeliveryOptions where
  toQuery :: DeliveryOptions -> QueryString
toQuery DeliveryOptions' {Maybe TlsPolicy
tlsPolicy :: Maybe TlsPolicy
$sel:tlsPolicy:DeliveryOptions' :: DeliveryOptions -> Maybe TlsPolicy
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"TlsPolicy" ByteString -> Maybe TlsPolicy -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe TlsPolicy
tlsPolicy]