{-# 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.AppIntegrationS.ListDataIntegrations
-- 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 paginated list of DataIntegrations in the account.
--
-- You cannot create a DataIntegration association for a DataIntegration
-- that has been previously associated. Use a different DataIntegration, or
-- recreate the DataIntegration using the
-- <https://docs.aws.amazon.com/appintegrations/latest/APIReference/API_CreateDataIntegration.html CreateDataIntegration>
-- API.
module Amazonka.AppIntegrationS.ListDataIntegrations
  ( -- * Creating a Request
    ListDataIntegrations (..),
    newListDataIntegrations,

    -- * Request Lenses
    listDataIntegrations_maxResults,
    listDataIntegrations_nextToken,

    -- * Destructuring the Response
    ListDataIntegrationsResponse (..),
    newListDataIntegrationsResponse,

    -- * Response Lenses
    listDataIntegrationsResponse_dataIntegrations,
    listDataIntegrationsResponse_nextToken,
    listDataIntegrationsResponse_httpStatus,
  )
where

import Amazonka.AppIntegrationS.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:/ 'newListDataIntegrations' smart constructor.
data ListDataIntegrations = ListDataIntegrations'
  { -- | The maximum number of results to return per page.
    ListDataIntegrations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token for the next set of results. Use the value returned in the
    -- previous response in the next request to retrieve the next set of
    -- results.
    ListDataIntegrations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListDataIntegrations -> ListDataIntegrations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDataIntegrations -> ListDataIntegrations -> Bool
$c/= :: ListDataIntegrations -> ListDataIntegrations -> Bool
== :: ListDataIntegrations -> ListDataIntegrations -> Bool
$c== :: ListDataIntegrations -> ListDataIntegrations -> Bool
Prelude.Eq, ReadPrec [ListDataIntegrations]
ReadPrec ListDataIntegrations
Int -> ReadS ListDataIntegrations
ReadS [ListDataIntegrations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDataIntegrations]
$creadListPrec :: ReadPrec [ListDataIntegrations]
readPrec :: ReadPrec ListDataIntegrations
$creadPrec :: ReadPrec ListDataIntegrations
readList :: ReadS [ListDataIntegrations]
$creadList :: ReadS [ListDataIntegrations]
readsPrec :: Int -> ReadS ListDataIntegrations
$creadsPrec :: Int -> ReadS ListDataIntegrations
Prelude.Read, Int -> ListDataIntegrations -> ShowS
[ListDataIntegrations] -> ShowS
ListDataIntegrations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDataIntegrations] -> ShowS
$cshowList :: [ListDataIntegrations] -> ShowS
show :: ListDataIntegrations -> String
$cshow :: ListDataIntegrations -> String
showsPrec :: Int -> ListDataIntegrations -> ShowS
$cshowsPrec :: Int -> ListDataIntegrations -> ShowS
Prelude.Show, forall x. Rep ListDataIntegrations x -> ListDataIntegrations
forall x. ListDataIntegrations -> Rep ListDataIntegrations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDataIntegrations x -> ListDataIntegrations
$cfrom :: forall x. ListDataIntegrations -> Rep ListDataIntegrations x
Prelude.Generic)

-- |
-- Create a value of 'ListDataIntegrations' 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', 'listDataIntegrations_maxResults' - The maximum number of results to return per page.
--
-- 'nextToken', 'listDataIntegrations_nextToken' - The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
newListDataIntegrations ::
  ListDataIntegrations
newListDataIntegrations :: ListDataIntegrations
newListDataIntegrations =
  ListDataIntegrations'
    { $sel:maxResults:ListDataIntegrations' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDataIntegrations' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
listDataIntegrations_nextToken :: Lens.Lens' ListDataIntegrations (Prelude.Maybe Prelude.Text)
listDataIntegrations_nextToken :: Lens' ListDataIntegrations (Maybe Text)
listDataIntegrations_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataIntegrations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDataIntegrations' :: ListDataIntegrations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDataIntegrations
s@ListDataIntegrations' {} Maybe Text
a -> ListDataIntegrations
s {$sel:nextToken:ListDataIntegrations' :: Maybe Text
nextToken = Maybe Text
a} :: ListDataIntegrations)

instance Core.AWSRequest ListDataIntegrations where
  type
    AWSResponse ListDataIntegrations =
      ListDataIntegrationsResponse
  request :: (Service -> Service)
-> ListDataIntegrations -> Request ListDataIntegrations
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 ListDataIntegrations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListDataIntegrations)))
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 (NonEmpty DataIntegrationSummary)
-> Maybe Text -> Int -> ListDataIntegrationsResponse
ListDataIntegrationsResponse'
            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
"DataIntegrations")
            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 ListDataIntegrations where
  hashWithSalt :: Int -> ListDataIntegrations -> Int
hashWithSalt Int
_salt ListDataIntegrations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDataIntegrations' :: ListDataIntegrations -> Maybe Text
$sel:maxResults:ListDataIntegrations' :: ListDataIntegrations -> 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 ListDataIntegrations where
  rnf :: ListDataIntegrations -> ()
rnf ListDataIntegrations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDataIntegrations' :: ListDataIntegrations -> Maybe Text
$sel:maxResults:ListDataIntegrations' :: ListDataIntegrations -> 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 ListDataIntegrations where
  toHeaders :: ListDataIntegrations -> 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 ListDataIntegrations where
  toPath :: ListDataIntegrations -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/dataIntegrations"

instance Data.ToQuery ListDataIntegrations where
  toQuery :: ListDataIntegrations -> QueryString
toQuery ListDataIntegrations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDataIntegrations' :: ListDataIntegrations -> Maybe Text
$sel:maxResults:ListDataIntegrations' :: ListDataIntegrations -> 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:/ 'newListDataIntegrationsResponse' smart constructor.
data ListDataIntegrationsResponse = ListDataIntegrationsResponse'
  { -- | The DataIntegrations associated with this account.
    ListDataIntegrationsResponse
-> Maybe (NonEmpty DataIntegrationSummary)
dataIntegrations :: Prelude.Maybe (Prelude.NonEmpty DataIntegrationSummary),
    -- | If there are additional results, this is the token for the next set of
    -- results.
    ListDataIntegrationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDataIntegrationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDataIntegrationsResponse
-> ListDataIntegrationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDataIntegrationsResponse
-> ListDataIntegrationsResponse -> Bool
$c/= :: ListDataIntegrationsResponse
-> ListDataIntegrationsResponse -> Bool
== :: ListDataIntegrationsResponse
-> ListDataIntegrationsResponse -> Bool
$c== :: ListDataIntegrationsResponse
-> ListDataIntegrationsResponse -> Bool
Prelude.Eq, ReadPrec [ListDataIntegrationsResponse]
ReadPrec ListDataIntegrationsResponse
Int -> ReadS ListDataIntegrationsResponse
ReadS [ListDataIntegrationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDataIntegrationsResponse]
$creadListPrec :: ReadPrec [ListDataIntegrationsResponse]
readPrec :: ReadPrec ListDataIntegrationsResponse
$creadPrec :: ReadPrec ListDataIntegrationsResponse
readList :: ReadS [ListDataIntegrationsResponse]
$creadList :: ReadS [ListDataIntegrationsResponse]
readsPrec :: Int -> ReadS ListDataIntegrationsResponse
$creadsPrec :: Int -> ReadS ListDataIntegrationsResponse
Prelude.Read, Int -> ListDataIntegrationsResponse -> ShowS
[ListDataIntegrationsResponse] -> ShowS
ListDataIntegrationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDataIntegrationsResponse] -> ShowS
$cshowList :: [ListDataIntegrationsResponse] -> ShowS
show :: ListDataIntegrationsResponse -> String
$cshow :: ListDataIntegrationsResponse -> String
showsPrec :: Int -> ListDataIntegrationsResponse -> ShowS
$cshowsPrec :: Int -> ListDataIntegrationsResponse -> ShowS
Prelude.Show, forall x.
Rep ListDataIntegrationsResponse x -> ListDataIntegrationsResponse
forall x.
ListDataIntegrationsResponse -> Rep ListDataIntegrationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListDataIntegrationsResponse x -> ListDataIntegrationsResponse
$cfrom :: forall x.
ListDataIntegrationsResponse -> Rep ListDataIntegrationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDataIntegrationsResponse' 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:
--
-- 'dataIntegrations', 'listDataIntegrationsResponse_dataIntegrations' - The DataIntegrations associated with this account.
--
-- 'nextToken', 'listDataIntegrationsResponse_nextToken' - If there are additional results, this is the token for the next set of
-- results.
--
-- 'httpStatus', 'listDataIntegrationsResponse_httpStatus' - The response's http status code.
newListDataIntegrationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDataIntegrationsResponse
newListDataIntegrationsResponse :: Int -> ListDataIntegrationsResponse
newListDataIntegrationsResponse Int
pHttpStatus_ =
  ListDataIntegrationsResponse'
    { $sel:dataIntegrations:ListDataIntegrationsResponse' :: Maybe (NonEmpty DataIntegrationSummary)
dataIntegrations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDataIntegrationsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDataIntegrationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The DataIntegrations associated with this account.
listDataIntegrationsResponse_dataIntegrations :: Lens.Lens' ListDataIntegrationsResponse (Prelude.Maybe (Prelude.NonEmpty DataIntegrationSummary))
listDataIntegrationsResponse_dataIntegrations :: Lens'
  ListDataIntegrationsResponse
  (Maybe (NonEmpty DataIntegrationSummary))
listDataIntegrationsResponse_dataIntegrations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataIntegrationsResponse' {Maybe (NonEmpty DataIntegrationSummary)
dataIntegrations :: Maybe (NonEmpty DataIntegrationSummary)
$sel:dataIntegrations:ListDataIntegrationsResponse' :: ListDataIntegrationsResponse
-> Maybe (NonEmpty DataIntegrationSummary)
dataIntegrations} -> Maybe (NonEmpty DataIntegrationSummary)
dataIntegrations) (\s :: ListDataIntegrationsResponse
s@ListDataIntegrationsResponse' {} Maybe (NonEmpty DataIntegrationSummary)
a -> ListDataIntegrationsResponse
s {$sel:dataIntegrations:ListDataIntegrationsResponse' :: Maybe (NonEmpty DataIntegrationSummary)
dataIntegrations = Maybe (NonEmpty DataIntegrationSummary)
a} :: ListDataIntegrationsResponse) 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 there are additional results, this is the token for the next set of
-- results.
listDataIntegrationsResponse_nextToken :: Lens.Lens' ListDataIntegrationsResponse (Prelude.Maybe Prelude.Text)
listDataIntegrationsResponse_nextToken :: Lens' ListDataIntegrationsResponse (Maybe Text)
listDataIntegrationsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDataIntegrationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDataIntegrationsResponse' :: ListDataIntegrationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDataIntegrationsResponse
s@ListDataIntegrationsResponse' {} Maybe Text
a -> ListDataIntegrationsResponse
s {$sel:nextToken:ListDataIntegrationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDataIntegrationsResponse)

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

instance Prelude.NFData ListDataIntegrationsResponse where
  rnf :: ListDataIntegrationsResponse -> ()
rnf ListDataIntegrationsResponse' {Int
Maybe (NonEmpty DataIntegrationSummary)
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
dataIntegrations :: Maybe (NonEmpty DataIntegrationSummary)
$sel:httpStatus:ListDataIntegrationsResponse' :: ListDataIntegrationsResponse -> Int
$sel:nextToken:ListDataIntegrationsResponse' :: ListDataIntegrationsResponse -> Maybe Text
$sel:dataIntegrations:ListDataIntegrationsResponse' :: ListDataIntegrationsResponse
-> Maybe (NonEmpty DataIntegrationSummary)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty DataIntegrationSummary)
dataIntegrations
      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