{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SESV2.Types.ContactListDestination where

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
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
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]
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
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. 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'
      { $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 :: Lens' ContactListDestination Text
contactListDestination_contactListName = 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 :: Lens' ContactListDestination ContactListImportAction
contactListDestination_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 Data.FromJSON ContactListDestination where
  parseJSON :: Value -> Parser ContactListDestination
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContactListDestination"
      ( \Object
x ->
          Text -> ContactListImportAction -> ContactListDestination
ContactListDestination'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ContactListName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ContactListImportAction")
      )

instance Prelude.Hashable ContactListDestination where
  hashWithSalt :: Int -> ContactListDestination -> Int
hashWithSalt Int
_salt ContactListDestination' {Text
ContactListImportAction
contactListImportAction :: ContactListImportAction
contactListName :: Text
$sel:contactListImportAction:ContactListDestination' :: ContactListDestination -> ContactListImportAction
$sel:contactListName:ContactListDestination' :: ContactListDestination -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contactListName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ContactListImportAction
contactListImportAction

instance Prelude.NFData ContactListDestination where
  rnf :: ContactListDestination -> ()
rnf ContactListDestination' {Text
ContactListImportAction
contactListImportAction :: ContactListImportAction
contactListName :: Text
$sel:contactListImportAction:ContactListDestination' :: ContactListDestination -> ContactListImportAction
$sel:contactListName:ContactListDestination' :: ContactListDestination -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
contactListName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ContactListImportAction
contactListImportAction

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ContactListName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
contactListName),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"ContactListImportAction"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ContactListImportAction
contactListImportAction
              )
          ]
      )