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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Used for filtering by a specific topic preference.
--
-- /See:/ 'newTopicFilter' smart constructor.
data TopicFilter = TopicFilter'
  { -- | The name of a topic on which you wish to apply the filter.
    TopicFilter -> Maybe Text
topicName :: Prelude.Maybe Prelude.Text,
    -- | Notes that the default subscription status should be applied to a
    -- contact because the contact has not noted their preference for
    -- subscribing to a topic.
    TopicFilter -> Maybe Bool
useDefaultIfPreferenceUnavailable :: Prelude.Maybe Prelude.Bool
  }
  deriving (TopicFilter -> TopicFilter -> Bool
(TopicFilter -> TopicFilter -> Bool)
-> (TopicFilter -> TopicFilter -> Bool) -> Eq TopicFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopicFilter -> TopicFilter -> Bool
$c/= :: TopicFilter -> TopicFilter -> Bool
== :: TopicFilter -> TopicFilter -> Bool
$c== :: TopicFilter -> TopicFilter -> Bool
Prelude.Eq, ReadPrec [TopicFilter]
ReadPrec TopicFilter
Int -> ReadS TopicFilter
ReadS [TopicFilter]
(Int -> ReadS TopicFilter)
-> ReadS [TopicFilter]
-> ReadPrec TopicFilter
-> ReadPrec [TopicFilter]
-> Read TopicFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TopicFilter]
$creadListPrec :: ReadPrec [TopicFilter]
readPrec :: ReadPrec TopicFilter
$creadPrec :: ReadPrec TopicFilter
readList :: ReadS [TopicFilter]
$creadList :: ReadS [TopicFilter]
readsPrec :: Int -> ReadS TopicFilter
$creadsPrec :: Int -> ReadS TopicFilter
Prelude.Read, Int -> TopicFilter -> ShowS
[TopicFilter] -> ShowS
TopicFilter -> String
(Int -> TopicFilter -> ShowS)
-> (TopicFilter -> String)
-> ([TopicFilter] -> ShowS)
-> Show TopicFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopicFilter] -> ShowS
$cshowList :: [TopicFilter] -> ShowS
show :: TopicFilter -> String
$cshow :: TopicFilter -> String
showsPrec :: Int -> TopicFilter -> ShowS
$cshowsPrec :: Int -> TopicFilter -> ShowS
Prelude.Show, (forall x. TopicFilter -> Rep TopicFilter x)
-> (forall x. Rep TopicFilter x -> TopicFilter)
-> Generic TopicFilter
forall x. Rep TopicFilter x -> TopicFilter
forall x. TopicFilter -> Rep TopicFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TopicFilter x -> TopicFilter
$cfrom :: forall x. TopicFilter -> Rep TopicFilter x
Prelude.Generic)

-- |
-- Create a value of 'TopicFilter' 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:
--
-- 'topicName', 'topicFilter_topicName' - The name of a topic on which you wish to apply the filter.
--
-- 'useDefaultIfPreferenceUnavailable', 'topicFilter_useDefaultIfPreferenceUnavailable' - Notes that the default subscription status should be applied to a
-- contact because the contact has not noted their preference for
-- subscribing to a topic.
newTopicFilter ::
  TopicFilter
newTopicFilter :: TopicFilter
newTopicFilter =
  TopicFilter' :: Maybe Text -> Maybe Bool -> TopicFilter
TopicFilter'
    { $sel:topicName:TopicFilter' :: Maybe Text
topicName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: Maybe Bool
useDefaultIfPreferenceUnavailable = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of a topic on which you wish to apply the filter.
topicFilter_topicName :: Lens.Lens' TopicFilter (Prelude.Maybe Prelude.Text)
topicFilter_topicName :: (Maybe Text -> f (Maybe Text)) -> TopicFilter -> f TopicFilter
topicFilter_topicName = (TopicFilter -> Maybe Text)
-> (TopicFilter -> Maybe Text -> TopicFilter)
-> Lens TopicFilter TopicFilter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicFilter' {Maybe Text
topicName :: Maybe Text
$sel:topicName:TopicFilter' :: TopicFilter -> Maybe Text
topicName} -> Maybe Text
topicName) (\s :: TopicFilter
s@TopicFilter' {} Maybe Text
a -> TopicFilter
s {$sel:topicName:TopicFilter' :: Maybe Text
topicName = Maybe Text
a} :: TopicFilter)

-- | Notes that the default subscription status should be applied to a
-- contact because the contact has not noted their preference for
-- subscribing to a topic.
topicFilter_useDefaultIfPreferenceUnavailable :: Lens.Lens' TopicFilter (Prelude.Maybe Prelude.Bool)
topicFilter_useDefaultIfPreferenceUnavailable :: (Maybe Bool -> f (Maybe Bool)) -> TopicFilter -> f TopicFilter
topicFilter_useDefaultIfPreferenceUnavailable = (TopicFilter -> Maybe Bool)
-> (TopicFilter -> Maybe Bool -> TopicFilter)
-> Lens TopicFilter TopicFilter (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicFilter' {Maybe Bool
useDefaultIfPreferenceUnavailable :: Maybe Bool
$sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: TopicFilter -> Maybe Bool
useDefaultIfPreferenceUnavailable} -> Maybe Bool
useDefaultIfPreferenceUnavailable) (\s :: TopicFilter
s@TopicFilter' {} Maybe Bool
a -> TopicFilter
s {$sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: Maybe Bool
useDefaultIfPreferenceUnavailable = Maybe Bool
a} :: TopicFilter)

instance Prelude.Hashable TopicFilter

instance Prelude.NFData TopicFilter

instance Core.ToJSON TopicFilter where
  toJSON :: TopicFilter -> Value
toJSON TopicFilter' {Maybe Bool
Maybe Text
useDefaultIfPreferenceUnavailable :: Maybe Bool
topicName :: Maybe Text
$sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: TopicFilter -> Maybe Bool
$sel:topicName:TopicFilter' :: TopicFilter -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TopicName" 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
topicName,
            (Text
"UseDefaultIfPreferenceUnavailable" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
useDefaultIfPreferenceUnavailable
          ]
      )