{-# 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.KafkaConnect.ListCustomPlugins
-- 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 custom plugins in this account and Region.
--
-- This operation returns paginated results.
module Amazonka.KafkaConnect.ListCustomPlugins
  ( -- * Creating a Request
    ListCustomPlugins (..),
    newListCustomPlugins,

    -- * Request Lenses
    listCustomPlugins_maxResults,
    listCustomPlugins_nextToken,

    -- * Destructuring the Response
    ListCustomPluginsResponse (..),
    newListCustomPluginsResponse,

    -- * Response Lenses
    listCustomPluginsResponse_customPlugins,
    listCustomPluginsResponse_nextToken,
    listCustomPluginsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListCustomPlugins' smart constructor.
data ListCustomPlugins = ListCustomPlugins'
  { -- | The maximum number of custom plugins to list in one response.
    ListCustomPlugins -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | If the response of a ListCustomPlugins operation is truncated, it will
    -- include a NextToken. Send this NextToken in a subsequent request to
    -- continue listing from where the previous operation left off.
    ListCustomPlugins -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListCustomPlugins -> ListCustomPlugins -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCustomPlugins -> ListCustomPlugins -> Bool
$c/= :: ListCustomPlugins -> ListCustomPlugins -> Bool
== :: ListCustomPlugins -> ListCustomPlugins -> Bool
$c== :: ListCustomPlugins -> ListCustomPlugins -> Bool
Prelude.Eq, ReadPrec [ListCustomPlugins]
ReadPrec ListCustomPlugins
Int -> ReadS ListCustomPlugins
ReadS [ListCustomPlugins]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCustomPlugins]
$creadListPrec :: ReadPrec [ListCustomPlugins]
readPrec :: ReadPrec ListCustomPlugins
$creadPrec :: ReadPrec ListCustomPlugins
readList :: ReadS [ListCustomPlugins]
$creadList :: ReadS [ListCustomPlugins]
readsPrec :: Int -> ReadS ListCustomPlugins
$creadsPrec :: Int -> ReadS ListCustomPlugins
Prelude.Read, Int -> ListCustomPlugins -> ShowS
[ListCustomPlugins] -> ShowS
ListCustomPlugins -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCustomPlugins] -> ShowS
$cshowList :: [ListCustomPlugins] -> ShowS
show :: ListCustomPlugins -> String
$cshow :: ListCustomPlugins -> String
showsPrec :: Int -> ListCustomPlugins -> ShowS
$cshowsPrec :: Int -> ListCustomPlugins -> ShowS
Prelude.Show, forall x. Rep ListCustomPlugins x -> ListCustomPlugins
forall x. ListCustomPlugins -> Rep ListCustomPlugins x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCustomPlugins x -> ListCustomPlugins
$cfrom :: forall x. ListCustomPlugins -> Rep ListCustomPlugins x
Prelude.Generic)

-- |
-- Create a value of 'ListCustomPlugins' 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', 'listCustomPlugins_maxResults' - The maximum number of custom plugins to list in one response.
--
-- 'nextToken', 'listCustomPlugins_nextToken' - If the response of a ListCustomPlugins operation is truncated, it will
-- include a NextToken. Send this NextToken in a subsequent request to
-- continue listing from where the previous operation left off.
newListCustomPlugins ::
  ListCustomPlugins
newListCustomPlugins :: ListCustomPlugins
newListCustomPlugins =
  ListCustomPlugins'
    { $sel:maxResults:ListCustomPlugins' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCustomPlugins' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of custom plugins to list in one response.
listCustomPlugins_maxResults :: Lens.Lens' ListCustomPlugins (Prelude.Maybe Prelude.Natural)
listCustomPlugins_maxResults :: Lens' ListCustomPlugins (Maybe Natural)
listCustomPlugins_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomPlugins' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListCustomPlugins' :: ListCustomPlugins -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListCustomPlugins
s@ListCustomPlugins' {} Maybe Natural
a -> ListCustomPlugins
s {$sel:maxResults:ListCustomPlugins' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListCustomPlugins)

-- | If the response of a ListCustomPlugins operation is truncated, it will
-- include a NextToken. Send this NextToken in a subsequent request to
-- continue listing from where the previous operation left off.
listCustomPlugins_nextToken :: Lens.Lens' ListCustomPlugins (Prelude.Maybe Prelude.Text)
listCustomPlugins_nextToken :: Lens' ListCustomPlugins (Maybe Text)
listCustomPlugins_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomPlugins' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCustomPlugins' :: ListCustomPlugins -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCustomPlugins
s@ListCustomPlugins' {} Maybe Text
a -> ListCustomPlugins
s {$sel:nextToken:ListCustomPlugins' :: Maybe Text
nextToken = Maybe Text
a} :: ListCustomPlugins)

instance Core.AWSPager ListCustomPlugins where
  page :: ListCustomPlugins
-> AWSResponse ListCustomPlugins -> Maybe ListCustomPlugins
page ListCustomPlugins
rq AWSResponse ListCustomPlugins
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListCustomPlugins
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListCustomPluginsResponse (Maybe Text)
listCustomPluginsResponse_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 ListCustomPlugins
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListCustomPluginsResponse (Maybe [CustomPluginSummary])
listCustomPluginsResponse_customPlugins
            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.$ ListCustomPlugins
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListCustomPlugins (Maybe Text)
listCustomPlugins_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListCustomPlugins
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListCustomPluginsResponse (Maybe Text)
listCustomPluginsResponse_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 ListCustomPlugins where
  type
    AWSResponse ListCustomPlugins =
      ListCustomPluginsResponse
  request :: (Service -> Service)
-> ListCustomPlugins -> Request ListCustomPlugins
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 ListCustomPlugins
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListCustomPlugins)))
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 [CustomPluginSummary]
-> Maybe Text -> Int -> ListCustomPluginsResponse
ListCustomPluginsResponse'
            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
"customPlugins" 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 ListCustomPlugins where
  hashWithSalt :: Int -> ListCustomPlugins -> Int
hashWithSalt Int
_salt ListCustomPlugins' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListCustomPlugins' :: ListCustomPlugins -> Maybe Text
$sel:maxResults:ListCustomPlugins' :: ListCustomPlugins -> 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 ListCustomPlugins where
  rnf :: ListCustomPlugins -> ()
rnf ListCustomPlugins' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListCustomPlugins' :: ListCustomPlugins -> Maybe Text
$sel:maxResults:ListCustomPlugins' :: ListCustomPlugins -> 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 ListCustomPlugins where
  toHeaders :: ListCustomPlugins -> 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 ListCustomPlugins where
  toPath :: ListCustomPlugins -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v1/custom-plugins"

instance Data.ToQuery ListCustomPlugins where
  toQuery :: ListCustomPlugins -> QueryString
toQuery ListCustomPlugins' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListCustomPlugins' :: ListCustomPlugins -> Maybe Text
$sel:maxResults:ListCustomPlugins' :: ListCustomPlugins -> 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:/ 'newListCustomPluginsResponse' smart constructor.
data ListCustomPluginsResponse = ListCustomPluginsResponse'
  { -- | An array of custom plugin descriptions.
    ListCustomPluginsResponse -> Maybe [CustomPluginSummary]
customPlugins :: Prelude.Maybe [CustomPluginSummary],
    -- | If the response of a ListCustomPlugins operation is truncated, it will
    -- include a NextToken. Send this NextToken in a subsequent request to
    -- continue listing from where the previous operation left off.
    ListCustomPluginsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListCustomPluginsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListCustomPluginsResponse -> ListCustomPluginsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCustomPluginsResponse -> ListCustomPluginsResponse -> Bool
$c/= :: ListCustomPluginsResponse -> ListCustomPluginsResponse -> Bool
== :: ListCustomPluginsResponse -> ListCustomPluginsResponse -> Bool
$c== :: ListCustomPluginsResponse -> ListCustomPluginsResponse -> Bool
Prelude.Eq, ReadPrec [ListCustomPluginsResponse]
ReadPrec ListCustomPluginsResponse
Int -> ReadS ListCustomPluginsResponse
ReadS [ListCustomPluginsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCustomPluginsResponse]
$creadListPrec :: ReadPrec [ListCustomPluginsResponse]
readPrec :: ReadPrec ListCustomPluginsResponse
$creadPrec :: ReadPrec ListCustomPluginsResponse
readList :: ReadS [ListCustomPluginsResponse]
$creadList :: ReadS [ListCustomPluginsResponse]
readsPrec :: Int -> ReadS ListCustomPluginsResponse
$creadsPrec :: Int -> ReadS ListCustomPluginsResponse
Prelude.Read, Int -> ListCustomPluginsResponse -> ShowS
[ListCustomPluginsResponse] -> ShowS
ListCustomPluginsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCustomPluginsResponse] -> ShowS
$cshowList :: [ListCustomPluginsResponse] -> ShowS
show :: ListCustomPluginsResponse -> String
$cshow :: ListCustomPluginsResponse -> String
showsPrec :: Int -> ListCustomPluginsResponse -> ShowS
$cshowsPrec :: Int -> ListCustomPluginsResponse -> ShowS
Prelude.Show, forall x.
Rep ListCustomPluginsResponse x -> ListCustomPluginsResponse
forall x.
ListCustomPluginsResponse -> Rep ListCustomPluginsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListCustomPluginsResponse x -> ListCustomPluginsResponse
$cfrom :: forall x.
ListCustomPluginsResponse -> Rep ListCustomPluginsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListCustomPluginsResponse' 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:
--
-- 'customPlugins', 'listCustomPluginsResponse_customPlugins' - An array of custom plugin descriptions.
--
-- 'nextToken', 'listCustomPluginsResponse_nextToken' - If the response of a ListCustomPlugins operation is truncated, it will
-- include a NextToken. Send this NextToken in a subsequent request to
-- continue listing from where the previous operation left off.
--
-- 'httpStatus', 'listCustomPluginsResponse_httpStatus' - The response's http status code.
newListCustomPluginsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListCustomPluginsResponse
newListCustomPluginsResponse :: Int -> ListCustomPluginsResponse
newListCustomPluginsResponse Int
pHttpStatus_ =
  ListCustomPluginsResponse'
    { $sel:customPlugins:ListCustomPluginsResponse' :: Maybe [CustomPluginSummary]
customPlugins =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCustomPluginsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListCustomPluginsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of custom plugin descriptions.
listCustomPluginsResponse_customPlugins :: Lens.Lens' ListCustomPluginsResponse (Prelude.Maybe [CustomPluginSummary])
listCustomPluginsResponse_customPlugins :: Lens' ListCustomPluginsResponse (Maybe [CustomPluginSummary])
listCustomPluginsResponse_customPlugins = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomPluginsResponse' {Maybe [CustomPluginSummary]
customPlugins :: Maybe [CustomPluginSummary]
$sel:customPlugins:ListCustomPluginsResponse' :: ListCustomPluginsResponse -> Maybe [CustomPluginSummary]
customPlugins} -> Maybe [CustomPluginSummary]
customPlugins) (\s :: ListCustomPluginsResponse
s@ListCustomPluginsResponse' {} Maybe [CustomPluginSummary]
a -> ListCustomPluginsResponse
s {$sel:customPlugins:ListCustomPluginsResponse' :: Maybe [CustomPluginSummary]
customPlugins = Maybe [CustomPluginSummary]
a} :: ListCustomPluginsResponse) 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

-- | If the response of a ListCustomPlugins operation is truncated, it will
-- include a NextToken. Send this NextToken in a subsequent request to
-- continue listing from where the previous operation left off.
listCustomPluginsResponse_nextToken :: Lens.Lens' ListCustomPluginsResponse (Prelude.Maybe Prelude.Text)
listCustomPluginsResponse_nextToken :: Lens' ListCustomPluginsResponse (Maybe Text)
listCustomPluginsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomPluginsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCustomPluginsResponse' :: ListCustomPluginsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCustomPluginsResponse
s@ListCustomPluginsResponse' {} Maybe Text
a -> ListCustomPluginsResponse
s {$sel:nextToken:ListCustomPluginsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListCustomPluginsResponse)

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

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