{-# 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.Transfer.ListConnectors
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the connectors for the specified Region.
--
-- This operation returns paginated results.
module Amazonka.Transfer.ListConnectors
  ( -- * Creating a Request
    ListConnectors (..),
    newListConnectors,

    -- * Request Lenses
    listConnectors_maxResults,
    listConnectors_nextToken,

    -- * Destructuring the Response
    ListConnectorsResponse (..),
    newListConnectorsResponse,

    -- * Response Lenses
    listConnectorsResponse_nextToken,
    listConnectorsResponse_httpStatus,
    listConnectorsResponse_connectors,
  )
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.Transfer.Types

-- | /See:/ 'newListConnectors' smart constructor.
data ListConnectors = ListConnectors'
  { -- | The maximum number of connectors to return.
    ListConnectors -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | When you can get additional results from the @ListConnectors@ call, a
    -- @NextToken@ parameter is returned in the output. You can then pass in a
    -- subsequent command to the @NextToken@ parameter to continue listing
    -- additional connectors.
    ListConnectors -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListConnectors -> ListConnectors -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListConnectors -> ListConnectors -> Bool
$c/= :: ListConnectors -> ListConnectors -> Bool
== :: ListConnectors -> ListConnectors -> Bool
$c== :: ListConnectors -> ListConnectors -> Bool
Prelude.Eq, ReadPrec [ListConnectors]
ReadPrec ListConnectors
Int -> ReadS ListConnectors
ReadS [ListConnectors]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListConnectors]
$creadListPrec :: ReadPrec [ListConnectors]
readPrec :: ReadPrec ListConnectors
$creadPrec :: ReadPrec ListConnectors
readList :: ReadS [ListConnectors]
$creadList :: ReadS [ListConnectors]
readsPrec :: Int -> ReadS ListConnectors
$creadsPrec :: Int -> ReadS ListConnectors
Prelude.Read, Int -> ListConnectors -> ShowS
[ListConnectors] -> ShowS
ListConnectors -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListConnectors] -> ShowS
$cshowList :: [ListConnectors] -> ShowS
show :: ListConnectors -> String
$cshow :: ListConnectors -> String
showsPrec :: Int -> ListConnectors -> ShowS
$cshowsPrec :: Int -> ListConnectors -> ShowS
Prelude.Show, forall x. Rep ListConnectors x -> ListConnectors
forall x. ListConnectors -> Rep ListConnectors x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListConnectors x -> ListConnectors
$cfrom :: forall x. ListConnectors -> Rep ListConnectors x
Prelude.Generic)

-- |
-- Create a value of 'ListConnectors' 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', 'listConnectors_maxResults' - The maximum number of connectors to return.
--
-- 'nextToken', 'listConnectors_nextToken' - When you can get additional results from the @ListConnectors@ call, a
-- @NextToken@ parameter is returned in the output. You can then pass in a
-- subsequent command to the @NextToken@ parameter to continue listing
-- additional connectors.
newListConnectors ::
  ListConnectors
newListConnectors :: ListConnectors
newListConnectors =
  ListConnectors'
    { $sel:maxResults:ListConnectors' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListConnectors' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of connectors to return.
listConnectors_maxResults :: Lens.Lens' ListConnectors (Prelude.Maybe Prelude.Natural)
listConnectors_maxResults :: Lens' ListConnectors (Maybe Natural)
listConnectors_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConnectors' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListConnectors' :: ListConnectors -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListConnectors
s@ListConnectors' {} Maybe Natural
a -> ListConnectors
s {$sel:maxResults:ListConnectors' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListConnectors)

-- | When you can get additional results from the @ListConnectors@ call, a
-- @NextToken@ parameter is returned in the output. You can then pass in a
-- subsequent command to the @NextToken@ parameter to continue listing
-- additional connectors.
listConnectors_nextToken :: Lens.Lens' ListConnectors (Prelude.Maybe Prelude.Text)
listConnectors_nextToken :: Lens' ListConnectors (Maybe Text)
listConnectors_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConnectors' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListConnectors' :: ListConnectors -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListConnectors
s@ListConnectors' {} Maybe Text
a -> ListConnectors
s {$sel:nextToken:ListConnectors' :: Maybe Text
nextToken = Maybe Text
a} :: ListConnectors)

instance Core.AWSPager ListConnectors where
  page :: ListConnectors
-> AWSResponse ListConnectors -> Maybe ListConnectors
page ListConnectors
rq AWSResponse ListConnectors
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListConnectors
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListConnectorsResponse (Maybe Text)
listConnectorsResponse_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 ListConnectors
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListConnectorsResponse [ListedConnector]
listConnectorsResponse_connectors) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListConnectors
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListConnectors (Maybe Text)
listConnectors_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListConnectors
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListConnectorsResponse (Maybe Text)
listConnectorsResponse_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 ListConnectors where
  type
    AWSResponse ListConnectors =
      ListConnectorsResponse
  request :: (Service -> Service) -> ListConnectors -> Request ListConnectors
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListConnectors
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListConnectors)))
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 -> Int -> [ListedConnector] -> ListConnectorsResponse
ListConnectorsResponse'
            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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            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
"Connectors" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListConnectors where
  hashWithSalt :: Int -> ListConnectors -> Int
hashWithSalt Int
_salt ListConnectors' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListConnectors' :: ListConnectors -> Maybe Text
$sel:maxResults:ListConnectors' :: ListConnectors -> 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 ListConnectors where
  rnf :: ListConnectors -> ()
rnf ListConnectors' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListConnectors' :: ListConnectors -> Maybe Text
$sel:maxResults:ListConnectors' :: ListConnectors -> 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 ListConnectors where
  toHeaders :: ListConnectors -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"TransferService.ListConnectors" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ListConnectors where
  toJSON :: ListConnectors -> Value
toJSON ListConnectors' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListConnectors' :: ListConnectors -> Maybe Text
$sel:maxResults:ListConnectors' :: ListConnectors -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
          ]
      )

instance Data.ToPath ListConnectors where
  toPath :: ListConnectors -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery ListConnectors where
  toQuery :: ListConnectors -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListConnectorsResponse' smart constructor.
data ListConnectorsResponse = ListConnectorsResponse'
  { -- | Returns a token that you can use to call @ListConnectors@ again and
    -- receive additional results, if there are any.
    ListConnectorsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListConnectorsResponse -> Int
httpStatus :: Prelude.Int,
    -- | Returns an array, where each item contains the details of a connector.
    ListConnectorsResponse -> [ListedConnector]
connectors :: [ListedConnector]
  }
  deriving (ListConnectorsResponse -> ListConnectorsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListConnectorsResponse -> ListConnectorsResponse -> Bool
$c/= :: ListConnectorsResponse -> ListConnectorsResponse -> Bool
== :: ListConnectorsResponse -> ListConnectorsResponse -> Bool
$c== :: ListConnectorsResponse -> ListConnectorsResponse -> Bool
Prelude.Eq, ReadPrec [ListConnectorsResponse]
ReadPrec ListConnectorsResponse
Int -> ReadS ListConnectorsResponse
ReadS [ListConnectorsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListConnectorsResponse]
$creadListPrec :: ReadPrec [ListConnectorsResponse]
readPrec :: ReadPrec ListConnectorsResponse
$creadPrec :: ReadPrec ListConnectorsResponse
readList :: ReadS [ListConnectorsResponse]
$creadList :: ReadS [ListConnectorsResponse]
readsPrec :: Int -> ReadS ListConnectorsResponse
$creadsPrec :: Int -> ReadS ListConnectorsResponse
Prelude.Read, Int -> ListConnectorsResponse -> ShowS
[ListConnectorsResponse] -> ShowS
ListConnectorsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListConnectorsResponse] -> ShowS
$cshowList :: [ListConnectorsResponse] -> ShowS
show :: ListConnectorsResponse -> String
$cshow :: ListConnectorsResponse -> String
showsPrec :: Int -> ListConnectorsResponse -> ShowS
$cshowsPrec :: Int -> ListConnectorsResponse -> ShowS
Prelude.Show, forall x. Rep ListConnectorsResponse x -> ListConnectorsResponse
forall x. ListConnectorsResponse -> Rep ListConnectorsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListConnectorsResponse x -> ListConnectorsResponse
$cfrom :: forall x. ListConnectorsResponse -> Rep ListConnectorsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListConnectorsResponse' 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', 'listConnectorsResponse_nextToken' - Returns a token that you can use to call @ListConnectors@ again and
-- receive additional results, if there are any.
--
-- 'httpStatus', 'listConnectorsResponse_httpStatus' - The response's http status code.
--
-- 'connectors', 'listConnectorsResponse_connectors' - Returns an array, where each item contains the details of a connector.
newListConnectorsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListConnectorsResponse
newListConnectorsResponse :: Int -> ListConnectorsResponse
newListConnectorsResponse Int
pHttpStatus_ =
  ListConnectorsResponse'
    { $sel:nextToken:ListConnectorsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListConnectorsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:connectors:ListConnectorsResponse' :: [ListedConnector]
connectors = forall a. Monoid a => a
Prelude.mempty
    }

-- | Returns a token that you can use to call @ListConnectors@ again and
-- receive additional results, if there are any.
listConnectorsResponse_nextToken :: Lens.Lens' ListConnectorsResponse (Prelude.Maybe Prelude.Text)
listConnectorsResponse_nextToken :: Lens' ListConnectorsResponse (Maybe Text)
listConnectorsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConnectorsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListConnectorsResponse' :: ListConnectorsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListConnectorsResponse
s@ListConnectorsResponse' {} Maybe Text
a -> ListConnectorsResponse
s {$sel:nextToken:ListConnectorsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListConnectorsResponse)

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

-- | Returns an array, where each item contains the details of a connector.
listConnectorsResponse_connectors :: Lens.Lens' ListConnectorsResponse [ListedConnector]
listConnectorsResponse_connectors :: Lens' ListConnectorsResponse [ListedConnector]
listConnectorsResponse_connectors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConnectorsResponse' {[ListedConnector]
connectors :: [ListedConnector]
$sel:connectors:ListConnectorsResponse' :: ListConnectorsResponse -> [ListedConnector]
connectors} -> [ListedConnector]
connectors) (\s :: ListConnectorsResponse
s@ListConnectorsResponse' {} [ListedConnector]
a -> ListConnectorsResponse
s {$sel:connectors:ListConnectorsResponse' :: [ListedConnector]
connectors = [ListedConnector]
a} :: ListConnectorsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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