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

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

-- | An object that contains details about the action of a contact list.
--
-- /See:/ 'newContactListDestination' smart constructor.
data ContactListDestination = ContactListDestination'
  { -- | The name of the contact list.
    ContactListDestination -> Text
contactListName :: Prelude.Text,
    -- | >The type of action to perform on the addresses. The following are the
    -- possible values:
    --
    -- -   PUT: add the addresses to the contact list. If the record already
    --     exists, it will override it with the new value.
    --
    -- -   DELETE: remove the addresses from the contact list.
    ContactListDestination -> ContactListImportAction
contactListImportAction :: ContactListImportAction
  }
  deriving (ContactListDestination -> ContactListDestination -> Bool
(ContactListDestination -> ContactListDestination -> Bool)
-> (ContactListDestination -> ContactListDestination -> Bool)
-> Eq ContactListDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContactListDestination -> ContactListDestination -> Bool
$c/= :: ContactListDestination -> ContactListDestination -> Bool
== :: ContactListDestination -> ContactListDestination -> Bool
$c== :: ContactListDestination -> ContactListDestination -> Bool
Prelude.Eq, ReadPrec [ContactListDestination]
ReadPrec ContactListDestination
Int -> ReadS ContactListDestination
ReadS [ContactListDestination]
(Int -> ReadS ContactListDestination)
-> ReadS [ContactListDestination]
-> ReadPrec ContactListDestination
-> ReadPrec [ContactListDestination]
-> Read ContactListDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContactListDestination]
$creadListPrec :: ReadPrec [ContactListDestination]
readPrec :: ReadPrec ContactListDestination
$creadPrec :: ReadPrec ContactListDestination
readList :: ReadS [ContactListDestination]
$creadList :: ReadS [ContactListDestination]
readsPrec :: Int -> ReadS ContactListDestination
$creadsPrec :: Int -> ReadS ContactListDestination
Prelude.Read, Int -> ContactListDestination -> ShowS
[ContactListDestination] -> ShowS
ContactListDestination -> String
(Int -> ContactListDestination -> ShowS)
-> (ContactListDestination -> String)
-> ([ContactListDestination] -> ShowS)
-> Show ContactListDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContactListDestination] -> ShowS
$cshowList :: [ContactListDestination] -> ShowS
show :: ContactListDestination -> String
$cshow :: ContactListDestination -> String
showsPrec :: Int -> ContactListDestination -> ShowS
$cshowsPrec :: Int -> ContactListDestination -> ShowS
Prelude.Show, (forall x. ContactListDestination -> Rep ContactListDestination x)
-> (forall x.
    Rep ContactListDestination x -> ContactListDestination)
-> Generic ContactListDestination
forall x. Rep ContactListDestination x -> ContactListDestination
forall x. ContactListDestination -> Rep ContactListDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContactListDestination x -> ContactListDestination
$cfrom :: forall x. ContactListDestination -> Rep ContactListDestination x
Prelude.Generic)

-- |
-- Create a value of 'ContactListDestination' 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:
--
-- 'contactListName', 'contactListDestination_contactListName' - The name of the contact list.
--
-- 'contactListImportAction', 'contactListDestination_contactListImportAction' - >The type of action to perform on the addresses. The following are the
-- possible values:
--
-- -   PUT: add the addresses to the contact list. If the record already
--     exists, it will override it with the new value.
--
-- -   DELETE: remove the addresses from the contact list.
newContactListDestination ::
  -- | 'contactListName'
  Prelude.Text ->
  -- | 'contactListImportAction'
  ContactListImportAction ->
  ContactListDestination
newContactListDestination :: Text -> ContactListImportAction -> ContactListDestination
newContactListDestination
  Text
pContactListName_
  ContactListImportAction
pContactListImportAction_ =
    ContactListDestination' :: Text -> ContactListImportAction -> ContactListDestination
ContactListDestination'
      { $sel:contactListName:ContactListDestination' :: Text
contactListName =
          Text
pContactListName_,
        $sel:contactListImportAction:ContactListDestination' :: ContactListImportAction
contactListImportAction = ContactListImportAction
pContactListImportAction_
      }

-- | The name of the contact list.
contactListDestination_contactListName :: Lens.Lens' ContactListDestination Prelude.Text
contactListDestination_contactListName :: (Text -> f Text)
-> ContactListDestination -> f ContactListDestination
contactListDestination_contactListName = (ContactListDestination -> Text)
-> (ContactListDestination -> Text -> ContactListDestination)
-> Lens ContactListDestination ContactListDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactListDestination' {Text
contactListName :: Text
$sel:contactListName:ContactListDestination' :: ContactListDestination -> Text
contactListName} -> Text
contactListName) (\s :: ContactListDestination
s@ContactListDestination' {} Text
a -> ContactListDestination
s {$sel:contactListName:ContactListDestination' :: Text
contactListName = Text
a} :: ContactListDestination)

-- | >The type of action to perform on the addresses. The following are the
-- possible values:
--
-- -   PUT: add the addresses to the contact list. If the record already
--     exists, it will override it with the new value.
--
-- -   DELETE: remove the addresses from the contact list.
contactListDestination_contactListImportAction :: Lens.Lens' ContactListDestination ContactListImportAction
contactListDestination_contactListImportAction :: (ContactListImportAction -> f ContactListImportAction)
-> ContactListDestination -> f ContactListDestination
contactListDestination_contactListImportAction = (ContactListDestination -> ContactListImportAction)
-> (ContactListDestination
    -> ContactListImportAction -> ContactListDestination)
-> Lens
     ContactListDestination
     ContactListDestination
     ContactListImportAction
     ContactListImportAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactListDestination' {ContactListImportAction
contactListImportAction :: ContactListImportAction
$sel:contactListImportAction:ContactListDestination' :: ContactListDestination -> ContactListImportAction
contactListImportAction} -> ContactListImportAction
contactListImportAction) (\s :: ContactListDestination
s@ContactListDestination' {} ContactListImportAction
a -> ContactListDestination
s {$sel:contactListImportAction:ContactListDestination' :: ContactListImportAction
contactListImportAction = ContactListImportAction
a} :: ContactListDestination)

instance Core.FromJSON ContactListDestination where
  parseJSON :: Value -> Parser ContactListDestination
parseJSON =
    String
-> (Object -> Parser ContactListDestination)
-> Value
-> Parser ContactListDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContactListDestination"
      ( \Object
x ->
          Text -> ContactListImportAction -> ContactListDestination
ContactListDestination'
            (Text -> ContactListImportAction -> ContactListDestination)
-> Parser Text
-> Parser (ContactListImportAction -> ContactListDestination)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ContactListName")
            Parser (ContactListImportAction -> ContactListDestination)
-> Parser ContactListImportAction -> Parser ContactListDestination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ContactListImportAction
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ContactListImportAction")
      )

instance Prelude.Hashable ContactListDestination

instance Prelude.NFData ContactListDestination

instance Core.ToJSON ContactListDestination where
  toJSON :: ContactListDestination -> Value
toJSON ContactListDestination' {Text
ContactListImportAction
contactListImportAction :: ContactListImportAction
contactListName :: Text
$sel:contactListImportAction:ContactListDestination' :: ContactListDestination -> ContactListImportAction
$sel:contactListName:ContactListDestination' :: ContactListDestination -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ContactListName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contactListName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ContactListImportAction"
                  Text -> ContactListImportAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ContactListImportAction
contactListImportAction
              )
          ]
      )