{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SES.GetIdentityMailFromDomainAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the custom MAIL FROM attributes for a list of identities (email
-- addresses : domains).
--
-- This operation is throttled at one request per second and can only get
-- custom MAIL FROM attributes for up to 100 identities at a time.
module Amazonka.SES.GetIdentityMailFromDomainAttributes
  ( -- * Creating a Request
    GetIdentityMailFromDomainAttributes (..),
    newGetIdentityMailFromDomainAttributes,

    -- * Request Lenses
    getIdentityMailFromDomainAttributes_identities,

    -- * Destructuring the Response
    GetIdentityMailFromDomainAttributesResponse (..),
    newGetIdentityMailFromDomainAttributesResponse,

    -- * Response Lenses
    getIdentityMailFromDomainAttributesResponse_httpStatus,
    getIdentityMailFromDomainAttributesResponse_mailFromDomainAttributes,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SES.Types

-- | Represents a request to return the Amazon SES custom MAIL FROM
-- attributes for a list of identities. For information about using a
-- custom MAIL FROM domain, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/mail-from.html Amazon SES Developer Guide>.
--
-- /See:/ 'newGetIdentityMailFromDomainAttributes' smart constructor.
data GetIdentityMailFromDomainAttributes = GetIdentityMailFromDomainAttributes'
  { -- | A list of one or more identities.
    GetIdentityMailFromDomainAttributes -> [Text]
identities :: [Prelude.Text]
  }
  deriving (GetIdentityMailFromDomainAttributes
-> GetIdentityMailFromDomainAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIdentityMailFromDomainAttributes
-> GetIdentityMailFromDomainAttributes -> Bool
$c/= :: GetIdentityMailFromDomainAttributes
-> GetIdentityMailFromDomainAttributes -> Bool
== :: GetIdentityMailFromDomainAttributes
-> GetIdentityMailFromDomainAttributes -> Bool
$c== :: GetIdentityMailFromDomainAttributes
-> GetIdentityMailFromDomainAttributes -> Bool
Prelude.Eq, ReadPrec [GetIdentityMailFromDomainAttributes]
ReadPrec GetIdentityMailFromDomainAttributes
Int -> ReadS GetIdentityMailFromDomainAttributes
ReadS [GetIdentityMailFromDomainAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetIdentityMailFromDomainAttributes]
$creadListPrec :: ReadPrec [GetIdentityMailFromDomainAttributes]
readPrec :: ReadPrec GetIdentityMailFromDomainAttributes
$creadPrec :: ReadPrec GetIdentityMailFromDomainAttributes
readList :: ReadS [GetIdentityMailFromDomainAttributes]
$creadList :: ReadS [GetIdentityMailFromDomainAttributes]
readsPrec :: Int -> ReadS GetIdentityMailFromDomainAttributes
$creadsPrec :: Int -> ReadS GetIdentityMailFromDomainAttributes
Prelude.Read, Int -> GetIdentityMailFromDomainAttributes -> ShowS
[GetIdentityMailFromDomainAttributes] -> ShowS
GetIdentityMailFromDomainAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIdentityMailFromDomainAttributes] -> ShowS
$cshowList :: [GetIdentityMailFromDomainAttributes] -> ShowS
show :: GetIdentityMailFromDomainAttributes -> String
$cshow :: GetIdentityMailFromDomainAttributes -> String
showsPrec :: Int -> GetIdentityMailFromDomainAttributes -> ShowS
$cshowsPrec :: Int -> GetIdentityMailFromDomainAttributes -> ShowS
Prelude.Show, forall x.
Rep GetIdentityMailFromDomainAttributes x
-> GetIdentityMailFromDomainAttributes
forall x.
GetIdentityMailFromDomainAttributes
-> Rep GetIdentityMailFromDomainAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetIdentityMailFromDomainAttributes x
-> GetIdentityMailFromDomainAttributes
$cfrom :: forall x.
GetIdentityMailFromDomainAttributes
-> Rep GetIdentityMailFromDomainAttributes x
Prelude.Generic)

-- |
-- Create a value of 'GetIdentityMailFromDomainAttributes' 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:
--
-- 'identities', 'getIdentityMailFromDomainAttributes_identities' - A list of one or more identities.
newGetIdentityMailFromDomainAttributes ::
  GetIdentityMailFromDomainAttributes
newGetIdentityMailFromDomainAttributes :: GetIdentityMailFromDomainAttributes
newGetIdentityMailFromDomainAttributes =
  GetIdentityMailFromDomainAttributes'
    { $sel:identities:GetIdentityMailFromDomainAttributes' :: [Text]
identities =
        forall a. Monoid a => a
Prelude.mempty
    }

-- | A list of one or more identities.
getIdentityMailFromDomainAttributes_identities :: Lens.Lens' GetIdentityMailFromDomainAttributes [Prelude.Text]
getIdentityMailFromDomainAttributes_identities :: Lens' GetIdentityMailFromDomainAttributes [Text]
getIdentityMailFromDomainAttributes_identities = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIdentityMailFromDomainAttributes' {[Text]
identities :: [Text]
$sel:identities:GetIdentityMailFromDomainAttributes' :: GetIdentityMailFromDomainAttributes -> [Text]
identities} -> [Text]
identities) (\s :: GetIdentityMailFromDomainAttributes
s@GetIdentityMailFromDomainAttributes' {} [Text]
a -> GetIdentityMailFromDomainAttributes
s {$sel:identities:GetIdentityMailFromDomainAttributes' :: [Text]
identities = [Text]
a} :: GetIdentityMailFromDomainAttributes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.AWSRequest
    GetIdentityMailFromDomainAttributes
  where
  type
    AWSResponse GetIdentityMailFromDomainAttributes =
      GetIdentityMailFromDomainAttributesResponse
  request :: (Service -> Service)
-> GetIdentityMailFromDomainAttributes
-> Request GetIdentityMailFromDomainAttributes
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetIdentityMailFromDomainAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetIdentityMailFromDomainAttributes)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"GetIdentityMailFromDomainAttributesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int
-> HashMap Text IdentityMailFromDomainAttributes
-> GetIdentityMailFromDomainAttributesResponse
GetIdentityMailFromDomainAttributesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"MailFromDomainAttributes"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Data.parseXMLMap Text
"entry" Text
"key" Text
"value"
                        )
      )

instance
  Prelude.Hashable
    GetIdentityMailFromDomainAttributes
  where
  hashWithSalt :: Int -> GetIdentityMailFromDomainAttributes -> Int
hashWithSalt
    Int
_salt
    GetIdentityMailFromDomainAttributes' {[Text]
identities :: [Text]
$sel:identities:GetIdentityMailFromDomainAttributes' :: GetIdentityMailFromDomainAttributes -> [Text]
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
identities

instance
  Prelude.NFData
    GetIdentityMailFromDomainAttributes
  where
  rnf :: GetIdentityMailFromDomainAttributes -> ()
rnf GetIdentityMailFromDomainAttributes' {[Text]
identities :: [Text]
$sel:identities:GetIdentityMailFromDomainAttributes' :: GetIdentityMailFromDomainAttributes -> [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [Text]
identities

instance
  Data.ToHeaders
    GetIdentityMailFromDomainAttributes
  where
  toHeaders :: GetIdentityMailFromDomainAttributes -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance
  Data.ToPath
    GetIdentityMailFromDomainAttributes
  where
  toPath :: GetIdentityMailFromDomainAttributes -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance
  Data.ToQuery
    GetIdentityMailFromDomainAttributes
  where
  toQuery :: GetIdentityMailFromDomainAttributes -> QueryString
toQuery GetIdentityMailFromDomainAttributes' {[Text]
identities :: [Text]
$sel:identities:GetIdentityMailFromDomainAttributes' :: GetIdentityMailFromDomainAttributes -> [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ( ByteString
"GetIdentityMailFromDomainAttributes" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"Identities"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [Text]
identities
      ]

-- | Represents the custom MAIL FROM attributes for a list of identities.
--
-- /See:/ 'newGetIdentityMailFromDomainAttributesResponse' smart constructor.
data GetIdentityMailFromDomainAttributesResponse = GetIdentityMailFromDomainAttributesResponse'
  { -- | The response's http status code.
    GetIdentityMailFromDomainAttributesResponse -> Int
httpStatus :: Prelude.Int,
    -- | A map of identities to custom MAIL FROM attributes.
    GetIdentityMailFromDomainAttributesResponse
-> HashMap Text IdentityMailFromDomainAttributes
mailFromDomainAttributes :: Prelude.HashMap Prelude.Text IdentityMailFromDomainAttributes
  }
  deriving (GetIdentityMailFromDomainAttributesResponse
-> GetIdentityMailFromDomainAttributesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIdentityMailFromDomainAttributesResponse
-> GetIdentityMailFromDomainAttributesResponse -> Bool
$c/= :: GetIdentityMailFromDomainAttributesResponse
-> GetIdentityMailFromDomainAttributesResponse -> Bool
== :: GetIdentityMailFromDomainAttributesResponse
-> GetIdentityMailFromDomainAttributesResponse -> Bool
$c== :: GetIdentityMailFromDomainAttributesResponse
-> GetIdentityMailFromDomainAttributesResponse -> Bool
Prelude.Eq, ReadPrec [GetIdentityMailFromDomainAttributesResponse]
ReadPrec GetIdentityMailFromDomainAttributesResponse
Int -> ReadS GetIdentityMailFromDomainAttributesResponse
ReadS [GetIdentityMailFromDomainAttributesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetIdentityMailFromDomainAttributesResponse]
$creadListPrec :: ReadPrec [GetIdentityMailFromDomainAttributesResponse]
readPrec :: ReadPrec GetIdentityMailFromDomainAttributesResponse
$creadPrec :: ReadPrec GetIdentityMailFromDomainAttributesResponse
readList :: ReadS [GetIdentityMailFromDomainAttributesResponse]
$creadList :: ReadS [GetIdentityMailFromDomainAttributesResponse]
readsPrec :: Int -> ReadS GetIdentityMailFromDomainAttributesResponse
$creadsPrec :: Int -> ReadS GetIdentityMailFromDomainAttributesResponse
Prelude.Read, Int -> GetIdentityMailFromDomainAttributesResponse -> ShowS
[GetIdentityMailFromDomainAttributesResponse] -> ShowS
GetIdentityMailFromDomainAttributesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIdentityMailFromDomainAttributesResponse] -> ShowS
$cshowList :: [GetIdentityMailFromDomainAttributesResponse] -> ShowS
show :: GetIdentityMailFromDomainAttributesResponse -> String
$cshow :: GetIdentityMailFromDomainAttributesResponse -> String
showsPrec :: Int -> GetIdentityMailFromDomainAttributesResponse -> ShowS
$cshowsPrec :: Int -> GetIdentityMailFromDomainAttributesResponse -> ShowS
Prelude.Show, forall x.
Rep GetIdentityMailFromDomainAttributesResponse x
-> GetIdentityMailFromDomainAttributesResponse
forall x.
GetIdentityMailFromDomainAttributesResponse
-> Rep GetIdentityMailFromDomainAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetIdentityMailFromDomainAttributesResponse x
-> GetIdentityMailFromDomainAttributesResponse
$cfrom :: forall x.
GetIdentityMailFromDomainAttributesResponse
-> Rep GetIdentityMailFromDomainAttributesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetIdentityMailFromDomainAttributesResponse' 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:
--
-- 'httpStatus', 'getIdentityMailFromDomainAttributesResponse_httpStatus' - The response's http status code.
--
-- 'mailFromDomainAttributes', 'getIdentityMailFromDomainAttributesResponse_mailFromDomainAttributes' - A map of identities to custom MAIL FROM attributes.
newGetIdentityMailFromDomainAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetIdentityMailFromDomainAttributesResponse
newGetIdentityMailFromDomainAttributesResponse :: Int -> GetIdentityMailFromDomainAttributesResponse
newGetIdentityMailFromDomainAttributesResponse
  Int
pHttpStatus_ =
    GetIdentityMailFromDomainAttributesResponse'
      { $sel:httpStatus:GetIdentityMailFromDomainAttributesResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:mailFromDomainAttributes:GetIdentityMailFromDomainAttributesResponse' :: HashMap Text IdentityMailFromDomainAttributes
mailFromDomainAttributes =
          forall a. Monoid a => a
Prelude.mempty
      }

-- | The response's http status code.
getIdentityMailFromDomainAttributesResponse_httpStatus :: Lens.Lens' GetIdentityMailFromDomainAttributesResponse Prelude.Int
getIdentityMailFromDomainAttributesResponse_httpStatus :: Lens' GetIdentityMailFromDomainAttributesResponse Int
getIdentityMailFromDomainAttributesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIdentityMailFromDomainAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetIdentityMailFromDomainAttributesResponse' :: GetIdentityMailFromDomainAttributesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetIdentityMailFromDomainAttributesResponse
s@GetIdentityMailFromDomainAttributesResponse' {} Int
a -> GetIdentityMailFromDomainAttributesResponse
s {$sel:httpStatus:GetIdentityMailFromDomainAttributesResponse' :: Int
httpStatus = Int
a} :: GetIdentityMailFromDomainAttributesResponse)

-- | A map of identities to custom MAIL FROM attributes.
getIdentityMailFromDomainAttributesResponse_mailFromDomainAttributes :: Lens.Lens' GetIdentityMailFromDomainAttributesResponse (Prelude.HashMap Prelude.Text IdentityMailFromDomainAttributes)
getIdentityMailFromDomainAttributesResponse_mailFromDomainAttributes :: Lens'
  GetIdentityMailFromDomainAttributesResponse
  (HashMap Text IdentityMailFromDomainAttributes)
getIdentityMailFromDomainAttributesResponse_mailFromDomainAttributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIdentityMailFromDomainAttributesResponse' {HashMap Text IdentityMailFromDomainAttributes
mailFromDomainAttributes :: HashMap Text IdentityMailFromDomainAttributes
$sel:mailFromDomainAttributes:GetIdentityMailFromDomainAttributesResponse' :: GetIdentityMailFromDomainAttributesResponse
-> HashMap Text IdentityMailFromDomainAttributes
mailFromDomainAttributes} -> HashMap Text IdentityMailFromDomainAttributes
mailFromDomainAttributes) (\s :: GetIdentityMailFromDomainAttributesResponse
s@GetIdentityMailFromDomainAttributesResponse' {} HashMap Text IdentityMailFromDomainAttributes
a -> GetIdentityMailFromDomainAttributesResponse
s {$sel:mailFromDomainAttributes:GetIdentityMailFromDomainAttributesResponse' :: HashMap Text IdentityMailFromDomainAttributes
mailFromDomainAttributes = HashMap Text IdentityMailFromDomainAttributes
a} :: GetIdentityMailFromDomainAttributesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    GetIdentityMailFromDomainAttributesResponse
  where
  rnf :: GetIdentityMailFromDomainAttributesResponse -> ()
rnf GetIdentityMailFromDomainAttributesResponse' {Int
HashMap Text IdentityMailFromDomainAttributes
mailFromDomainAttributes :: HashMap Text IdentityMailFromDomainAttributes
httpStatus :: Int
$sel:mailFromDomainAttributes:GetIdentityMailFromDomainAttributesResponse' :: GetIdentityMailFromDomainAttributesResponse
-> HashMap Text IdentityMailFromDomainAttributes
$sel:httpStatus:GetIdentityMailFromDomainAttributesResponse' :: GetIdentityMailFromDomainAttributesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text IdentityMailFromDomainAttributes
mailFromDomainAttributes