{-# 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.PinpointEmail.Types.IdentityInfo
-- 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.PinpointEmail.Types.IdentityInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.PinpointEmail.Types.IdentityType
import qualified Amazonka.Prelude as Prelude

-- | Information about an email identity.
--
-- /See:/ 'newIdentityInfo' smart constructor.
data IdentityInfo = IdentityInfo'
  { -- | The email identity type. The identity type can be one of the following:
    --
    -- -   @EMAIL_ADDRESS@ – The identity is an email address.
    --
    -- -   @DOMAIN@ – The identity is a domain.
    --
    -- -   @MANAGED_DOMAIN@ – The identity is a domain that is managed by AWS.
    IdentityInfo -> Maybe IdentityType
identityType :: Prelude.Maybe IdentityType,
    -- | The address or domain of the identity.
    IdentityInfo -> Maybe Text
identityName :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether or not you can send email from the identity.
    --
    -- In Amazon Pinpoint, an identity is an email address or domain that you
    -- send email from. Before you can send email from an identity, you have to
    -- demostrate that you own the identity, and that you authorize Amazon
    -- Pinpoint to send email from that identity.
    IdentityInfo -> Maybe Bool
sendingEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (IdentityInfo -> IdentityInfo -> Bool
(IdentityInfo -> IdentityInfo -> Bool)
-> (IdentityInfo -> IdentityInfo -> Bool) -> Eq IdentityInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IdentityInfo -> IdentityInfo -> Bool
$c/= :: IdentityInfo -> IdentityInfo -> Bool
== :: IdentityInfo -> IdentityInfo -> Bool
$c== :: IdentityInfo -> IdentityInfo -> Bool
Prelude.Eq, ReadPrec [IdentityInfo]
ReadPrec IdentityInfo
Int -> ReadS IdentityInfo
ReadS [IdentityInfo]
(Int -> ReadS IdentityInfo)
-> ReadS [IdentityInfo]
-> ReadPrec IdentityInfo
-> ReadPrec [IdentityInfo]
-> Read IdentityInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IdentityInfo]
$creadListPrec :: ReadPrec [IdentityInfo]
readPrec :: ReadPrec IdentityInfo
$creadPrec :: ReadPrec IdentityInfo
readList :: ReadS [IdentityInfo]
$creadList :: ReadS [IdentityInfo]
readsPrec :: Int -> ReadS IdentityInfo
$creadsPrec :: Int -> ReadS IdentityInfo
Prelude.Read, Int -> IdentityInfo -> ShowS
[IdentityInfo] -> ShowS
IdentityInfo -> String
(Int -> IdentityInfo -> ShowS)
-> (IdentityInfo -> String)
-> ([IdentityInfo] -> ShowS)
-> Show IdentityInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdentityInfo] -> ShowS
$cshowList :: [IdentityInfo] -> ShowS
show :: IdentityInfo -> String
$cshow :: IdentityInfo -> String
showsPrec :: Int -> IdentityInfo -> ShowS
$cshowsPrec :: Int -> IdentityInfo -> ShowS
Prelude.Show, (forall x. IdentityInfo -> Rep IdentityInfo x)
-> (forall x. Rep IdentityInfo x -> IdentityInfo)
-> Generic IdentityInfo
forall x. Rep IdentityInfo x -> IdentityInfo
forall x. IdentityInfo -> Rep IdentityInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IdentityInfo x -> IdentityInfo
$cfrom :: forall x. IdentityInfo -> Rep IdentityInfo x
Prelude.Generic)

-- |
-- Create a value of 'IdentityInfo' 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:
--
-- 'identityType', 'identityInfo_identityType' - The email identity type. The identity type can be one of the following:
--
-- -   @EMAIL_ADDRESS@ – The identity is an email address.
--
-- -   @DOMAIN@ – The identity is a domain.
--
-- -   @MANAGED_DOMAIN@ – The identity is a domain that is managed by AWS.
--
-- 'identityName', 'identityInfo_identityName' - The address or domain of the identity.
--
-- 'sendingEnabled', 'identityInfo_sendingEnabled' - Indicates whether or not you can send email from the identity.
--
-- In Amazon Pinpoint, an identity is an email address or domain that you
-- send email from. Before you can send email from an identity, you have to
-- demostrate that you own the identity, and that you authorize Amazon
-- Pinpoint to send email from that identity.
newIdentityInfo ::
  IdentityInfo
newIdentityInfo :: IdentityInfo
newIdentityInfo =
  IdentityInfo' :: Maybe IdentityType -> Maybe Text -> Maybe Bool -> IdentityInfo
IdentityInfo'
    { $sel:identityType:IdentityInfo' :: Maybe IdentityType
identityType = Maybe IdentityType
forall a. Maybe a
Prelude.Nothing,
      $sel:identityName:IdentityInfo' :: Maybe Text
identityName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sendingEnabled:IdentityInfo' :: Maybe Bool
sendingEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The email identity type. The identity type can be one of the following:
--
-- -   @EMAIL_ADDRESS@ – The identity is an email address.
--
-- -   @DOMAIN@ – The identity is a domain.
--
-- -   @MANAGED_DOMAIN@ – The identity is a domain that is managed by AWS.
identityInfo_identityType :: Lens.Lens' IdentityInfo (Prelude.Maybe IdentityType)
identityInfo_identityType :: (Maybe IdentityType -> f (Maybe IdentityType))
-> IdentityInfo -> f IdentityInfo
identityInfo_identityType = (IdentityInfo -> Maybe IdentityType)
-> (IdentityInfo -> Maybe IdentityType -> IdentityInfo)
-> Lens
     IdentityInfo IdentityInfo (Maybe IdentityType) (Maybe IdentityType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityInfo' {Maybe IdentityType
identityType :: Maybe IdentityType
$sel:identityType:IdentityInfo' :: IdentityInfo -> Maybe IdentityType
identityType} -> Maybe IdentityType
identityType) (\s :: IdentityInfo
s@IdentityInfo' {} Maybe IdentityType
a -> IdentityInfo
s {$sel:identityType:IdentityInfo' :: Maybe IdentityType
identityType = Maybe IdentityType
a} :: IdentityInfo)

-- | The address or domain of the identity.
identityInfo_identityName :: Lens.Lens' IdentityInfo (Prelude.Maybe Prelude.Text)
identityInfo_identityName :: (Maybe Text -> f (Maybe Text)) -> IdentityInfo -> f IdentityInfo
identityInfo_identityName = (IdentityInfo -> Maybe Text)
-> (IdentityInfo -> Maybe Text -> IdentityInfo)
-> Lens IdentityInfo IdentityInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityInfo' {Maybe Text
identityName :: Maybe Text
$sel:identityName:IdentityInfo' :: IdentityInfo -> Maybe Text
identityName} -> Maybe Text
identityName) (\s :: IdentityInfo
s@IdentityInfo' {} Maybe Text
a -> IdentityInfo
s {$sel:identityName:IdentityInfo' :: Maybe Text
identityName = Maybe Text
a} :: IdentityInfo)

-- | Indicates whether or not you can send email from the identity.
--
-- In Amazon Pinpoint, an identity is an email address or domain that you
-- send email from. Before you can send email from an identity, you have to
-- demostrate that you own the identity, and that you authorize Amazon
-- Pinpoint to send email from that identity.
identityInfo_sendingEnabled :: Lens.Lens' IdentityInfo (Prelude.Maybe Prelude.Bool)
identityInfo_sendingEnabled :: (Maybe Bool -> f (Maybe Bool)) -> IdentityInfo -> f IdentityInfo
identityInfo_sendingEnabled = (IdentityInfo -> Maybe Bool)
-> (IdentityInfo -> Maybe Bool -> IdentityInfo)
-> Lens IdentityInfo IdentityInfo (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityInfo' {Maybe Bool
sendingEnabled :: Maybe Bool
$sel:sendingEnabled:IdentityInfo' :: IdentityInfo -> Maybe Bool
sendingEnabled} -> Maybe Bool
sendingEnabled) (\s :: IdentityInfo
s@IdentityInfo' {} Maybe Bool
a -> IdentityInfo
s {$sel:sendingEnabled:IdentityInfo' :: Maybe Bool
sendingEnabled = Maybe Bool
a} :: IdentityInfo)

instance Core.FromJSON IdentityInfo where
  parseJSON :: Value -> Parser IdentityInfo
parseJSON =
    String
-> (Object -> Parser IdentityInfo) -> Value -> Parser IdentityInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IdentityInfo"
      ( \Object
x ->
          Maybe IdentityType -> Maybe Text -> Maybe Bool -> IdentityInfo
IdentityInfo'
            (Maybe IdentityType -> Maybe Text -> Maybe Bool -> IdentityInfo)
-> Parser (Maybe IdentityType)
-> Parser (Maybe Text -> Maybe Bool -> IdentityInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe IdentityType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IdentityType")
            Parser (Maybe Text -> Maybe Bool -> IdentityInfo)
-> Parser (Maybe Text) -> Parser (Maybe Bool -> IdentityInfo)
forall (f :: * -> *) a b. Applicative f => 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
"IdentityName")
            Parser (Maybe Bool -> IdentityInfo)
-> Parser (Maybe Bool) -> Parser IdentityInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SendingEnabled")
      )

instance Prelude.Hashable IdentityInfo

instance Prelude.NFData IdentityInfo