{-# 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.ListConfigurationSets
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- List all of the configuration sets associated with your account in the
-- current region.
--
-- /Configuration sets/ are groups of rules that you can apply to the
-- emails you send. You apply a configuration set to an email by including
-- a reference to the configuration set in the headers of the email. When
-- you apply a configuration set to an email, all of the rules in that
-- configuration set are applied to the email.
module Amazonka.SESV2.ListConfigurationSets
  ( -- * Creating a Request
    ListConfigurationSets (..),
    newListConfigurationSets,

    -- * Request Lenses
    listConfigurationSets_nextToken,
    listConfigurationSets_pageSize,

    -- * Destructuring the Response
    ListConfigurationSetsResponse (..),
    newListConfigurationSetsResponse,

    -- * Response Lenses
    listConfigurationSetsResponse_configurationSets,
    listConfigurationSetsResponse_nextToken,
    listConfigurationSetsResponse_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 obtain a list of configuration sets for your Amazon SES
-- account in the current Amazon Web Services Region.
--
-- /See:/ 'newListConfigurationSets' smart constructor.
data ListConfigurationSets = ListConfigurationSets'
  { -- | A token returned from a previous call to @ListConfigurationSets@ to
    -- indicate the position in the list of configuration sets.
    ListConfigurationSets -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The number of results to show in a single call to
    -- @ListConfigurationSets@. 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.
    ListConfigurationSets -> Maybe Int
pageSize :: Prelude.Maybe Prelude.Int
  }
  deriving (ListConfigurationSets -> ListConfigurationSets -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListConfigurationSets -> ListConfigurationSets -> Bool
$c/= :: ListConfigurationSets -> ListConfigurationSets -> Bool
== :: ListConfigurationSets -> ListConfigurationSets -> Bool
$c== :: ListConfigurationSets -> ListConfigurationSets -> Bool
Prelude.Eq, ReadPrec [ListConfigurationSets]
ReadPrec ListConfigurationSets
Int -> ReadS ListConfigurationSets
ReadS [ListConfigurationSets]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListConfigurationSets]
$creadListPrec :: ReadPrec [ListConfigurationSets]
readPrec :: ReadPrec ListConfigurationSets
$creadPrec :: ReadPrec ListConfigurationSets
readList :: ReadS [ListConfigurationSets]
$creadList :: ReadS [ListConfigurationSets]
readsPrec :: Int -> ReadS ListConfigurationSets
$creadsPrec :: Int -> ReadS ListConfigurationSets
Prelude.Read, Int -> ListConfigurationSets -> ShowS
[ListConfigurationSets] -> ShowS
ListConfigurationSets -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListConfigurationSets] -> ShowS
$cshowList :: [ListConfigurationSets] -> ShowS
show :: ListConfigurationSets -> String
$cshow :: ListConfigurationSets -> String
showsPrec :: Int -> ListConfigurationSets -> ShowS
$cshowsPrec :: Int -> ListConfigurationSets -> ShowS
Prelude.Show, forall x. Rep ListConfigurationSets x -> ListConfigurationSets
forall x. ListConfigurationSets -> Rep ListConfigurationSets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListConfigurationSets x -> ListConfigurationSets
$cfrom :: forall x. ListConfigurationSets -> Rep ListConfigurationSets x
Prelude.Generic)

-- |
-- Create a value of 'ListConfigurationSets' 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', 'listConfigurationSets_nextToken' - A token returned from a previous call to @ListConfigurationSets@ to
-- indicate the position in the list of configuration sets.
--
-- 'pageSize', 'listConfigurationSets_pageSize' - The number of results to show in a single call to
-- @ListConfigurationSets@. 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.
newListConfigurationSets ::
  ListConfigurationSets
newListConfigurationSets :: ListConfigurationSets
newListConfigurationSets =
  ListConfigurationSets'
    { $sel:nextToken:ListConfigurationSets' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:ListConfigurationSets' :: Maybe Int
pageSize = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The number of results to show in a single call to
-- @ListConfigurationSets@. 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.
listConfigurationSets_pageSize :: Lens.Lens' ListConfigurationSets (Prelude.Maybe Prelude.Int)
listConfigurationSets_pageSize :: Lens' ListConfigurationSets (Maybe Int)
listConfigurationSets_pageSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConfigurationSets' {Maybe Int
pageSize :: Maybe Int
$sel:pageSize:ListConfigurationSets' :: ListConfigurationSets -> Maybe Int
pageSize} -> Maybe Int
pageSize) (\s :: ListConfigurationSets
s@ListConfigurationSets' {} Maybe Int
a -> ListConfigurationSets
s {$sel:pageSize:ListConfigurationSets' :: Maybe Int
pageSize = Maybe Int
a} :: ListConfigurationSets)

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

instance Data.ToQuery ListConfigurationSets where
  toQuery :: ListConfigurationSets -> QueryString
toQuery ListConfigurationSets' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListConfigurationSets' :: ListConfigurationSets -> Maybe Int
$sel:nextToken:ListConfigurationSets' :: ListConfigurationSets -> 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 configuration sets in your Amazon SES account in the current
-- Amazon Web Services Region.
--
-- /See:/ 'newListConfigurationSetsResponse' smart constructor.
data ListConfigurationSetsResponse = ListConfigurationSetsResponse'
  { -- | An array that contains all of the configuration sets in your Amazon SES
    -- account in the current Amazon Web Services Region.
    ListConfigurationSetsResponse -> Maybe [Text]
configurationSets :: Prelude.Maybe [Prelude.Text],
    -- | A token that indicates that there are additional configuration sets to
    -- list. To view additional configuration sets, issue another request to
    -- @ListConfigurationSets@, and pass this token in the @NextToken@
    -- parameter.
    ListConfigurationSetsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListConfigurationSetsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListConfigurationSetsResponse
-> ListConfigurationSetsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListConfigurationSetsResponse
-> ListConfigurationSetsResponse -> Bool
$c/= :: ListConfigurationSetsResponse
-> ListConfigurationSetsResponse -> Bool
== :: ListConfigurationSetsResponse
-> ListConfigurationSetsResponse -> Bool
$c== :: ListConfigurationSetsResponse
-> ListConfigurationSetsResponse -> Bool
Prelude.Eq, ReadPrec [ListConfigurationSetsResponse]
ReadPrec ListConfigurationSetsResponse
Int -> ReadS ListConfigurationSetsResponse
ReadS [ListConfigurationSetsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListConfigurationSetsResponse]
$creadListPrec :: ReadPrec [ListConfigurationSetsResponse]
readPrec :: ReadPrec ListConfigurationSetsResponse
$creadPrec :: ReadPrec ListConfigurationSetsResponse
readList :: ReadS [ListConfigurationSetsResponse]
$creadList :: ReadS [ListConfigurationSetsResponse]
readsPrec :: Int -> ReadS ListConfigurationSetsResponse
$creadsPrec :: Int -> ReadS ListConfigurationSetsResponse
Prelude.Read, Int -> ListConfigurationSetsResponse -> ShowS
[ListConfigurationSetsResponse] -> ShowS
ListConfigurationSetsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListConfigurationSetsResponse] -> ShowS
$cshowList :: [ListConfigurationSetsResponse] -> ShowS
show :: ListConfigurationSetsResponse -> String
$cshow :: ListConfigurationSetsResponse -> String
showsPrec :: Int -> ListConfigurationSetsResponse -> ShowS
$cshowsPrec :: Int -> ListConfigurationSetsResponse -> ShowS
Prelude.Show, forall x.
Rep ListConfigurationSetsResponse x
-> ListConfigurationSetsResponse
forall x.
ListConfigurationSetsResponse
-> Rep ListConfigurationSetsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListConfigurationSetsResponse x
-> ListConfigurationSetsResponse
$cfrom :: forall x.
ListConfigurationSetsResponse
-> Rep ListConfigurationSetsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListConfigurationSetsResponse' 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:
--
-- 'configurationSets', 'listConfigurationSetsResponse_configurationSets' - An array that contains all of the configuration sets in your Amazon SES
-- account in the current Amazon Web Services Region.
--
-- 'nextToken', 'listConfigurationSetsResponse_nextToken' - A token that indicates that there are additional configuration sets to
-- list. To view additional configuration sets, issue another request to
-- @ListConfigurationSets@, and pass this token in the @NextToken@
-- parameter.
--
-- 'httpStatus', 'listConfigurationSetsResponse_httpStatus' - The response's http status code.
newListConfigurationSetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListConfigurationSetsResponse
newListConfigurationSetsResponse :: Int -> ListConfigurationSetsResponse
newListConfigurationSetsResponse Int
pHttpStatus_ =
  ListConfigurationSetsResponse'
    { $sel:configurationSets:ListConfigurationSetsResponse' :: Maybe [Text]
configurationSets =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListConfigurationSetsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListConfigurationSetsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array that contains all of the configuration sets in your Amazon SES
-- account in the current Amazon Web Services Region.
listConfigurationSetsResponse_configurationSets :: Lens.Lens' ListConfigurationSetsResponse (Prelude.Maybe [Prelude.Text])
listConfigurationSetsResponse_configurationSets :: Lens' ListConfigurationSetsResponse (Maybe [Text])
listConfigurationSetsResponse_configurationSets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConfigurationSetsResponse' {Maybe [Text]
configurationSets :: Maybe [Text]
$sel:configurationSets:ListConfigurationSetsResponse' :: ListConfigurationSetsResponse -> Maybe [Text]
configurationSets} -> Maybe [Text]
configurationSets) (\s :: ListConfigurationSetsResponse
s@ListConfigurationSetsResponse' {} Maybe [Text]
a -> ListConfigurationSetsResponse
s {$sel:configurationSets:ListConfigurationSetsResponse' :: Maybe [Text]
configurationSets = Maybe [Text]
a} :: ListConfigurationSetsResponse) 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
-- @ListConfigurationSets@, and pass this token in the @NextToken@
-- parameter.
listConfigurationSetsResponse_nextToken :: Lens.Lens' ListConfigurationSetsResponse (Prelude.Maybe Prelude.Text)
listConfigurationSetsResponse_nextToken :: Lens' ListConfigurationSetsResponse (Maybe Text)
listConfigurationSetsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConfigurationSetsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListConfigurationSetsResponse' :: ListConfigurationSetsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListConfigurationSetsResponse
s@ListConfigurationSetsResponse' {} Maybe Text
a -> ListConfigurationSetsResponse
s {$sel:nextToken:ListConfigurationSetsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListConfigurationSetsResponse)

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

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