{-# 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.MigrationHubStrategy.ListCollectors
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves a list of all the installed collectors.
--
-- This operation returns paginated results.
module Amazonka.MigrationHubStrategy.ListCollectors
  ( -- * Creating a Request
    ListCollectors (..),
    newListCollectors,

    -- * Request Lenses
    listCollectors_maxResults,
    listCollectors_nextToken,

    -- * Destructuring the Response
    ListCollectorsResponse (..),
    newListCollectorsResponse,

    -- * Response Lenses
    listCollectorsResponse_collectors,
    listCollectorsResponse_nextToken,
    listCollectorsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListCollectors' smart constructor.
data ListCollectors = ListCollectors'
  { -- | The maximum number of items to include in the response. The maximum
    -- value is 100.
    ListCollectors -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The token from a previous call that you use to retrieve the next set of
    -- results. For example, if a previous call to this action returned 100
    -- items, but you set @maxResults@ to 10. You\'ll receive a set of 10
    -- results along with a token. You then use the returned token to retrieve
    -- the next set of 10.
    ListCollectors -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListCollectors -> ListCollectors -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCollectors -> ListCollectors -> Bool
$c/= :: ListCollectors -> ListCollectors -> Bool
== :: ListCollectors -> ListCollectors -> Bool
$c== :: ListCollectors -> ListCollectors -> Bool
Prelude.Eq, ReadPrec [ListCollectors]
ReadPrec ListCollectors
Int -> ReadS ListCollectors
ReadS [ListCollectors]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCollectors]
$creadListPrec :: ReadPrec [ListCollectors]
readPrec :: ReadPrec ListCollectors
$creadPrec :: ReadPrec ListCollectors
readList :: ReadS [ListCollectors]
$creadList :: ReadS [ListCollectors]
readsPrec :: Int -> ReadS ListCollectors
$creadsPrec :: Int -> ReadS ListCollectors
Prelude.Read, Int -> ListCollectors -> ShowS
[ListCollectors] -> ShowS
ListCollectors -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCollectors] -> ShowS
$cshowList :: [ListCollectors] -> ShowS
show :: ListCollectors -> String
$cshow :: ListCollectors -> String
showsPrec :: Int -> ListCollectors -> ShowS
$cshowsPrec :: Int -> ListCollectors -> ShowS
Prelude.Show, forall x. Rep ListCollectors x -> ListCollectors
forall x. ListCollectors -> Rep ListCollectors x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCollectors x -> ListCollectors
$cfrom :: forall x. ListCollectors -> Rep ListCollectors x
Prelude.Generic)

-- |
-- Create a value of 'ListCollectors' 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', 'listCollectors_maxResults' - The maximum number of items to include in the response. The maximum
-- value is 100.
--
-- 'nextToken', 'listCollectors_nextToken' - The token from a previous call that you use to retrieve the next set of
-- results. For example, if a previous call to this action returned 100
-- items, but you set @maxResults@ to 10. You\'ll receive a set of 10
-- results along with a token. You then use the returned token to retrieve
-- the next set of 10.
newListCollectors ::
  ListCollectors
newListCollectors :: ListCollectors
newListCollectors =
  ListCollectors'
    { $sel:maxResults:ListCollectors' :: Maybe Int
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCollectors' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of items to include in the response. The maximum
-- value is 100.
listCollectors_maxResults :: Lens.Lens' ListCollectors (Prelude.Maybe Prelude.Int)
listCollectors_maxResults :: Lens' ListCollectors (Maybe Int)
listCollectors_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCollectors' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:ListCollectors' :: ListCollectors -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: ListCollectors
s@ListCollectors' {} Maybe Int
a -> ListCollectors
s {$sel:maxResults:ListCollectors' :: Maybe Int
maxResults = Maybe Int
a} :: ListCollectors)

-- | The token from a previous call that you use to retrieve the next set of
-- results. For example, if a previous call to this action returned 100
-- items, but you set @maxResults@ to 10. You\'ll receive a set of 10
-- results along with a token. You then use the returned token to retrieve
-- the next set of 10.
listCollectors_nextToken :: Lens.Lens' ListCollectors (Prelude.Maybe Prelude.Text)
listCollectors_nextToken :: Lens' ListCollectors (Maybe Text)
listCollectors_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCollectors' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCollectors' :: ListCollectors -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCollectors
s@ListCollectors' {} Maybe Text
a -> ListCollectors
s {$sel:nextToken:ListCollectors' :: Maybe Text
nextToken = Maybe Text
a} :: ListCollectors)

instance Core.AWSPager ListCollectors where
  page :: ListCollectors
-> AWSResponse ListCollectors -> Maybe ListCollectors
page ListCollectors
rq AWSResponse ListCollectors
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListCollectors
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListCollectorsResponse (Maybe Text)
listCollectorsResponse_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 ListCollectors
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListCollectorsResponse (Maybe [Collector])
listCollectorsResponse_collectors
            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.$ ListCollectors
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListCollectors (Maybe Text)
listCollectors_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListCollectors
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListCollectorsResponse (Maybe Text)
listCollectorsResponse_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 ListCollectors where
  type
    AWSResponse ListCollectors =
      ListCollectorsResponse
  request :: (Service -> Service) -> ListCollectors -> Request ListCollectors
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 ListCollectors
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListCollectors)))
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 [Collector] -> Maybe Text -> Int -> ListCollectorsResponse
ListCollectorsResponse'
            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
"Collectors" 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 ListCollectors where
  hashWithSalt :: Int -> ListCollectors -> Int
hashWithSalt Int
_salt ListCollectors' {Maybe Int
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Int
$sel:nextToken:ListCollectors' :: ListCollectors -> Maybe Text
$sel:maxResults:ListCollectors' :: ListCollectors -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

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

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

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

-- | /See:/ 'newListCollectorsResponse' smart constructor.
data ListCollectorsResponse = ListCollectorsResponse'
  { -- | The list of all the installed collectors.
    ListCollectorsResponse -> Maybe [Collector]
collectors :: Prelude.Maybe [Collector],
    -- | The token you use to retrieve the next set of results, or null if there
    -- are no more results.
    ListCollectorsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListCollectorsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListCollectorsResponse -> ListCollectorsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCollectorsResponse -> ListCollectorsResponse -> Bool
$c/= :: ListCollectorsResponse -> ListCollectorsResponse -> Bool
== :: ListCollectorsResponse -> ListCollectorsResponse -> Bool
$c== :: ListCollectorsResponse -> ListCollectorsResponse -> Bool
Prelude.Eq, ReadPrec [ListCollectorsResponse]
ReadPrec ListCollectorsResponse
Int -> ReadS ListCollectorsResponse
ReadS [ListCollectorsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCollectorsResponse]
$creadListPrec :: ReadPrec [ListCollectorsResponse]
readPrec :: ReadPrec ListCollectorsResponse
$creadPrec :: ReadPrec ListCollectorsResponse
readList :: ReadS [ListCollectorsResponse]
$creadList :: ReadS [ListCollectorsResponse]
readsPrec :: Int -> ReadS ListCollectorsResponse
$creadsPrec :: Int -> ReadS ListCollectorsResponse
Prelude.Read, Int -> ListCollectorsResponse -> ShowS
[ListCollectorsResponse] -> ShowS
ListCollectorsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCollectorsResponse] -> ShowS
$cshowList :: [ListCollectorsResponse] -> ShowS
show :: ListCollectorsResponse -> String
$cshow :: ListCollectorsResponse -> String
showsPrec :: Int -> ListCollectorsResponse -> ShowS
$cshowsPrec :: Int -> ListCollectorsResponse -> ShowS
Prelude.Show, forall x. Rep ListCollectorsResponse x -> ListCollectorsResponse
forall x. ListCollectorsResponse -> Rep ListCollectorsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCollectorsResponse x -> ListCollectorsResponse
$cfrom :: forall x. ListCollectorsResponse -> Rep ListCollectorsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListCollectorsResponse' 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:
--
-- 'collectors', 'listCollectorsResponse_collectors' - The list of all the installed collectors.
--
-- 'nextToken', 'listCollectorsResponse_nextToken' - The token you use to retrieve the next set of results, or null if there
-- are no more results.
--
-- 'httpStatus', 'listCollectorsResponse_httpStatus' - The response's http status code.
newListCollectorsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListCollectorsResponse
newListCollectorsResponse :: Int -> ListCollectorsResponse
newListCollectorsResponse Int
pHttpStatus_ =
  ListCollectorsResponse'
    { $sel:collectors:ListCollectorsResponse' :: Maybe [Collector]
collectors =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCollectorsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListCollectorsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of all the installed collectors.
listCollectorsResponse_collectors :: Lens.Lens' ListCollectorsResponse (Prelude.Maybe [Collector])
listCollectorsResponse_collectors :: Lens' ListCollectorsResponse (Maybe [Collector])
listCollectorsResponse_collectors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCollectorsResponse' {Maybe [Collector]
collectors :: Maybe [Collector]
$sel:collectors:ListCollectorsResponse' :: ListCollectorsResponse -> Maybe [Collector]
collectors} -> Maybe [Collector]
collectors) (\s :: ListCollectorsResponse
s@ListCollectorsResponse' {} Maybe [Collector]
a -> ListCollectorsResponse
s {$sel:collectors:ListCollectorsResponse' :: Maybe [Collector]
collectors = Maybe [Collector]
a} :: ListCollectorsResponse) 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 token you use to retrieve the next set of results, or null if there
-- are no more results.
listCollectorsResponse_nextToken :: Lens.Lens' ListCollectorsResponse (Prelude.Maybe Prelude.Text)
listCollectorsResponse_nextToken :: Lens' ListCollectorsResponse (Maybe Text)
listCollectorsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCollectorsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCollectorsResponse' :: ListCollectorsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCollectorsResponse
s@ListCollectorsResponse' {} Maybe Text
a -> ListCollectorsResponse
s {$sel:nextToken:ListCollectorsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListCollectorsResponse)

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

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