{-# 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.SESV2.GetBlacklistReports
-- 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)
--
-- Retrieve a list of the blacklists that your dedicated IP addresses
-- appear on.
module Amazonka.SESV2.GetBlacklistReports
  ( -- * Creating a Request
    GetBlacklistReports (..),
    newGetBlacklistReports,

    -- * Request Lenses
    getBlacklistReports_blacklistItemNames,

    -- * Destructuring the Response
    GetBlacklistReportsResponse (..),
    newGetBlacklistReportsResponse,

    -- * Response Lenses
    getBlacklistReportsResponse_httpStatus,
    getBlacklistReportsResponse_blacklistReport,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SESV2.Types

-- | A request to retrieve a list of the blacklists that your dedicated IP
-- addresses appear on.
--
-- /See:/ 'newGetBlacklistReports' smart constructor.
data GetBlacklistReports = GetBlacklistReports'
  { -- | A list of IP addresses that you want to retrieve blacklist information
    -- about. You can only specify the dedicated IP addresses that you use to
    -- send email using Amazon SES or Amazon Pinpoint.
    GetBlacklistReports -> [Text]
blacklistItemNames :: [Prelude.Text]
  }
  deriving (GetBlacklistReports -> GetBlacklistReports -> Bool
(GetBlacklistReports -> GetBlacklistReports -> Bool)
-> (GetBlacklistReports -> GetBlacklistReports -> Bool)
-> Eq GetBlacklistReports
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBlacklistReports -> GetBlacklistReports -> Bool
$c/= :: GetBlacklistReports -> GetBlacklistReports -> Bool
== :: GetBlacklistReports -> GetBlacklistReports -> Bool
$c== :: GetBlacklistReports -> GetBlacklistReports -> Bool
Prelude.Eq, ReadPrec [GetBlacklistReports]
ReadPrec GetBlacklistReports
Int -> ReadS GetBlacklistReports
ReadS [GetBlacklistReports]
(Int -> ReadS GetBlacklistReports)
-> ReadS [GetBlacklistReports]
-> ReadPrec GetBlacklistReports
-> ReadPrec [GetBlacklistReports]
-> Read GetBlacklistReports
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBlacklistReports]
$creadListPrec :: ReadPrec [GetBlacklistReports]
readPrec :: ReadPrec GetBlacklistReports
$creadPrec :: ReadPrec GetBlacklistReports
readList :: ReadS [GetBlacklistReports]
$creadList :: ReadS [GetBlacklistReports]
readsPrec :: Int -> ReadS GetBlacklistReports
$creadsPrec :: Int -> ReadS GetBlacklistReports
Prelude.Read, Int -> GetBlacklistReports -> ShowS
[GetBlacklistReports] -> ShowS
GetBlacklistReports -> String
(Int -> GetBlacklistReports -> ShowS)
-> (GetBlacklistReports -> String)
-> ([GetBlacklistReports] -> ShowS)
-> Show GetBlacklistReports
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBlacklistReports] -> ShowS
$cshowList :: [GetBlacklistReports] -> ShowS
show :: GetBlacklistReports -> String
$cshow :: GetBlacklistReports -> String
showsPrec :: Int -> GetBlacklistReports -> ShowS
$cshowsPrec :: Int -> GetBlacklistReports -> ShowS
Prelude.Show, (forall x. GetBlacklistReports -> Rep GetBlacklistReports x)
-> (forall x. Rep GetBlacklistReports x -> GetBlacklistReports)
-> Generic GetBlacklistReports
forall x. Rep GetBlacklistReports x -> GetBlacklistReports
forall x. GetBlacklistReports -> Rep GetBlacklistReports x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBlacklistReports x -> GetBlacklistReports
$cfrom :: forall x. GetBlacklistReports -> Rep GetBlacklistReports x
Prelude.Generic)

-- |
-- Create a value of 'GetBlacklistReports' 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:
--
-- 'blacklistItemNames', 'getBlacklistReports_blacklistItemNames' - A list of IP addresses that you want to retrieve blacklist information
-- about. You can only specify the dedicated IP addresses that you use to
-- send email using Amazon SES or Amazon Pinpoint.
newGetBlacklistReports ::
  GetBlacklistReports
newGetBlacklistReports :: GetBlacklistReports
newGetBlacklistReports =
  GetBlacklistReports' :: [Text] -> GetBlacklistReports
GetBlacklistReports'
    { $sel:blacklistItemNames:GetBlacklistReports' :: [Text]
blacklistItemNames =
        [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A list of IP addresses that you want to retrieve blacklist information
-- about. You can only specify the dedicated IP addresses that you use to
-- send email using Amazon SES or Amazon Pinpoint.
getBlacklistReports_blacklistItemNames :: Lens.Lens' GetBlacklistReports [Prelude.Text]
getBlacklistReports_blacklistItemNames :: ([Text] -> f [Text])
-> GetBlacklistReports -> f GetBlacklistReports
getBlacklistReports_blacklistItemNames = (GetBlacklistReports -> [Text])
-> (GetBlacklistReports -> [Text] -> GetBlacklistReports)
-> Lens GetBlacklistReports GetBlacklistReports [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlacklistReports' {[Text]
blacklistItemNames :: [Text]
$sel:blacklistItemNames:GetBlacklistReports' :: GetBlacklistReports -> [Text]
blacklistItemNames} -> [Text]
blacklistItemNames) (\s :: GetBlacklistReports
s@GetBlacklistReports' {} [Text]
a -> GetBlacklistReports
s {$sel:blacklistItemNames:GetBlacklistReports' :: [Text]
blacklistItemNames = [Text]
a} :: GetBlacklistReports) (([Text] -> f [Text])
 -> GetBlacklistReports -> f GetBlacklistReports)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> GetBlacklistReports
-> f GetBlacklistReports
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest GetBlacklistReports where
  type
    AWSResponse GetBlacklistReports =
      GetBlacklistReportsResponse
  request :: GetBlacklistReports -> Request GetBlacklistReports
request = Service -> GetBlacklistReports -> Request GetBlacklistReports
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetBlacklistReports
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetBlacklistReports)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetBlacklistReports))
-> Logger
-> Service
-> Proxy GetBlacklistReports
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetBlacklistReports)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> HashMap Text [BlacklistEntry] -> GetBlacklistReportsResponse
GetBlacklistReportsResponse'
            (Int
 -> HashMap Text [BlacklistEntry] -> GetBlacklistReportsResponse)
-> Either String Int
-> Either
     String
     (HashMap Text [BlacklistEntry] -> GetBlacklistReportsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String
  (HashMap Text [BlacklistEntry] -> GetBlacklistReportsResponse)
-> Either String (HashMap Text [BlacklistEntry])
-> Either String GetBlacklistReportsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Either String (Maybe (HashMap Text [BlacklistEntry]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"BlacklistReport"
                            Either String (Maybe (HashMap Text [BlacklistEntry]))
-> HashMap Text [BlacklistEntry]
-> Either String (HashMap Text [BlacklistEntry])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ HashMap Text [BlacklistEntry]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable GetBlacklistReports

instance Prelude.NFData GetBlacklistReports

instance Core.ToHeaders GetBlacklistReports where
  toHeaders :: GetBlacklistReports -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetBlacklistReports -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath GetBlacklistReports where
  toPath :: GetBlacklistReports -> ByteString
toPath =
    ByteString -> GetBlacklistReports -> ByteString
forall a b. a -> b -> a
Prelude.const
      ByteString
"/v2/email/deliverability-dashboard/blacklist-report"

instance Core.ToQuery GetBlacklistReports where
  toQuery :: GetBlacklistReports -> QueryString
toQuery GetBlacklistReports' {[Text]
blacklistItemNames :: [Text]
$sel:blacklistItemNames:GetBlacklistReports' :: GetBlacklistReports -> [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"BlacklistItemNames"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [Text]
blacklistItemNames
      ]

-- | An object that contains information about blacklist events.
--
-- /See:/ 'newGetBlacklistReportsResponse' smart constructor.
data GetBlacklistReportsResponse = GetBlacklistReportsResponse'
  { -- | The response's http status code.
    GetBlacklistReportsResponse -> Int
httpStatus :: Prelude.Int,
    -- | An object that contains information about a blacklist that one of your
    -- dedicated IP addresses appears on.
    GetBlacklistReportsResponse -> HashMap Text [BlacklistEntry]
blacklistReport :: Prelude.HashMap Prelude.Text [BlacklistEntry]
  }
  deriving (GetBlacklistReportsResponse -> GetBlacklistReportsResponse -> Bool
(GetBlacklistReportsResponse
 -> GetBlacklistReportsResponse -> Bool)
-> (GetBlacklistReportsResponse
    -> GetBlacklistReportsResponse -> Bool)
-> Eq GetBlacklistReportsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBlacklistReportsResponse -> GetBlacklistReportsResponse -> Bool
$c/= :: GetBlacklistReportsResponse -> GetBlacklistReportsResponse -> Bool
== :: GetBlacklistReportsResponse -> GetBlacklistReportsResponse -> Bool
$c== :: GetBlacklistReportsResponse -> GetBlacklistReportsResponse -> Bool
Prelude.Eq, ReadPrec [GetBlacklistReportsResponse]
ReadPrec GetBlacklistReportsResponse
Int -> ReadS GetBlacklistReportsResponse
ReadS [GetBlacklistReportsResponse]
(Int -> ReadS GetBlacklistReportsResponse)
-> ReadS [GetBlacklistReportsResponse]
-> ReadPrec GetBlacklistReportsResponse
-> ReadPrec [GetBlacklistReportsResponse]
-> Read GetBlacklistReportsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBlacklistReportsResponse]
$creadListPrec :: ReadPrec [GetBlacklistReportsResponse]
readPrec :: ReadPrec GetBlacklistReportsResponse
$creadPrec :: ReadPrec GetBlacklistReportsResponse
readList :: ReadS [GetBlacklistReportsResponse]
$creadList :: ReadS [GetBlacklistReportsResponse]
readsPrec :: Int -> ReadS GetBlacklistReportsResponse
$creadsPrec :: Int -> ReadS GetBlacklistReportsResponse
Prelude.Read, Int -> GetBlacklistReportsResponse -> ShowS
[GetBlacklistReportsResponse] -> ShowS
GetBlacklistReportsResponse -> String
(Int -> GetBlacklistReportsResponse -> ShowS)
-> (GetBlacklistReportsResponse -> String)
-> ([GetBlacklistReportsResponse] -> ShowS)
-> Show GetBlacklistReportsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBlacklistReportsResponse] -> ShowS
$cshowList :: [GetBlacklistReportsResponse] -> ShowS
show :: GetBlacklistReportsResponse -> String
$cshow :: GetBlacklistReportsResponse -> String
showsPrec :: Int -> GetBlacklistReportsResponse -> ShowS
$cshowsPrec :: Int -> GetBlacklistReportsResponse -> ShowS
Prelude.Show, (forall x.
 GetBlacklistReportsResponse -> Rep GetBlacklistReportsResponse x)
-> (forall x.
    Rep GetBlacklistReportsResponse x -> GetBlacklistReportsResponse)
-> Generic GetBlacklistReportsResponse
forall x.
Rep GetBlacklistReportsResponse x -> GetBlacklistReportsResponse
forall x.
GetBlacklistReportsResponse -> Rep GetBlacklistReportsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetBlacklistReportsResponse x -> GetBlacklistReportsResponse
$cfrom :: forall x.
GetBlacklistReportsResponse -> Rep GetBlacklistReportsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetBlacklistReportsResponse' 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', 'getBlacklistReportsResponse_httpStatus' - The response's http status code.
--
-- 'blacklistReport', 'getBlacklistReportsResponse_blacklistReport' - An object that contains information about a blacklist that one of your
-- dedicated IP addresses appears on.
newGetBlacklistReportsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetBlacklistReportsResponse
newGetBlacklistReportsResponse :: Int -> GetBlacklistReportsResponse
newGetBlacklistReportsResponse Int
pHttpStatus_ =
  GetBlacklistReportsResponse' :: Int -> HashMap Text [BlacklistEntry] -> GetBlacklistReportsResponse
GetBlacklistReportsResponse'
    { $sel:httpStatus:GetBlacklistReportsResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:blacklistReport:GetBlacklistReportsResponse' :: HashMap Text [BlacklistEntry]
blacklistReport = HashMap Text [BlacklistEntry]
forall a. Monoid a => a
Prelude.mempty
    }

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

-- | An object that contains information about a blacklist that one of your
-- dedicated IP addresses appears on.
getBlacklistReportsResponse_blacklistReport :: Lens.Lens' GetBlacklistReportsResponse (Prelude.HashMap Prelude.Text [BlacklistEntry])
getBlacklistReportsResponse_blacklistReport :: (HashMap Text [BlacklistEntry]
 -> f (HashMap Text [BlacklistEntry]))
-> GetBlacklistReportsResponse -> f GetBlacklistReportsResponse
getBlacklistReportsResponse_blacklistReport = (GetBlacklistReportsResponse -> HashMap Text [BlacklistEntry])
-> (GetBlacklistReportsResponse
    -> HashMap Text [BlacklistEntry] -> GetBlacklistReportsResponse)
-> Lens
     GetBlacklistReportsResponse
     GetBlacklistReportsResponse
     (HashMap Text [BlacklistEntry])
     (HashMap Text [BlacklistEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlacklistReportsResponse' {HashMap Text [BlacklistEntry]
blacklistReport :: HashMap Text [BlacklistEntry]
$sel:blacklistReport:GetBlacklistReportsResponse' :: GetBlacklistReportsResponse -> HashMap Text [BlacklistEntry]
blacklistReport} -> HashMap Text [BlacklistEntry]
blacklistReport) (\s :: GetBlacklistReportsResponse
s@GetBlacklistReportsResponse' {} HashMap Text [BlacklistEntry]
a -> GetBlacklistReportsResponse
s {$sel:blacklistReport:GetBlacklistReportsResponse' :: HashMap Text [BlacklistEntry]
blacklistReport = HashMap Text [BlacklistEntry]
a} :: GetBlacklistReportsResponse) ((HashMap Text [BlacklistEntry]
  -> f (HashMap Text [BlacklistEntry]))
 -> GetBlacklistReportsResponse -> f GetBlacklistReportsResponse)
-> ((HashMap Text [BlacklistEntry]
     -> f (HashMap Text [BlacklistEntry]))
    -> HashMap Text [BlacklistEntry]
    -> f (HashMap Text [BlacklistEntry]))
-> (HashMap Text [BlacklistEntry]
    -> f (HashMap Text [BlacklistEntry]))
-> GetBlacklistReportsResponse
-> f GetBlacklistReportsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text [BlacklistEntry]
 -> f (HashMap Text [BlacklistEntry]))
-> HashMap Text [BlacklistEntry]
-> f (HashMap Text [BlacklistEntry])
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData GetBlacklistReportsResponse