{-# 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.IoTAnalytics.ListDatastores
-- 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 data stores.
--
-- This operation returns paginated results.
module Amazonka.IoTAnalytics.ListDatastores
  ( -- * Creating a Request
    ListDatastores (..),
    newListDatastores,

    -- * Request Lenses
    listDatastores_maxResults,
    listDatastores_nextToken,

    -- * Destructuring the Response
    ListDatastoresResponse (..),
    newListDatastoresResponse,

    -- * Response Lenses
    listDatastoresResponse_datastoreSummaries,
    listDatastoresResponse_nextToken,
    listDatastoresResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListDatastores' smart constructor.
data ListDatastores = ListDatastores'
  { -- | The maximum number of results to return in this request.
    --
    -- The default value is 100.
    ListDatastores -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token for the next set of results.
    ListDatastores -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListDatastores -> ListDatastores -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDatastores -> ListDatastores -> Bool
$c/= :: ListDatastores -> ListDatastores -> Bool
== :: ListDatastores -> ListDatastores -> Bool
$c== :: ListDatastores -> ListDatastores -> Bool
Prelude.Eq, ReadPrec [ListDatastores]
ReadPrec ListDatastores
Int -> ReadS ListDatastores
ReadS [ListDatastores]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDatastores]
$creadListPrec :: ReadPrec [ListDatastores]
readPrec :: ReadPrec ListDatastores
$creadPrec :: ReadPrec ListDatastores
readList :: ReadS [ListDatastores]
$creadList :: ReadS [ListDatastores]
readsPrec :: Int -> ReadS ListDatastores
$creadsPrec :: Int -> ReadS ListDatastores
Prelude.Read, Int -> ListDatastores -> ShowS
[ListDatastores] -> ShowS
ListDatastores -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDatastores] -> ShowS
$cshowList :: [ListDatastores] -> ShowS
show :: ListDatastores -> String
$cshow :: ListDatastores -> String
showsPrec :: Int -> ListDatastores -> ShowS
$cshowsPrec :: Int -> ListDatastores -> ShowS
Prelude.Show, forall x. Rep ListDatastores x -> ListDatastores
forall x. ListDatastores -> Rep ListDatastores x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDatastores x -> ListDatastores
$cfrom :: forall x. ListDatastores -> Rep ListDatastores x
Prelude.Generic)

-- |
-- Create a value of 'ListDatastores' 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', 'listDatastores_maxResults' - The maximum number of results to return in this request.
--
-- The default value is 100.
--
-- 'nextToken', 'listDatastores_nextToken' - The token for the next set of results.
newListDatastores ::
  ListDatastores
newListDatastores :: ListDatastores
newListDatastores =
  ListDatastores'
    { $sel:maxResults:ListDatastores' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDatastores' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to return in this request.
--
-- The default value is 100.
listDatastores_maxResults :: Lens.Lens' ListDatastores (Prelude.Maybe Prelude.Natural)
listDatastores_maxResults :: Lens' ListDatastores (Maybe Natural)
listDatastores_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatastores' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDatastores' :: ListDatastores -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDatastores
s@ListDatastores' {} Maybe Natural
a -> ListDatastores
s {$sel:maxResults:ListDatastores' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDatastores)

-- | The token for the next set of results.
listDatastores_nextToken :: Lens.Lens' ListDatastores (Prelude.Maybe Prelude.Text)
listDatastores_nextToken :: Lens' ListDatastores (Maybe Text)
listDatastores_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatastores' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDatastores' :: ListDatastores -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDatastores
s@ListDatastores' {} Maybe Text
a -> ListDatastores
s {$sel:nextToken:ListDatastores' :: Maybe Text
nextToken = Maybe Text
a} :: ListDatastores)

instance Core.AWSPager ListDatastores where
  page :: ListDatastores
-> AWSResponse ListDatastores -> Maybe ListDatastores
page ListDatastores
rq AWSResponse ListDatastores
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDatastores
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDatastoresResponse (Maybe Text)
listDatastoresResponse_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 ListDatastores
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDatastoresResponse (Maybe [DatastoreSummary])
listDatastoresResponse_datastoreSummaries
            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.$ ListDatastores
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListDatastores (Maybe Text)
listDatastores_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListDatastores
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListDatastoresResponse (Maybe Text)
listDatastoresResponse_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 ListDatastores where
  type
    AWSResponse ListDatastores =
      ListDatastoresResponse
  request :: (Service -> Service) -> ListDatastores -> Request ListDatastores
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 ListDatastores
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDatastores)))
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 [DatastoreSummary]
-> Maybe Text -> Int -> ListDatastoresResponse
ListDatastoresResponse'
            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
"datastoreSummaries"
                            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 ListDatastores where
  hashWithSalt :: Int -> ListDatastores -> Int
hashWithSalt Int
_salt ListDatastores' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDatastores' :: ListDatastores -> Maybe Text
$sel:maxResults:ListDatastores' :: ListDatastores -> 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 ListDatastores where
  rnf :: ListDatastores -> ()
rnf ListDatastores' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDatastores' :: ListDatastores -> Maybe Text
$sel:maxResults:ListDatastores' :: ListDatastores -> 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 ListDatastores where
  toHeaders :: ListDatastores -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery ListDatastores where
  toQuery :: ListDatastores -> QueryString
toQuery ListDatastores' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDatastores' :: ListDatastores -> Maybe Text
$sel:maxResults:ListDatastores' :: ListDatastores -> 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:/ 'newListDatastoresResponse' smart constructor.
data ListDatastoresResponse = ListDatastoresResponse'
  { -- | A list of @DatastoreSummary@ objects.
    ListDatastoresResponse -> Maybe [DatastoreSummary]
datastoreSummaries :: Prelude.Maybe [DatastoreSummary],
    -- | The token to retrieve the next set of results, or @null@ if there are no
    -- more results.
    ListDatastoresResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDatastoresResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDatastoresResponse -> ListDatastoresResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDatastoresResponse -> ListDatastoresResponse -> Bool
$c/= :: ListDatastoresResponse -> ListDatastoresResponse -> Bool
== :: ListDatastoresResponse -> ListDatastoresResponse -> Bool
$c== :: ListDatastoresResponse -> ListDatastoresResponse -> Bool
Prelude.Eq, ReadPrec [ListDatastoresResponse]
ReadPrec ListDatastoresResponse
Int -> ReadS ListDatastoresResponse
ReadS [ListDatastoresResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDatastoresResponse]
$creadListPrec :: ReadPrec [ListDatastoresResponse]
readPrec :: ReadPrec ListDatastoresResponse
$creadPrec :: ReadPrec ListDatastoresResponse
readList :: ReadS [ListDatastoresResponse]
$creadList :: ReadS [ListDatastoresResponse]
readsPrec :: Int -> ReadS ListDatastoresResponse
$creadsPrec :: Int -> ReadS ListDatastoresResponse
Prelude.Read, Int -> ListDatastoresResponse -> ShowS
[ListDatastoresResponse] -> ShowS
ListDatastoresResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDatastoresResponse] -> ShowS
$cshowList :: [ListDatastoresResponse] -> ShowS
show :: ListDatastoresResponse -> String
$cshow :: ListDatastoresResponse -> String
showsPrec :: Int -> ListDatastoresResponse -> ShowS
$cshowsPrec :: Int -> ListDatastoresResponse -> ShowS
Prelude.Show, forall x. Rep ListDatastoresResponse x -> ListDatastoresResponse
forall x. ListDatastoresResponse -> Rep ListDatastoresResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDatastoresResponse x -> ListDatastoresResponse
$cfrom :: forall x. ListDatastoresResponse -> Rep ListDatastoresResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDatastoresResponse' 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:
--
-- 'datastoreSummaries', 'listDatastoresResponse_datastoreSummaries' - A list of @DatastoreSummary@ objects.
--
-- 'nextToken', 'listDatastoresResponse_nextToken' - The token to retrieve the next set of results, or @null@ if there are no
-- more results.
--
-- 'httpStatus', 'listDatastoresResponse_httpStatus' - The response's http status code.
newListDatastoresResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDatastoresResponse
newListDatastoresResponse :: Int -> ListDatastoresResponse
newListDatastoresResponse Int
pHttpStatus_ =
  ListDatastoresResponse'
    { $sel:datastoreSummaries:ListDatastoresResponse' :: Maybe [DatastoreSummary]
datastoreSummaries =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDatastoresResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDatastoresResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of @DatastoreSummary@ objects.
listDatastoresResponse_datastoreSummaries :: Lens.Lens' ListDatastoresResponse (Prelude.Maybe [DatastoreSummary])
listDatastoresResponse_datastoreSummaries :: Lens' ListDatastoresResponse (Maybe [DatastoreSummary])
listDatastoresResponse_datastoreSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatastoresResponse' {Maybe [DatastoreSummary]
datastoreSummaries :: Maybe [DatastoreSummary]
$sel:datastoreSummaries:ListDatastoresResponse' :: ListDatastoresResponse -> Maybe [DatastoreSummary]
datastoreSummaries} -> Maybe [DatastoreSummary]
datastoreSummaries) (\s :: ListDatastoresResponse
s@ListDatastoresResponse' {} Maybe [DatastoreSummary]
a -> ListDatastoresResponse
s {$sel:datastoreSummaries:ListDatastoresResponse' :: Maybe [DatastoreSummary]
datastoreSummaries = Maybe [DatastoreSummary]
a} :: ListDatastoresResponse) 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 to retrieve the next set of results, or @null@ if there are no
-- more results.
listDatastoresResponse_nextToken :: Lens.Lens' ListDatastoresResponse (Prelude.Maybe Prelude.Text)
listDatastoresResponse_nextToken :: Lens' ListDatastoresResponse (Maybe Text)
listDatastoresResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDatastoresResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDatastoresResponse' :: ListDatastoresResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDatastoresResponse
s@ListDatastoresResponse' {} Maybe Text
a -> ListDatastoresResponse
s {$sel:nextToken:ListDatastoresResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDatastoresResponse)

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

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