{-# 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.ListContactLists
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all of the contact lists available.
module Amazonka.SESV2.ListContactLists
  ( -- * Creating a Request
    ListContactLists (..),
    newListContactLists,

    -- * Request Lenses
    listContactLists_nextToken,
    listContactLists_pageSize,

    -- * Destructuring the Response
    ListContactListsResponse (..),
    newListContactListsResponse,

    -- * Response Lenses
    listContactListsResponse_contactLists,
    listContactListsResponse_nextToken,
    listContactListsResponse_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

-- | /See:/ 'newListContactLists' smart constructor.
data ListContactLists = ListContactLists'
  { -- | A string token indicating that there might be additional contact lists
    -- available to be listed. Use the token provided in the Response to use in
    -- the subsequent call to ListContactLists with the same parameters to
    -- retrieve the next page of contact lists.
    ListContactLists -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Maximum number of contact lists to return at once. Use this parameter to
    -- paginate results. If additional contact lists exist beyond the specified
    -- limit, the @NextToken@ element is sent in the response. Use the
    -- @NextToken@ value in subsequent requests to retrieve additional lists.
    ListContactLists -> Maybe Int
pageSize :: Prelude.Maybe Prelude.Int
  }
  deriving (ListContactLists -> ListContactLists -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListContactLists -> ListContactLists -> Bool
$c/= :: ListContactLists -> ListContactLists -> Bool
== :: ListContactLists -> ListContactLists -> Bool
$c== :: ListContactLists -> ListContactLists -> Bool
Prelude.Eq, ReadPrec [ListContactLists]
ReadPrec ListContactLists
Int -> ReadS ListContactLists
ReadS [ListContactLists]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListContactLists]
$creadListPrec :: ReadPrec [ListContactLists]
readPrec :: ReadPrec ListContactLists
$creadPrec :: ReadPrec ListContactLists
readList :: ReadS [ListContactLists]
$creadList :: ReadS [ListContactLists]
readsPrec :: Int -> ReadS ListContactLists
$creadsPrec :: Int -> ReadS ListContactLists
Prelude.Read, Int -> ListContactLists -> ShowS
[ListContactLists] -> ShowS
ListContactLists -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListContactLists] -> ShowS
$cshowList :: [ListContactLists] -> ShowS
show :: ListContactLists -> String
$cshow :: ListContactLists -> String
showsPrec :: Int -> ListContactLists -> ShowS
$cshowsPrec :: Int -> ListContactLists -> ShowS
Prelude.Show, forall x. Rep ListContactLists x -> ListContactLists
forall x. ListContactLists -> Rep ListContactLists x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListContactLists x -> ListContactLists
$cfrom :: forall x. ListContactLists -> Rep ListContactLists x
Prelude.Generic)

-- |
-- Create a value of 'ListContactLists' 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', 'listContactLists_nextToken' - A string token indicating that there might be additional contact lists
-- available to be listed. Use the token provided in the Response to use in
-- the subsequent call to ListContactLists with the same parameters to
-- retrieve the next page of contact lists.
--
-- 'pageSize', 'listContactLists_pageSize' - Maximum number of contact lists to return at once. Use this parameter to
-- paginate results. If additional contact lists exist beyond the specified
-- limit, the @NextToken@ element is sent in the response. Use the
-- @NextToken@ value in subsequent requests to retrieve additional lists.
newListContactLists ::
  ListContactLists
newListContactLists :: ListContactLists
newListContactLists =
  ListContactLists'
    { $sel:nextToken:ListContactLists' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:ListContactLists' :: Maybe Int
pageSize = forall a. Maybe a
Prelude.Nothing
    }

-- | A string token indicating that there might be additional contact lists
-- available to be listed. Use the token provided in the Response to use in
-- the subsequent call to ListContactLists with the same parameters to
-- retrieve the next page of contact lists.
listContactLists_nextToken :: Lens.Lens' ListContactLists (Prelude.Maybe Prelude.Text)
listContactLists_nextToken :: Lens' ListContactLists (Maybe Text)
listContactLists_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContactLists' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListContactLists' :: ListContactLists -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListContactLists
s@ListContactLists' {} Maybe Text
a -> ListContactLists
s {$sel:nextToken:ListContactLists' :: Maybe Text
nextToken = Maybe Text
a} :: ListContactLists)

-- | Maximum number of contact lists to return at once. Use this parameter to
-- paginate results. If additional contact lists exist beyond the specified
-- limit, the @NextToken@ element is sent in the response. Use the
-- @NextToken@ value in subsequent requests to retrieve additional lists.
listContactLists_pageSize :: Lens.Lens' ListContactLists (Prelude.Maybe Prelude.Int)
listContactLists_pageSize :: Lens' ListContactLists (Maybe Int)
listContactLists_pageSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContactLists' {Maybe Int
pageSize :: Maybe Int
$sel:pageSize:ListContactLists' :: ListContactLists -> Maybe Int
pageSize} -> Maybe Int
pageSize) (\s :: ListContactLists
s@ListContactLists' {} Maybe Int
a -> ListContactLists
s {$sel:pageSize:ListContactLists' :: Maybe Int
pageSize = Maybe Int
a} :: ListContactLists)

instance Core.AWSRequest ListContactLists where
  type
    AWSResponse ListContactLists =
      ListContactListsResponse
  request :: (Service -> Service)
-> ListContactLists -> Request ListContactLists
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 ListContactLists
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListContactLists)))
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 [ContactList]
-> Maybe Text -> Int -> ListContactListsResponse
ListContactListsResponse'
            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
"ContactLists" 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 ListContactLists where
  hashWithSalt :: Int -> ListContactLists -> Int
hashWithSalt Int
_salt ListContactLists' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListContactLists' :: ListContactLists -> Maybe Int
$sel:nextToken:ListContactLists' :: ListContactLists -> 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 ListContactLists where
  rnf :: ListContactLists -> ()
rnf ListContactLists' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListContactLists' :: ListContactLists -> Maybe Int
$sel:nextToken:ListContactLists' :: ListContactLists -> 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 ListContactLists where
  toHeaders :: ListContactLists -> 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 ListContactLists where
  toPath :: ListContactLists -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v2/email/contact-lists"

instance Data.ToQuery ListContactLists where
  toQuery :: ListContactLists -> QueryString
toQuery ListContactLists' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListContactLists' :: ListContactLists -> Maybe Int
$sel:nextToken:ListContactLists' :: ListContactLists -> 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
      ]

-- | /See:/ 'newListContactListsResponse' smart constructor.
data ListContactListsResponse = ListContactListsResponse'
  { -- | The available contact lists.
    ListContactListsResponse -> Maybe [ContactList]
contactLists :: Prelude.Maybe [ContactList],
    -- | A string token indicating that there might be additional contact lists
    -- available to be listed. Copy this token to a subsequent call to
    -- @ListContactLists@ with the same parameters to retrieve the next page of
    -- contact lists.
    ListContactListsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListContactListsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListContactListsResponse -> ListContactListsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListContactListsResponse -> ListContactListsResponse -> Bool
$c/= :: ListContactListsResponse -> ListContactListsResponse -> Bool
== :: ListContactListsResponse -> ListContactListsResponse -> Bool
$c== :: ListContactListsResponse -> ListContactListsResponse -> Bool
Prelude.Eq, ReadPrec [ListContactListsResponse]
ReadPrec ListContactListsResponse
Int -> ReadS ListContactListsResponse
ReadS [ListContactListsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListContactListsResponse]
$creadListPrec :: ReadPrec [ListContactListsResponse]
readPrec :: ReadPrec ListContactListsResponse
$creadPrec :: ReadPrec ListContactListsResponse
readList :: ReadS [ListContactListsResponse]
$creadList :: ReadS [ListContactListsResponse]
readsPrec :: Int -> ReadS ListContactListsResponse
$creadsPrec :: Int -> ReadS ListContactListsResponse
Prelude.Read, Int -> ListContactListsResponse -> ShowS
[ListContactListsResponse] -> ShowS
ListContactListsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListContactListsResponse] -> ShowS
$cshowList :: [ListContactListsResponse] -> ShowS
show :: ListContactListsResponse -> String
$cshow :: ListContactListsResponse -> String
showsPrec :: Int -> ListContactListsResponse -> ShowS
$cshowsPrec :: Int -> ListContactListsResponse -> ShowS
Prelude.Show, forall x.
Rep ListContactListsResponse x -> ListContactListsResponse
forall x.
ListContactListsResponse -> Rep ListContactListsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListContactListsResponse x -> ListContactListsResponse
$cfrom :: forall x.
ListContactListsResponse -> Rep ListContactListsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListContactListsResponse' 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:
--
-- 'contactLists', 'listContactListsResponse_contactLists' - The available contact lists.
--
-- 'nextToken', 'listContactListsResponse_nextToken' - A string token indicating that there might be additional contact lists
-- available to be listed. Copy this token to a subsequent call to
-- @ListContactLists@ with the same parameters to retrieve the next page of
-- contact lists.
--
-- 'httpStatus', 'listContactListsResponse_httpStatus' - The response's http status code.
newListContactListsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListContactListsResponse
newListContactListsResponse :: Int -> ListContactListsResponse
newListContactListsResponse Int
pHttpStatus_ =
  ListContactListsResponse'
    { $sel:contactLists:ListContactListsResponse' :: Maybe [ContactList]
contactLists =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListContactListsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListContactListsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The available contact lists.
listContactListsResponse_contactLists :: Lens.Lens' ListContactListsResponse (Prelude.Maybe [ContactList])
listContactListsResponse_contactLists :: Lens' ListContactListsResponse (Maybe [ContactList])
listContactListsResponse_contactLists = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContactListsResponse' {Maybe [ContactList]
contactLists :: Maybe [ContactList]
$sel:contactLists:ListContactListsResponse' :: ListContactListsResponse -> Maybe [ContactList]
contactLists} -> Maybe [ContactList]
contactLists) (\s :: ListContactListsResponse
s@ListContactListsResponse' {} Maybe [ContactList]
a -> ListContactListsResponse
s {$sel:contactLists:ListContactListsResponse' :: Maybe [ContactList]
contactLists = Maybe [ContactList]
a} :: ListContactListsResponse) 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 string token indicating that there might be additional contact lists
-- available to be listed. Copy this token to a subsequent call to
-- @ListContactLists@ with the same parameters to retrieve the next page of
-- contact lists.
listContactListsResponse_nextToken :: Lens.Lens' ListContactListsResponse (Prelude.Maybe Prelude.Text)
listContactListsResponse_nextToken :: Lens' ListContactListsResponse (Maybe Text)
listContactListsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContactListsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListContactListsResponse' :: ListContactListsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListContactListsResponse
s@ListContactListsResponse' {} Maybe Text
a -> ListContactListsResponse
s {$sel:nextToken:ListContactListsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListContactListsResponse)

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

instance Prelude.NFData ListContactListsResponse where
  rnf :: ListContactListsResponse -> ()
rnf ListContactListsResponse' {Int
Maybe [ContactList]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
contactLists :: Maybe [ContactList]
$sel:httpStatus:ListContactListsResponse' :: ListContactListsResponse -> Int
$sel:nextToken:ListContactListsResponse' :: ListContactListsResponse -> Maybe Text
$sel:contactLists:ListContactListsResponse' :: ListContactListsResponse -> Maybe [ContactList]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ContactList]
contactLists
      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