{-# 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-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)
--
-- 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_nextToken,
    listContactListsResponse_contactLists,
    listContactListsResponse_httpStatus,
  )
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

-- | /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
(ListContactLists -> ListContactLists -> Bool)
-> (ListContactLists -> ListContactLists -> Bool)
-> Eq ListContactLists
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]
(Int -> ReadS ListContactLists)
-> ReadS [ListContactLists]
-> ReadPrec ListContactLists
-> ReadPrec [ListContactLists]
-> Read 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
(Int -> ListContactLists -> ShowS)
-> (ListContactLists -> String)
-> ([ListContactLists] -> ShowS)
-> Show ListContactLists
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. ListContactLists -> Rep ListContactLists x)
-> (forall x. Rep ListContactLists x -> ListContactLists)
-> Generic ListContactLists
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' :: Maybe Text -> Maybe Int -> ListContactLists
ListContactLists'
    { $sel:nextToken:ListContactLists' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:ListContactLists' :: Maybe Int
pageSize = Maybe Int
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 :: (Maybe Text -> f (Maybe Text))
-> ListContactLists -> f ListContactLists
listContactLists_nextToken = (ListContactLists -> Maybe Text)
-> (ListContactLists -> Maybe Text -> ListContactLists)
-> Lens ListContactLists ListContactLists (Maybe Text) (Maybe Text)
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 :: (Maybe Int -> f (Maybe Int))
-> ListContactLists -> f ListContactLists
listContactLists_pageSize = (ListContactLists -> Maybe Int)
-> (ListContactLists -> Maybe Int -> ListContactLists)
-> Lens ListContactLists ListContactLists (Maybe Int) (Maybe Int)
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 :: ListContactLists -> Request ListContactLists
request = Service -> ListContactLists -> Request ListContactLists
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListContactLists
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListContactLists)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListContactLists))
-> Logger
-> Service
-> Proxy ListContactLists
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListContactLists)))
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 ->
          Maybe Text
-> Maybe [ContactList] -> Int -> ListContactListsResponse
ListContactListsResponse'
            (Maybe Text
 -> Maybe [ContactList] -> Int -> ListContactListsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [ContactList] -> Int -> ListContactListsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either
  String (Maybe [ContactList] -> Int -> ListContactListsResponse)
-> Either String (Maybe [ContactList])
-> Either String (Int -> ListContactListsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [ContactList]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ContactLists" Either String (Maybe (Maybe [ContactList]))
-> Maybe [ContactList] -> Either String (Maybe [ContactList])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ContactList]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListContactListsResponse)
-> Either String Int -> Either String ListContactListsResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable ListContactLists

instance Prelude.NFData ListContactLists

instance Core.ToHeaders ListContactLists where
  toHeaders :: ListContactLists -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListContactLists -> 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 ListContactLists where
  toPath :: ListContactLists -> ByteString
toPath = ByteString -> ListContactLists -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v2/email/contact-lists"

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"PageSize" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
pageSize
      ]

-- | /See:/ 'newListContactListsResponse' smart constructor.
data ListContactListsResponse = ListContactListsResponse'
  { -- | 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 available contact lists.
    ListContactListsResponse -> Maybe [ContactList]
contactLists :: Prelude.Maybe [ContactList],
    -- | The response's http status code.
    ListContactListsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListContactListsResponse -> ListContactListsResponse -> Bool
(ListContactListsResponse -> ListContactListsResponse -> Bool)
-> (ListContactListsResponse -> ListContactListsResponse -> Bool)
-> Eq ListContactListsResponse
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]
(Int -> ReadS ListContactListsResponse)
-> ReadS [ListContactListsResponse]
-> ReadPrec ListContactListsResponse
-> ReadPrec [ListContactListsResponse]
-> Read 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
(Int -> ListContactListsResponse -> ShowS)
-> (ListContactListsResponse -> String)
-> ([ListContactListsResponse] -> ShowS)
-> Show ListContactListsResponse
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.
 ListContactListsResponse -> Rep ListContactListsResponse x)
-> (forall x.
    Rep ListContactListsResponse x -> ListContactListsResponse)
-> Generic ListContactListsResponse
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:
--
-- '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.
--
-- 'contactLists', 'listContactListsResponse_contactLists' - The available contact lists.
--
-- 'httpStatus', 'listContactListsResponse_httpStatus' - The response's http status code.
newListContactListsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListContactListsResponse
newListContactListsResponse :: Int -> ListContactListsResponse
newListContactListsResponse Int
pHttpStatus_ =
  ListContactListsResponse' :: Maybe Text
-> Maybe [ContactList] -> Int -> ListContactListsResponse
ListContactListsResponse'
    { $sel:nextToken:ListContactListsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contactLists:ListContactListsResponse' :: Maybe [ContactList]
contactLists = Maybe [ContactList]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListContactListsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ListContactListsResponse -> f ListContactListsResponse
listContactListsResponse_nextToken = (ListContactListsResponse -> Maybe Text)
-> (ListContactListsResponse
    -> Maybe Text -> ListContactListsResponse)
-> Lens
     ListContactListsResponse
     ListContactListsResponse
     (Maybe Text)
     (Maybe Text)
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 available contact lists.
listContactListsResponse_contactLists :: Lens.Lens' ListContactListsResponse (Prelude.Maybe [ContactList])
listContactListsResponse_contactLists :: (Maybe [ContactList] -> f (Maybe [ContactList]))
-> ListContactListsResponse -> f ListContactListsResponse
listContactListsResponse_contactLists = (ListContactListsResponse -> Maybe [ContactList])
-> (ListContactListsResponse
    -> Maybe [ContactList] -> ListContactListsResponse)
-> Lens
     ListContactListsResponse
     ListContactListsResponse
     (Maybe [ContactList])
     (Maybe [ContactList])
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) ((Maybe [ContactList] -> f (Maybe [ContactList]))
 -> ListContactListsResponse -> f ListContactListsResponse)
-> ((Maybe [ContactList] -> f (Maybe [ContactList]))
    -> Maybe [ContactList] -> f (Maybe [ContactList]))
-> (Maybe [ContactList] -> f (Maybe [ContactList]))
-> ListContactListsResponse
-> f ListContactListsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ContactList] [ContactList] [ContactList] [ContactList]
-> Iso
     (Maybe [ContactList])
     (Maybe [ContactList])
     (Maybe [ContactList])
     (Maybe [ContactList])
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 AnIso [ContactList] [ContactList] [ContactList] [ContactList]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listContactListsResponse_httpStatus :: Lens.Lens' ListContactListsResponse Prelude.Int
listContactListsResponse_httpStatus :: (Int -> f Int)
-> ListContactListsResponse -> f ListContactListsResponse
listContactListsResponse_httpStatus = (ListContactListsResponse -> Int)
-> (ListContactListsResponse -> Int -> ListContactListsResponse)
-> Lens ListContactListsResponse ListContactListsResponse Int Int
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