{-# 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.Kafka.ListConfigurations
-- 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 the MSK configurations in this Region.
--
-- This operation returns paginated results.
module Amazonka.Kafka.ListConfigurations
  ( -- * Creating a Request
    ListConfigurations (..),
    newListConfigurations,

    -- * Request Lenses
    listConfigurations_maxResults,
    listConfigurations_nextToken,

    -- * Destructuring the Response
    ListConfigurationsResponse (..),
    newListConfigurationsResponse,

    -- * Response Lenses
    listConfigurationsResponse_configurations,
    listConfigurationsResponse_nextToken,
    listConfigurationsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kafka.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListConfigurations' smart constructor.
data ListConfigurations = ListConfigurations'
  { -- | The maximum number of results to return in the response. If there are
    -- more results, the response includes a NextToken parameter.
    ListConfigurations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The paginated results marker. When the result of the operation is
    -- truncated, the call returns NextToken in the response. To get the next
    -- batch, provide this token in your next request.
    ListConfigurations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListConfigurations -> ListConfigurations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListConfigurations -> ListConfigurations -> Bool
$c/= :: ListConfigurations -> ListConfigurations -> Bool
== :: ListConfigurations -> ListConfigurations -> Bool
$c== :: ListConfigurations -> ListConfigurations -> Bool
Prelude.Eq, ReadPrec [ListConfigurations]
ReadPrec ListConfigurations
Int -> ReadS ListConfigurations
ReadS [ListConfigurations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListConfigurations]
$creadListPrec :: ReadPrec [ListConfigurations]
readPrec :: ReadPrec ListConfigurations
$creadPrec :: ReadPrec ListConfigurations
readList :: ReadS [ListConfigurations]
$creadList :: ReadS [ListConfigurations]
readsPrec :: Int -> ReadS ListConfigurations
$creadsPrec :: Int -> ReadS ListConfigurations
Prelude.Read, Int -> ListConfigurations -> ShowS
[ListConfigurations] -> ShowS
ListConfigurations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListConfigurations] -> ShowS
$cshowList :: [ListConfigurations] -> ShowS
show :: ListConfigurations -> String
$cshow :: ListConfigurations -> String
showsPrec :: Int -> ListConfigurations -> ShowS
$cshowsPrec :: Int -> ListConfigurations -> ShowS
Prelude.Show, forall x. Rep ListConfigurations x -> ListConfigurations
forall x. ListConfigurations -> Rep ListConfigurations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListConfigurations x -> ListConfigurations
$cfrom :: forall x. ListConfigurations -> Rep ListConfigurations x
Prelude.Generic)

-- |
-- Create a value of 'ListConfigurations' 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:
--
-- 'maxResults', 'listConfigurations_maxResults' - The maximum number of results to return in the response. If there are
-- more results, the response includes a NextToken parameter.
--
-- 'nextToken', 'listConfigurations_nextToken' - The paginated results marker. When the result of the operation is
-- truncated, the call returns NextToken in the response. To get the next
-- batch, provide this token in your next request.
newListConfigurations ::
  ListConfigurations
newListConfigurations :: ListConfigurations
newListConfigurations =
  ListConfigurations'
    { $sel:maxResults:ListConfigurations' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListConfigurations' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to return in the response. If there are
-- more results, the response includes a NextToken parameter.
listConfigurations_maxResults :: Lens.Lens' ListConfigurations (Prelude.Maybe Prelude.Natural)
listConfigurations_maxResults :: Lens' ListConfigurations (Maybe Natural)
listConfigurations_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConfigurations' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListConfigurations' :: ListConfigurations -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListConfigurations
s@ListConfigurations' {} Maybe Natural
a -> ListConfigurations
s {$sel:maxResults:ListConfigurations' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListConfigurations)

-- | The paginated results marker. When the result of the operation is
-- truncated, the call returns NextToken in the response. To get the next
-- batch, provide this token in your next request.
listConfigurations_nextToken :: Lens.Lens' ListConfigurations (Prelude.Maybe Prelude.Text)
listConfigurations_nextToken :: Lens' ListConfigurations (Maybe Text)
listConfigurations_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConfigurations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListConfigurations' :: ListConfigurations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListConfigurations
s@ListConfigurations' {} Maybe Text
a -> ListConfigurations
s {$sel:nextToken:ListConfigurations' :: Maybe Text
nextToken = Maybe Text
a} :: ListConfigurations)

instance Core.AWSPager ListConfigurations where
  page :: ListConfigurations
-> AWSResponse ListConfigurations -> Maybe ListConfigurations
page ListConfigurations
rq AWSResponse ListConfigurations
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListConfigurations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListConfigurationsResponse (Maybe Text)
listConfigurationsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListConfigurations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListConfigurationsResponse (Maybe [Configuration])
listConfigurationsResponse_configurations
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListConfigurations
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListConfigurations (Maybe Text)
listConfigurations_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListConfigurations
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListConfigurationsResponse (Maybe Text)
listConfigurationsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListConfigurations where
  type
    AWSResponse ListConfigurations =
      ListConfigurationsResponse
  request :: (Service -> Service)
-> ListConfigurations -> Request ListConfigurations
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 ListConfigurations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListConfigurations)))
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 [Configuration]
-> Maybe Text -> Int -> ListConfigurationsResponse
ListConfigurationsResponse'
            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
"configurations" 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 ListConfigurations where
  hashWithSalt :: Int -> ListConfigurations -> Int
hashWithSalt Int
_salt ListConfigurations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListConfigurations' :: ListConfigurations -> Maybe Text
$sel:maxResults:ListConfigurations' :: ListConfigurations -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

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

instance Data.ToHeaders ListConfigurations where
  toHeaders :: ListConfigurations -> 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 ListConfigurations where
  toPath :: ListConfigurations -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v1/configurations"

instance Data.ToQuery ListConfigurations where
  toQuery :: ListConfigurations -> QueryString
toQuery ListConfigurations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListConfigurations' :: ListConfigurations -> Maybe Text
$sel:maxResults:ListConfigurations' :: ListConfigurations -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListConfigurationsResponse' smart constructor.
data ListConfigurationsResponse = ListConfigurationsResponse'
  { -- | An array of MSK configurations.
    ListConfigurationsResponse -> Maybe [Configuration]
configurations :: Prelude.Maybe [Configuration],
    -- | The paginated results marker. When the result of a ListConfigurations
    -- operation is truncated, the call returns NextToken in the response. To
    -- get another batch of configurations, provide this token in your next
    -- request.
    ListConfigurationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListConfigurationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListConfigurationsResponse -> ListConfigurationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListConfigurationsResponse -> ListConfigurationsResponse -> Bool
$c/= :: ListConfigurationsResponse -> ListConfigurationsResponse -> Bool
== :: ListConfigurationsResponse -> ListConfigurationsResponse -> Bool
$c== :: ListConfigurationsResponse -> ListConfigurationsResponse -> Bool
Prelude.Eq, ReadPrec [ListConfigurationsResponse]
ReadPrec ListConfigurationsResponse
Int -> ReadS ListConfigurationsResponse
ReadS [ListConfigurationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListConfigurationsResponse]
$creadListPrec :: ReadPrec [ListConfigurationsResponse]
readPrec :: ReadPrec ListConfigurationsResponse
$creadPrec :: ReadPrec ListConfigurationsResponse
readList :: ReadS [ListConfigurationsResponse]
$creadList :: ReadS [ListConfigurationsResponse]
readsPrec :: Int -> ReadS ListConfigurationsResponse
$creadsPrec :: Int -> ReadS ListConfigurationsResponse
Prelude.Read, Int -> ListConfigurationsResponse -> ShowS
[ListConfigurationsResponse] -> ShowS
ListConfigurationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListConfigurationsResponse] -> ShowS
$cshowList :: [ListConfigurationsResponse] -> ShowS
show :: ListConfigurationsResponse -> String
$cshow :: ListConfigurationsResponse -> String
showsPrec :: Int -> ListConfigurationsResponse -> ShowS
$cshowsPrec :: Int -> ListConfigurationsResponse -> ShowS
Prelude.Show, forall x.
Rep ListConfigurationsResponse x -> ListConfigurationsResponse
forall x.
ListConfigurationsResponse -> Rep ListConfigurationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListConfigurationsResponse x -> ListConfigurationsResponse
$cfrom :: forall x.
ListConfigurationsResponse -> Rep ListConfigurationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListConfigurationsResponse' 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:
--
-- 'configurations', 'listConfigurationsResponse_configurations' - An array of MSK configurations.
--
-- 'nextToken', 'listConfigurationsResponse_nextToken' - The paginated results marker. When the result of a ListConfigurations
-- operation is truncated, the call returns NextToken in the response. To
-- get another batch of configurations, provide this token in your next
-- request.
--
-- 'httpStatus', 'listConfigurationsResponse_httpStatus' - The response's http status code.
newListConfigurationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListConfigurationsResponse
newListConfigurationsResponse :: Int -> ListConfigurationsResponse
newListConfigurationsResponse Int
pHttpStatus_ =
  ListConfigurationsResponse'
    { $sel:configurations:ListConfigurationsResponse' :: Maybe [Configuration]
configurations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListConfigurationsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListConfigurationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of MSK configurations.
listConfigurationsResponse_configurations :: Lens.Lens' ListConfigurationsResponse (Prelude.Maybe [Configuration])
listConfigurationsResponse_configurations :: Lens' ListConfigurationsResponse (Maybe [Configuration])
listConfigurationsResponse_configurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConfigurationsResponse' {Maybe [Configuration]
configurations :: Maybe [Configuration]
$sel:configurations:ListConfigurationsResponse' :: ListConfigurationsResponse -> Maybe [Configuration]
configurations} -> Maybe [Configuration]
configurations) (\s :: ListConfigurationsResponse
s@ListConfigurationsResponse' {} Maybe [Configuration]
a -> ListConfigurationsResponse
s {$sel:configurations:ListConfigurationsResponse' :: Maybe [Configuration]
configurations = Maybe [Configuration]
a} :: ListConfigurationsResponse) 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

-- | The paginated results marker. When the result of a ListConfigurations
-- operation is truncated, the call returns NextToken in the response. To
-- get another batch of configurations, provide this token in your next
-- request.
listConfigurationsResponse_nextToken :: Lens.Lens' ListConfigurationsResponse (Prelude.Maybe Prelude.Text)
listConfigurationsResponse_nextToken :: Lens' ListConfigurationsResponse (Maybe Text)
listConfigurationsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConfigurationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListConfigurationsResponse' :: ListConfigurationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListConfigurationsResponse
s@ListConfigurationsResponse' {} Maybe Text
a -> ListConfigurationsResponse
s {$sel:nextToken:ListConfigurationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListConfigurationsResponse)

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

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