{-# 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.AppFlow.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)
--
-- Returns the list of all registered custom connectors in your Amazon Web
-- Services account. This API lists only custom connectors registered in
-- this account, not the Amazon Web Services authored connectors.
module Amazonka.AppFlow.ListConnectors
  ( -- * Creating a Request
    ListConnectors (..),
    newListConnectors,

    -- * Request Lenses
    listConnectors_maxResults,
    listConnectors_nextToken,

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

    -- * Response Lenses
    listConnectorsResponse_connectors,
    listConnectorsResponse_nextToken,
    listConnectorsResponse_httpStatus,
  )
where

import Amazonka.AppFlow.Types
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

-- | /See:/ 'newListConnectors' smart constructor.
data ListConnectors = ListConnectors'
  { -- | Specifies the maximum number of items that should be returned in the
    -- result set. The default for @maxResults@ is 20 (for all paginated API
    -- operations).
    ListConnectors -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token for the next page of data.
    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' - Specifies the maximum number of items that should be returned in the
-- result set. The default for @maxResults@ is 20 (for all paginated API
-- operations).
--
-- 'nextToken', 'listConnectors_nextToken' - The pagination token for the next page of data.
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
    }

-- | Specifies the maximum number of items that should be returned in the
-- result set. The default for @maxResults@ is 20 (for all paginated API
-- operations).
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)

-- | The pagination token for the next page of data.
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.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 [ConnectorDetail]
-> Maybe Text -> Int -> 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
"connectors" 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 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
"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
"/list-connectors"

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'
  { -- | Contains information about the connectors supported by Amazon AppFlow.
    ListConnectorsResponse -> Maybe [ConnectorDetail]
connectors :: Prelude.Maybe [ConnectorDetail],
    -- | The pagination token for the next page of data. If nextToken=null, this
    -- means that all records have been fetched.
    ListConnectorsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListConnectorsResponse -> Int
httpStatus :: Prelude.Int
  }
  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:
--
-- 'connectors', 'listConnectorsResponse_connectors' - Contains information about the connectors supported by Amazon AppFlow.
--
-- 'nextToken', 'listConnectorsResponse_nextToken' - The pagination token for the next page of data. If nextToken=null, this
-- means that all records have been fetched.
--
-- 'httpStatus', 'listConnectorsResponse_httpStatus' - The response's http status code.
newListConnectorsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListConnectorsResponse
newListConnectorsResponse :: Int -> ListConnectorsResponse
newListConnectorsResponse Int
pHttpStatus_ =
  ListConnectorsResponse'
    { $sel:connectors:ListConnectorsResponse' :: Maybe [ConnectorDetail]
connectors =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListConnectorsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListConnectorsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Contains information about the connectors supported by Amazon AppFlow.
listConnectorsResponse_connectors :: Lens.Lens' ListConnectorsResponse (Prelude.Maybe [ConnectorDetail])
listConnectorsResponse_connectors :: Lens' ListConnectorsResponse (Maybe [ConnectorDetail])
listConnectorsResponse_connectors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListConnectorsResponse' {Maybe [ConnectorDetail]
connectors :: Maybe [ConnectorDetail]
$sel:connectors:ListConnectorsResponse' :: ListConnectorsResponse -> Maybe [ConnectorDetail]
connectors} -> Maybe [ConnectorDetail]
connectors) (\s :: ListConnectorsResponse
s@ListConnectorsResponse' {} Maybe [ConnectorDetail]
a -> ListConnectorsResponse
s {$sel:connectors:ListConnectorsResponse' :: Maybe [ConnectorDetail]
connectors = Maybe [ConnectorDetail]
a} :: ListConnectorsResponse) 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 pagination token for the next page of data. If nextToken=null, this
-- means that all records have been fetched.
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)

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