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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SESV2.Types.ContactListDestination
import Amazonka.SESV2.Types.SuppressionListDestination

-- | An object that contains details about the resource destination the
-- import job is going to target.
--
-- /See:/ 'newImportDestination' smart constructor.
data ImportDestination = ImportDestination'
  { -- | An object that contains the action of the import job towards suppression
    -- list.
    ImportDestination -> Maybe SuppressionListDestination
suppressionListDestination :: Prelude.Maybe SuppressionListDestination,
    -- | An object that contains the action of the import job towards a contact
    -- list.
    ImportDestination -> Maybe ContactListDestination
contactListDestination :: Prelude.Maybe ContactListDestination
  }
  deriving (ImportDestination -> ImportDestination -> Bool
(ImportDestination -> ImportDestination -> Bool)
-> (ImportDestination -> ImportDestination -> Bool)
-> Eq ImportDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportDestination -> ImportDestination -> Bool
$c/= :: ImportDestination -> ImportDestination -> Bool
== :: ImportDestination -> ImportDestination -> Bool
$c== :: ImportDestination -> ImportDestination -> Bool
Prelude.Eq, ReadPrec [ImportDestination]
ReadPrec ImportDestination
Int -> ReadS ImportDestination
ReadS [ImportDestination]
(Int -> ReadS ImportDestination)
-> ReadS [ImportDestination]
-> ReadPrec ImportDestination
-> ReadPrec [ImportDestination]
-> Read ImportDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportDestination]
$creadListPrec :: ReadPrec [ImportDestination]
readPrec :: ReadPrec ImportDestination
$creadPrec :: ReadPrec ImportDestination
readList :: ReadS [ImportDestination]
$creadList :: ReadS [ImportDestination]
readsPrec :: Int -> ReadS ImportDestination
$creadsPrec :: Int -> ReadS ImportDestination
Prelude.Read, Int -> ImportDestination -> ShowS
[ImportDestination] -> ShowS
ImportDestination -> String
(Int -> ImportDestination -> ShowS)
-> (ImportDestination -> String)
-> ([ImportDestination] -> ShowS)
-> Show ImportDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportDestination] -> ShowS
$cshowList :: [ImportDestination] -> ShowS
show :: ImportDestination -> String
$cshow :: ImportDestination -> String
showsPrec :: Int -> ImportDestination -> ShowS
$cshowsPrec :: Int -> ImportDestination -> ShowS
Prelude.Show, (forall x. ImportDestination -> Rep ImportDestination x)
-> (forall x. Rep ImportDestination x -> ImportDestination)
-> Generic ImportDestination
forall x. Rep ImportDestination x -> ImportDestination
forall x. ImportDestination -> Rep ImportDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportDestination x -> ImportDestination
$cfrom :: forall x. ImportDestination -> Rep ImportDestination x
Prelude.Generic)

-- |
-- Create a value of 'ImportDestination' 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:
--
-- 'suppressionListDestination', 'importDestination_suppressionListDestination' - An object that contains the action of the import job towards suppression
-- list.
--
-- 'contactListDestination', 'importDestination_contactListDestination' - An object that contains the action of the import job towards a contact
-- list.
newImportDestination ::
  ImportDestination
newImportDestination :: ImportDestination
newImportDestination =
  ImportDestination' :: Maybe SuppressionListDestination
-> Maybe ContactListDestination -> ImportDestination
ImportDestination'
    { $sel:suppressionListDestination:ImportDestination' :: Maybe SuppressionListDestination
suppressionListDestination =
        Maybe SuppressionListDestination
forall a. Maybe a
Prelude.Nothing,
      $sel:contactListDestination:ImportDestination' :: Maybe ContactListDestination
contactListDestination = Maybe ContactListDestination
forall a. Maybe a
Prelude.Nothing
    }

-- | An object that contains the action of the import job towards suppression
-- list.
importDestination_suppressionListDestination :: Lens.Lens' ImportDestination (Prelude.Maybe SuppressionListDestination)
importDestination_suppressionListDestination :: (Maybe SuppressionListDestination
 -> f (Maybe SuppressionListDestination))
-> ImportDestination -> f ImportDestination
importDestination_suppressionListDestination = (ImportDestination -> Maybe SuppressionListDestination)
-> (ImportDestination
    -> Maybe SuppressionListDestination -> ImportDestination)
-> Lens
     ImportDestination
     ImportDestination
     (Maybe SuppressionListDestination)
     (Maybe SuppressionListDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportDestination' {Maybe SuppressionListDestination
suppressionListDestination :: Maybe SuppressionListDestination
$sel:suppressionListDestination:ImportDestination' :: ImportDestination -> Maybe SuppressionListDestination
suppressionListDestination} -> Maybe SuppressionListDestination
suppressionListDestination) (\s :: ImportDestination
s@ImportDestination' {} Maybe SuppressionListDestination
a -> ImportDestination
s {$sel:suppressionListDestination:ImportDestination' :: Maybe SuppressionListDestination
suppressionListDestination = Maybe SuppressionListDestination
a} :: ImportDestination)

-- | An object that contains the action of the import job towards a contact
-- list.
importDestination_contactListDestination :: Lens.Lens' ImportDestination (Prelude.Maybe ContactListDestination)
importDestination_contactListDestination :: (Maybe ContactListDestination -> f (Maybe ContactListDestination))
-> ImportDestination -> f ImportDestination
importDestination_contactListDestination = (ImportDestination -> Maybe ContactListDestination)
-> (ImportDestination
    -> Maybe ContactListDestination -> ImportDestination)
-> Lens
     ImportDestination
     ImportDestination
     (Maybe ContactListDestination)
     (Maybe ContactListDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportDestination' {Maybe ContactListDestination
contactListDestination :: Maybe ContactListDestination
$sel:contactListDestination:ImportDestination' :: ImportDestination -> Maybe ContactListDestination
contactListDestination} -> Maybe ContactListDestination
contactListDestination) (\s :: ImportDestination
s@ImportDestination' {} Maybe ContactListDestination
a -> ImportDestination
s {$sel:contactListDestination:ImportDestination' :: Maybe ContactListDestination
contactListDestination = Maybe ContactListDestination
a} :: ImportDestination)

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

instance Prelude.Hashable ImportDestination

instance Prelude.NFData ImportDestination

instance Core.ToJSON ImportDestination where
  toJSON :: ImportDestination -> Value
toJSON ImportDestination' {Maybe ContactListDestination
Maybe SuppressionListDestination
contactListDestination :: Maybe ContactListDestination
suppressionListDestination :: Maybe SuppressionListDestination
$sel:contactListDestination:ImportDestination' :: ImportDestination -> Maybe ContactListDestination
$sel:suppressionListDestination:ImportDestination' :: ImportDestination -> Maybe SuppressionListDestination
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SuppressionListDestination" Text -> SuppressionListDestination -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SuppressionListDestination -> Pair)
-> Maybe SuppressionListDestination -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SuppressionListDestination
suppressionListDestination,
            (Text
"ContactListDestination" Text -> ContactListDestination -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ContactListDestination -> Pair)
-> Maybe ContactListDestination -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ContactListDestination
contactListDestination
          ]
      )