{-# 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.MigrationHubOrchestrator.ListPlugins
-- 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 AWS Migration Hub Orchestrator plugins.
--
-- This operation returns paginated results.
module Amazonka.MigrationHubOrchestrator.ListPlugins
  ( -- * Creating a Request
    ListPlugins (..),
    newListPlugins,

    -- * Request Lenses
    listPlugins_maxResults,
    listPlugins_nextToken,

    -- * Destructuring the Response
    ListPluginsResponse (..),
    newListPluginsResponse,

    -- * Response Lenses
    listPluginsResponse_nextToken,
    listPluginsResponse_plugins,
    listPluginsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListPlugins' smart constructor.
data ListPlugins = ListPlugins'
  { -- | The maximum number of plugins that can be returned.
    ListPlugins -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token.
    ListPlugins -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListPlugins -> ListPlugins -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPlugins -> ListPlugins -> Bool
$c/= :: ListPlugins -> ListPlugins -> Bool
== :: ListPlugins -> ListPlugins -> Bool
$c== :: ListPlugins -> ListPlugins -> Bool
Prelude.Eq, ReadPrec [ListPlugins]
ReadPrec ListPlugins
Int -> ReadS ListPlugins
ReadS [ListPlugins]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPlugins]
$creadListPrec :: ReadPrec [ListPlugins]
readPrec :: ReadPrec ListPlugins
$creadPrec :: ReadPrec ListPlugins
readList :: ReadS [ListPlugins]
$creadList :: ReadS [ListPlugins]
readsPrec :: Int -> ReadS ListPlugins
$creadsPrec :: Int -> ReadS ListPlugins
Prelude.Read, Int -> ListPlugins -> ShowS
[ListPlugins] -> ShowS
ListPlugins -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPlugins] -> ShowS
$cshowList :: [ListPlugins] -> ShowS
show :: ListPlugins -> String
$cshow :: ListPlugins -> String
showsPrec :: Int -> ListPlugins -> ShowS
$cshowsPrec :: Int -> ListPlugins -> ShowS
Prelude.Show, forall x. Rep ListPlugins x -> ListPlugins
forall x. ListPlugins -> Rep ListPlugins x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPlugins x -> ListPlugins
$cfrom :: forall x. ListPlugins -> Rep ListPlugins x
Prelude.Generic)

-- |
-- Create a value of 'ListPlugins' 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', 'listPlugins_maxResults' - The maximum number of plugins that can be returned.
--
-- 'nextToken', 'listPlugins_nextToken' - The pagination token.
newListPlugins ::
  ListPlugins
newListPlugins :: ListPlugins
newListPlugins =
  ListPlugins'
    { $sel:maxResults:ListPlugins' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPlugins' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of plugins that can be returned.
listPlugins_maxResults :: Lens.Lens' ListPlugins (Prelude.Maybe Prelude.Natural)
listPlugins_maxResults :: Lens' ListPlugins (Maybe Natural)
listPlugins_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPlugins' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListPlugins' :: ListPlugins -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListPlugins
s@ListPlugins' {} Maybe Natural
a -> ListPlugins
s {$sel:maxResults:ListPlugins' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListPlugins)

-- | The pagination token.
listPlugins_nextToken :: Lens.Lens' ListPlugins (Prelude.Maybe Prelude.Text)
listPlugins_nextToken :: Lens' ListPlugins (Maybe Text)
listPlugins_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPlugins' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPlugins' :: ListPlugins -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPlugins
s@ListPlugins' {} Maybe Text
a -> ListPlugins
s {$sel:nextToken:ListPlugins' :: Maybe Text
nextToken = Maybe Text
a} :: ListPlugins)

instance Core.AWSPager ListPlugins where
  page :: ListPlugins -> AWSResponse ListPlugins -> Maybe ListPlugins
page ListPlugins
rq AWSResponse ListPlugins
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPlugins
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPluginsResponse (Maybe Text)
listPluginsResponse_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 ListPlugins
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPluginsResponse (Maybe [PluginSummary])
listPluginsResponse_plugins
            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.$ ListPlugins
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListPlugins (Maybe Text)
listPlugins_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPlugins
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPluginsResponse (Maybe Text)
listPluginsResponse_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 ListPlugins where
  type AWSResponse ListPlugins = ListPluginsResponse
  request :: (Service -> Service) -> ListPlugins -> Request ListPlugins
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 ListPlugins
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPlugins)))
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 [PluginSummary] -> Int -> ListPluginsResponse
ListPluginsResponse'
            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
"nextToken")
            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
"plugins" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListPlugins where
  hashWithSalt :: Int -> ListPlugins -> Int
hashWithSalt Int
_salt ListPlugins' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPlugins' :: ListPlugins -> Maybe Text
$sel:maxResults:ListPlugins' :: ListPlugins -> 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 ListPlugins where
  rnf :: ListPlugins -> ()
rnf ListPlugins' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPlugins' :: ListPlugins -> Maybe Text
$sel:maxResults:ListPlugins' :: ListPlugins -> 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 ListPlugins where
  toHeaders :: ListPlugins -> 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 ListPlugins where
  toPath :: ListPlugins -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/plugins"

instance Data.ToQuery ListPlugins where
  toQuery :: ListPlugins -> QueryString
toQuery ListPlugins' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPlugins' :: ListPlugins -> Maybe Text
$sel:maxResults:ListPlugins' :: ListPlugins -> 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:/ 'newListPluginsResponse' smart constructor.
data ListPluginsResponse = ListPluginsResponse'
  { -- | The pagination token.
    ListPluginsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Migration Hub Orchestrator plugins.
    ListPluginsResponse -> Maybe [PluginSummary]
plugins :: Prelude.Maybe [PluginSummary],
    -- | The response's http status code.
    ListPluginsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPluginsResponse -> ListPluginsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPluginsResponse -> ListPluginsResponse -> Bool
$c/= :: ListPluginsResponse -> ListPluginsResponse -> Bool
== :: ListPluginsResponse -> ListPluginsResponse -> Bool
$c== :: ListPluginsResponse -> ListPluginsResponse -> Bool
Prelude.Eq, ReadPrec [ListPluginsResponse]
ReadPrec ListPluginsResponse
Int -> ReadS ListPluginsResponse
ReadS [ListPluginsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPluginsResponse]
$creadListPrec :: ReadPrec [ListPluginsResponse]
readPrec :: ReadPrec ListPluginsResponse
$creadPrec :: ReadPrec ListPluginsResponse
readList :: ReadS [ListPluginsResponse]
$creadList :: ReadS [ListPluginsResponse]
readsPrec :: Int -> ReadS ListPluginsResponse
$creadsPrec :: Int -> ReadS ListPluginsResponse
Prelude.Read, Int -> ListPluginsResponse -> ShowS
[ListPluginsResponse] -> ShowS
ListPluginsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPluginsResponse] -> ShowS
$cshowList :: [ListPluginsResponse] -> ShowS
show :: ListPluginsResponse -> String
$cshow :: ListPluginsResponse -> String
showsPrec :: Int -> ListPluginsResponse -> ShowS
$cshowsPrec :: Int -> ListPluginsResponse -> ShowS
Prelude.Show, forall x. Rep ListPluginsResponse x -> ListPluginsResponse
forall x. ListPluginsResponse -> Rep ListPluginsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPluginsResponse x -> ListPluginsResponse
$cfrom :: forall x. ListPluginsResponse -> Rep ListPluginsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPluginsResponse' 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', 'listPluginsResponse_nextToken' - The pagination token.
--
-- 'plugins', 'listPluginsResponse_plugins' - Migration Hub Orchestrator plugins.
--
-- 'httpStatus', 'listPluginsResponse_httpStatus' - The response's http status code.
newListPluginsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPluginsResponse
newListPluginsResponse :: Int -> ListPluginsResponse
newListPluginsResponse Int
pHttpStatus_ =
  ListPluginsResponse'
    { $sel:nextToken:ListPluginsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:plugins:ListPluginsResponse' :: Maybe [PluginSummary]
plugins = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPluginsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The pagination token.
listPluginsResponse_nextToken :: Lens.Lens' ListPluginsResponse (Prelude.Maybe Prelude.Text)
listPluginsResponse_nextToken :: Lens' ListPluginsResponse (Maybe Text)
listPluginsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPluginsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPluginsResponse' :: ListPluginsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPluginsResponse
s@ListPluginsResponse' {} Maybe Text
a -> ListPluginsResponse
s {$sel:nextToken:ListPluginsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListPluginsResponse)

-- | Migration Hub Orchestrator plugins.
listPluginsResponse_plugins :: Lens.Lens' ListPluginsResponse (Prelude.Maybe [PluginSummary])
listPluginsResponse_plugins :: Lens' ListPluginsResponse (Maybe [PluginSummary])
listPluginsResponse_plugins = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPluginsResponse' {Maybe [PluginSummary]
plugins :: Maybe [PluginSummary]
$sel:plugins:ListPluginsResponse' :: ListPluginsResponse -> Maybe [PluginSummary]
plugins} -> Maybe [PluginSummary]
plugins) (\s :: ListPluginsResponse
s@ListPluginsResponse' {} Maybe [PluginSummary]
a -> ListPluginsResponse
s {$sel:plugins:ListPluginsResponse' :: Maybe [PluginSummary]
plugins = Maybe [PluginSummary]
a} :: ListPluginsResponse) 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 response's http status code.
listPluginsResponse_httpStatus :: Lens.Lens' ListPluginsResponse Prelude.Int
listPluginsResponse_httpStatus :: Lens' ListPluginsResponse Int
listPluginsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPluginsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListPluginsResponse' :: ListPluginsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListPluginsResponse
s@ListPluginsResponse' {} Int
a -> ListPluginsResponse
s {$sel:httpStatus:ListPluginsResponse' :: Int
httpStatus = Int
a} :: ListPluginsResponse)

instance Prelude.NFData ListPluginsResponse where
  rnf :: ListPluginsResponse -> ()
rnf ListPluginsResponse' {Int
Maybe [PluginSummary]
Maybe Text
httpStatus :: Int
plugins :: Maybe [PluginSummary]
nextToken :: Maybe Text
$sel:httpStatus:ListPluginsResponse' :: ListPluginsResponse -> Int
$sel:plugins:ListPluginsResponse' :: ListPluginsResponse -> Maybe [PluginSummary]
$sel:nextToken:ListPluginsResponse' :: ListPluginsResponse -> 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 [PluginSummary]
plugins
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus