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

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

-- | Used to associate a configuration set with a dedicated IP pool.
--
-- /See:/ 'newDeliveryOptions' smart constructor.
data DeliveryOptions = DeliveryOptions'
  { -- | The name of the dedicated IP pool to associate with the configuration
    -- set.
    DeliveryOptions -> Maybe Text
sendingPoolName :: Prelude.Maybe Prelude.Text,
    -- | 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:
--
-- 'sendingPoolName', 'deliveryOptions_sendingPoolName' - The name of the dedicated IP pool to associate with the configuration
-- set.
--
-- '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 Text -> Maybe TlsPolicy -> DeliveryOptions
DeliveryOptions'
    { $sel:sendingPoolName:DeliveryOptions' :: Maybe Text
sendingPoolName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tlsPolicy:DeliveryOptions' :: Maybe TlsPolicy
tlsPolicy = Maybe TlsPolicy
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the dedicated IP pool to associate with the configuration
-- set.
deliveryOptions_sendingPoolName :: Lens.Lens' DeliveryOptions (Prelude.Maybe Prelude.Text)
deliveryOptions_sendingPoolName :: (Maybe Text -> f (Maybe Text))
-> DeliveryOptions -> f DeliveryOptions
deliveryOptions_sendingPoolName = (DeliveryOptions -> Maybe Text)
-> (DeliveryOptions -> Maybe Text -> DeliveryOptions)
-> Lens DeliveryOptions DeliveryOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeliveryOptions' {Maybe Text
sendingPoolName :: Maybe Text
$sel:sendingPoolName:DeliveryOptions' :: DeliveryOptions -> Maybe Text
sendingPoolName} -> Maybe Text
sendingPoolName) (\s :: DeliveryOptions
s@DeliveryOptions' {} Maybe Text
a -> DeliveryOptions
s {$sel:sendingPoolName:DeliveryOptions' :: Maybe Text
sendingPoolName = Maybe Text
a} :: 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_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.FromJSON DeliveryOptions where
  parseJSON :: Value -> Parser DeliveryOptions
parseJSON =
    String
-> (Object -> Parser DeliveryOptions)
-> Value
-> Parser DeliveryOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeliveryOptions"
      ( \Object
x ->
          Maybe Text -> Maybe TlsPolicy -> DeliveryOptions
DeliveryOptions'
            (Maybe Text -> Maybe TlsPolicy -> DeliveryOptions)
-> Parser (Maybe Text)
-> Parser (Maybe TlsPolicy -> DeliveryOptions)
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
"SendingPoolName")
            Parser (Maybe TlsPolicy -> DeliveryOptions)
-> Parser (Maybe TlsPolicy) -> Parser DeliveryOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TlsPolicy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TlsPolicy")
      )

instance Prelude.Hashable DeliveryOptions

instance Prelude.NFData DeliveryOptions

instance Core.ToJSON DeliveryOptions where
  toJSON :: DeliveryOptions -> Value
toJSON DeliveryOptions' {Maybe Text
Maybe TlsPolicy
tlsPolicy :: Maybe TlsPolicy
sendingPoolName :: Maybe Text
$sel:tlsPolicy:DeliveryOptions' :: DeliveryOptions -> Maybe TlsPolicy
$sel:sendingPoolName:DeliveryOptions' :: DeliveryOptions -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SendingPoolName" 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
sendingPoolName,
            (Text
"TlsPolicy" Text -> TlsPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TlsPolicy -> Pair) -> Maybe TlsPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TlsPolicy
tlsPolicy
          ]
      )