{-# 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.ListEmailIdentities
-- 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 a list of all of the email identities that are associated with
-- your Amazon Web Services account. An identity can be either an email
-- address or a domain. This operation returns identities that are verified
-- as well as those that aren\'t. This operation returns identities that
-- are associated with Amazon SES and Amazon Pinpoint.
module Amazonka.SESV2.ListEmailIdentities
  ( -- * Creating a Request
    ListEmailIdentities (..),
    newListEmailIdentities,

    -- * Request Lenses
    listEmailIdentities_nextToken,
    listEmailIdentities_pageSize,

    -- * Destructuring the Response
    ListEmailIdentitiesResponse (..),
    newListEmailIdentitiesResponse,

    -- * Response Lenses
    listEmailIdentitiesResponse_emailIdentities,
    listEmailIdentitiesResponse_nextToken,
    listEmailIdentitiesResponse_httpStatus,
  )
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.SESV2.Types

-- | A request to list all of the email identities associated with your
-- Amazon Web Services account. This list includes identities that you\'ve
-- already verified, identities that are unverified, and identities that
-- were verified in the past, but are no longer verified.
--
-- /See:/ 'newListEmailIdentities' smart constructor.
data ListEmailIdentities = ListEmailIdentities'
  { -- | A token returned from a previous call to @ListEmailIdentities@ to
    -- indicate the position in the list of identities.
    ListEmailIdentities -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The number of results to show in a single call to @ListEmailIdentities@.
    -- If the number of results is larger than the number you specified in this
    -- parameter, then the response includes a @NextToken@ element, which you
    -- can use to obtain additional results.
    --
    -- The value you specify has to be at least 0, and can be no more than
    -- 1000.
    ListEmailIdentities -> Maybe Int
pageSize :: Prelude.Maybe Prelude.Int
  }
  deriving (ListEmailIdentities -> ListEmailIdentities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListEmailIdentities -> ListEmailIdentities -> Bool
$c/= :: ListEmailIdentities -> ListEmailIdentities -> Bool
== :: ListEmailIdentities -> ListEmailIdentities -> Bool
$c== :: ListEmailIdentities -> ListEmailIdentities -> Bool
Prelude.Eq, ReadPrec [ListEmailIdentities]
ReadPrec ListEmailIdentities
Int -> ReadS ListEmailIdentities
ReadS [ListEmailIdentities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListEmailIdentities]
$creadListPrec :: ReadPrec [ListEmailIdentities]
readPrec :: ReadPrec ListEmailIdentities
$creadPrec :: ReadPrec ListEmailIdentities
readList :: ReadS [ListEmailIdentities]
$creadList :: ReadS [ListEmailIdentities]
readsPrec :: Int -> ReadS ListEmailIdentities
$creadsPrec :: Int -> ReadS ListEmailIdentities
Prelude.Read, Int -> ListEmailIdentities -> ShowS
[ListEmailIdentities] -> ShowS
ListEmailIdentities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListEmailIdentities] -> ShowS
$cshowList :: [ListEmailIdentities] -> ShowS
show :: ListEmailIdentities -> String
$cshow :: ListEmailIdentities -> String
showsPrec :: Int -> ListEmailIdentities -> ShowS
$cshowsPrec :: Int -> ListEmailIdentities -> ShowS
Prelude.Show, forall x. Rep ListEmailIdentities x -> ListEmailIdentities
forall x. ListEmailIdentities -> Rep ListEmailIdentities x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListEmailIdentities x -> ListEmailIdentities
$cfrom :: forall x. ListEmailIdentities -> Rep ListEmailIdentities x
Prelude.Generic)

-- |
-- Create a value of 'ListEmailIdentities' 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:
--
-- 'nextToken', 'listEmailIdentities_nextToken' - A token returned from a previous call to @ListEmailIdentities@ to
-- indicate the position in the list of identities.
--
-- 'pageSize', 'listEmailIdentities_pageSize' - The number of results to show in a single call to @ListEmailIdentities@.
-- If the number of results is larger than the number you specified in this
-- parameter, then the response includes a @NextToken@ element, which you
-- can use to obtain additional results.
--
-- The value you specify has to be at least 0, and can be no more than
-- 1000.
newListEmailIdentities ::
  ListEmailIdentities
newListEmailIdentities :: ListEmailIdentities
newListEmailIdentities =
  ListEmailIdentities'
    { $sel:nextToken:ListEmailIdentities' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:ListEmailIdentities' :: Maybe Int
pageSize = forall a. Maybe a
Prelude.Nothing
    }

-- | A token returned from a previous call to @ListEmailIdentities@ to
-- indicate the position in the list of identities.
listEmailIdentities_nextToken :: Lens.Lens' ListEmailIdentities (Prelude.Maybe Prelude.Text)
listEmailIdentities_nextToken :: Lens' ListEmailIdentities (Maybe Text)
listEmailIdentities_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEmailIdentities' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListEmailIdentities' :: ListEmailIdentities -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListEmailIdentities
s@ListEmailIdentities' {} Maybe Text
a -> ListEmailIdentities
s {$sel:nextToken:ListEmailIdentities' :: Maybe Text
nextToken = Maybe Text
a} :: ListEmailIdentities)

-- | The number of results to show in a single call to @ListEmailIdentities@.
-- If the number of results is larger than the number you specified in this
-- parameter, then the response includes a @NextToken@ element, which you
-- can use to obtain additional results.
--
-- The value you specify has to be at least 0, and can be no more than
-- 1000.
listEmailIdentities_pageSize :: Lens.Lens' ListEmailIdentities (Prelude.Maybe Prelude.Int)
listEmailIdentities_pageSize :: Lens' ListEmailIdentities (Maybe Int)
listEmailIdentities_pageSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEmailIdentities' {Maybe Int
pageSize :: Maybe Int
$sel:pageSize:ListEmailIdentities' :: ListEmailIdentities -> Maybe Int
pageSize} -> Maybe Int
pageSize) (\s :: ListEmailIdentities
s@ListEmailIdentities' {} Maybe Int
a -> ListEmailIdentities
s {$sel:pageSize:ListEmailIdentities' :: Maybe Int
pageSize = Maybe Int
a} :: ListEmailIdentities)

instance Core.AWSRequest ListEmailIdentities where
  type
    AWSResponse ListEmailIdentities =
      ListEmailIdentitiesResponse
  request :: (Service -> Service)
-> ListEmailIdentities -> Request ListEmailIdentities
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListEmailIdentities
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListEmailIdentities)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [IdentityInfo]
-> Maybe Text -> Int -> ListEmailIdentitiesResponse
ListEmailIdentitiesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"EmailIdentities"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable ListEmailIdentities where
  hashWithSalt :: Int -> ListEmailIdentities -> Int
hashWithSalt Int
_salt ListEmailIdentities' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListEmailIdentities' :: ListEmailIdentities -> Maybe Int
$sel:nextToken:ListEmailIdentities' :: ListEmailIdentities -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
pageSize

instance Prelude.NFData ListEmailIdentities where
  rnf :: ListEmailIdentities -> ()
rnf ListEmailIdentities' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListEmailIdentities' :: ListEmailIdentities -> Maybe Int
$sel:nextToken:ListEmailIdentities' :: ListEmailIdentities -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
pageSize

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

instance Data.ToPath ListEmailIdentities where
  toPath :: ListEmailIdentities -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v2/email/identities"

instance Data.ToQuery ListEmailIdentities where
  toQuery :: ListEmailIdentities -> QueryString
toQuery ListEmailIdentities' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListEmailIdentities' :: ListEmailIdentities -> Maybe Int
$sel:nextToken:ListEmailIdentities' :: ListEmailIdentities -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"NextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken,
        ByteString
"PageSize" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
pageSize
      ]

-- | A list of all of the identities that you\'ve attempted to verify,
-- regardless of whether or not those identities were successfully
-- verified.
--
-- /See:/ 'newListEmailIdentitiesResponse' smart constructor.
data ListEmailIdentitiesResponse = ListEmailIdentitiesResponse'
  { -- | An array that includes all of the email identities associated with your
    -- Amazon Web Services account.
    ListEmailIdentitiesResponse -> Maybe [IdentityInfo]
emailIdentities :: Prelude.Maybe [IdentityInfo],
    -- | A token that indicates that there are additional configuration sets to
    -- list. To view additional configuration sets, issue another request to
    -- @ListEmailIdentities@, and pass this token in the @NextToken@ parameter.
    ListEmailIdentitiesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListEmailIdentitiesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListEmailIdentitiesResponse -> ListEmailIdentitiesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListEmailIdentitiesResponse -> ListEmailIdentitiesResponse -> Bool
$c/= :: ListEmailIdentitiesResponse -> ListEmailIdentitiesResponse -> Bool
== :: ListEmailIdentitiesResponse -> ListEmailIdentitiesResponse -> Bool
$c== :: ListEmailIdentitiesResponse -> ListEmailIdentitiesResponse -> Bool
Prelude.Eq, ReadPrec [ListEmailIdentitiesResponse]
ReadPrec ListEmailIdentitiesResponse
Int -> ReadS ListEmailIdentitiesResponse
ReadS [ListEmailIdentitiesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListEmailIdentitiesResponse]
$creadListPrec :: ReadPrec [ListEmailIdentitiesResponse]
readPrec :: ReadPrec ListEmailIdentitiesResponse
$creadPrec :: ReadPrec ListEmailIdentitiesResponse
readList :: ReadS [ListEmailIdentitiesResponse]
$creadList :: ReadS [ListEmailIdentitiesResponse]
readsPrec :: Int -> ReadS ListEmailIdentitiesResponse
$creadsPrec :: Int -> ReadS ListEmailIdentitiesResponse
Prelude.Read, Int -> ListEmailIdentitiesResponse -> ShowS
[ListEmailIdentitiesResponse] -> ShowS
ListEmailIdentitiesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListEmailIdentitiesResponse] -> ShowS
$cshowList :: [ListEmailIdentitiesResponse] -> ShowS
show :: ListEmailIdentitiesResponse -> String
$cshow :: ListEmailIdentitiesResponse -> String
showsPrec :: Int -> ListEmailIdentitiesResponse -> ShowS
$cshowsPrec :: Int -> ListEmailIdentitiesResponse -> ShowS
Prelude.Show, forall x.
Rep ListEmailIdentitiesResponse x -> ListEmailIdentitiesResponse
forall x.
ListEmailIdentitiesResponse -> Rep ListEmailIdentitiesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListEmailIdentitiesResponse x -> ListEmailIdentitiesResponse
$cfrom :: forall x.
ListEmailIdentitiesResponse -> Rep ListEmailIdentitiesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListEmailIdentitiesResponse' 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:
--
-- 'emailIdentities', 'listEmailIdentitiesResponse_emailIdentities' - An array that includes all of the email identities associated with your
-- Amazon Web Services account.
--
-- 'nextToken', 'listEmailIdentitiesResponse_nextToken' - A token that indicates that there are additional configuration sets to
-- list. To view additional configuration sets, issue another request to
-- @ListEmailIdentities@, and pass this token in the @NextToken@ parameter.
--
-- 'httpStatus', 'listEmailIdentitiesResponse_httpStatus' - The response's http status code.
newListEmailIdentitiesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListEmailIdentitiesResponse
newListEmailIdentitiesResponse :: Int -> ListEmailIdentitiesResponse
newListEmailIdentitiesResponse Int
pHttpStatus_ =
  ListEmailIdentitiesResponse'
    { $sel:emailIdentities:ListEmailIdentitiesResponse' :: Maybe [IdentityInfo]
emailIdentities =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListEmailIdentitiesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListEmailIdentitiesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array that includes all of the email identities associated with your
-- Amazon Web Services account.
listEmailIdentitiesResponse_emailIdentities :: Lens.Lens' ListEmailIdentitiesResponse (Prelude.Maybe [IdentityInfo])
listEmailIdentitiesResponse_emailIdentities :: Lens' ListEmailIdentitiesResponse (Maybe [IdentityInfo])
listEmailIdentitiesResponse_emailIdentities = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEmailIdentitiesResponse' {Maybe [IdentityInfo]
emailIdentities :: Maybe [IdentityInfo]
$sel:emailIdentities:ListEmailIdentitiesResponse' :: ListEmailIdentitiesResponse -> Maybe [IdentityInfo]
emailIdentities} -> Maybe [IdentityInfo]
emailIdentities) (\s :: ListEmailIdentitiesResponse
s@ListEmailIdentitiesResponse' {} Maybe [IdentityInfo]
a -> ListEmailIdentitiesResponse
s {$sel:emailIdentities:ListEmailIdentitiesResponse' :: Maybe [IdentityInfo]
emailIdentities = Maybe [IdentityInfo]
a} :: ListEmailIdentitiesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A token that indicates that there are additional configuration sets to
-- list. To view additional configuration sets, issue another request to
-- @ListEmailIdentities@, and pass this token in the @NextToken@ parameter.
listEmailIdentitiesResponse_nextToken :: Lens.Lens' ListEmailIdentitiesResponse (Prelude.Maybe Prelude.Text)
listEmailIdentitiesResponse_nextToken :: Lens' ListEmailIdentitiesResponse (Maybe Text)
listEmailIdentitiesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEmailIdentitiesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListEmailIdentitiesResponse' :: ListEmailIdentitiesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListEmailIdentitiesResponse
s@ListEmailIdentitiesResponse' {} Maybe Text
a -> ListEmailIdentitiesResponse
s {$sel:nextToken:ListEmailIdentitiesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListEmailIdentitiesResponse)

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

instance Prelude.NFData ListEmailIdentitiesResponse where
  rnf :: ListEmailIdentitiesResponse -> ()
rnf ListEmailIdentitiesResponse' {Int
Maybe [IdentityInfo]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
emailIdentities :: Maybe [IdentityInfo]
$sel:httpStatus:ListEmailIdentitiesResponse' :: ListEmailIdentitiesResponse -> Int
$sel:nextToken:ListEmailIdentitiesResponse' :: ListEmailIdentitiesResponse -> Maybe Text
$sel:emailIdentities:ListEmailIdentitiesResponse' :: ListEmailIdentitiesResponse -> Maybe [IdentityInfo]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [IdentityInfo]
emailIdentities
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus