{-# 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.Kendra.ListIndices
-- 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 Amazon Kendra indexes that you created.
module Amazonka.Kendra.ListIndices
  ( -- * Creating a Request
    ListIndices (..),
    newListIndices,

    -- * Request Lenses
    listIndices_maxResults,
    listIndices_nextToken,

    -- * Destructuring the Response
    ListIndicesResponse (..),
    newListIndicesResponse,

    -- * Response Lenses
    listIndicesResponse_indexConfigurationSummaryItems,
    listIndicesResponse_nextToken,
    listIndicesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListIndices' smart constructor.
data ListIndices = ListIndices'
  { -- | The maximum number of indices to return.
    ListIndices -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | If the previous response was incomplete (because there is more data to
    -- retrieve), Amazon Kendra returns a pagination token in the response. You
    -- can use this pagination token to retrieve the next set of indexes.
    ListIndices -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListIndices -> ListIndices -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIndices -> ListIndices -> Bool
$c/= :: ListIndices -> ListIndices -> Bool
== :: ListIndices -> ListIndices -> Bool
$c== :: ListIndices -> ListIndices -> Bool
Prelude.Eq, ReadPrec [ListIndices]
ReadPrec ListIndices
Int -> ReadS ListIndices
ReadS [ListIndices]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListIndices]
$creadListPrec :: ReadPrec [ListIndices]
readPrec :: ReadPrec ListIndices
$creadPrec :: ReadPrec ListIndices
readList :: ReadS [ListIndices]
$creadList :: ReadS [ListIndices]
readsPrec :: Int -> ReadS ListIndices
$creadsPrec :: Int -> ReadS ListIndices
Prelude.Read, Int -> ListIndices -> ShowS
[ListIndices] -> ShowS
ListIndices -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIndices] -> ShowS
$cshowList :: [ListIndices] -> ShowS
show :: ListIndices -> String
$cshow :: ListIndices -> String
showsPrec :: Int -> ListIndices -> ShowS
$cshowsPrec :: Int -> ListIndices -> ShowS
Prelude.Show, forall x. Rep ListIndices x -> ListIndices
forall x. ListIndices -> Rep ListIndices x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListIndices x -> ListIndices
$cfrom :: forall x. ListIndices -> Rep ListIndices x
Prelude.Generic)

-- |
-- Create a value of 'ListIndices' 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', 'listIndices_maxResults' - The maximum number of indices to return.
--
-- 'nextToken', 'listIndices_nextToken' - If the previous response was incomplete (because there is more data to
-- retrieve), Amazon Kendra returns a pagination token in the response. You
-- can use this pagination token to retrieve the next set of indexes.
newListIndices ::
  ListIndices
newListIndices :: ListIndices
newListIndices =
  ListIndices'
    { $sel:maxResults:ListIndices' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListIndices' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

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

-- | If the previous response was incomplete (because there is more data to
-- retrieve), Amazon Kendra returns a pagination token in the response. You
-- can use this pagination token to retrieve the next set of indexes.
listIndices_nextToken :: Lens.Lens' ListIndices (Prelude.Maybe Prelude.Text)
listIndices_nextToken :: Lens' ListIndices (Maybe Text)
listIndices_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIndices' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListIndices' :: ListIndices -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListIndices
s@ListIndices' {} Maybe Text
a -> ListIndices
s {$sel:nextToken:ListIndices' :: Maybe Text
nextToken = Maybe Text
a} :: ListIndices)

instance Core.AWSRequest ListIndices where
  type AWSResponse ListIndices = ListIndicesResponse
  request :: (Service -> Service) -> ListIndices -> Request ListIndices
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 ListIndices
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListIndices)))
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 [IndexConfigurationSummary]
-> Maybe Text -> Int -> ListIndicesResponse
ListIndicesResponse'
            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
"IndexConfigurationSummaryItems"
                            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 ListIndices where
  hashWithSalt :: Int -> ListIndices -> Int
hashWithSalt Int
_salt ListIndices' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListIndices' :: ListIndices -> Maybe Text
$sel:maxResults:ListIndices' :: ListIndices -> 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 ListIndices where
  rnf :: ListIndices -> ()
rnf ListIndices' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListIndices' :: ListIndices -> Maybe Text
$sel:maxResults:ListIndices' :: ListIndices -> 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 ListIndices where
  toHeaders :: ListIndices -> 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
"AWSKendraFrontendService.ListIndices" ::
                          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 ListIndices where
  toJSON :: ListIndices -> Value
toJSON ListIndices' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListIndices' :: ListIndices -> Maybe Text
$sel:maxResults:ListIndices' :: ListIndices -> 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 ListIndices where
  toPath :: ListIndices -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListIndicesResponse' smart constructor.
data ListIndicesResponse = ListIndicesResponse'
  { -- | An array of summary information on the configuration of one or more
    -- indexes.
    ListIndicesResponse -> Maybe [IndexConfigurationSummary]
indexConfigurationSummaryItems :: Prelude.Maybe [IndexConfigurationSummary],
    -- | If the response is truncated, Amazon Kendra returns this token that you
    -- can use in the subsequent request to retrieve the next set of indexes.
    ListIndicesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListIndicesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListIndicesResponse -> ListIndicesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIndicesResponse -> ListIndicesResponse -> Bool
$c/= :: ListIndicesResponse -> ListIndicesResponse -> Bool
== :: ListIndicesResponse -> ListIndicesResponse -> Bool
$c== :: ListIndicesResponse -> ListIndicesResponse -> Bool
Prelude.Eq, ReadPrec [ListIndicesResponse]
ReadPrec ListIndicesResponse
Int -> ReadS ListIndicesResponse
ReadS [ListIndicesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListIndicesResponse]
$creadListPrec :: ReadPrec [ListIndicesResponse]
readPrec :: ReadPrec ListIndicesResponse
$creadPrec :: ReadPrec ListIndicesResponse
readList :: ReadS [ListIndicesResponse]
$creadList :: ReadS [ListIndicesResponse]
readsPrec :: Int -> ReadS ListIndicesResponse
$creadsPrec :: Int -> ReadS ListIndicesResponse
Prelude.Read, Int -> ListIndicesResponse -> ShowS
[ListIndicesResponse] -> ShowS
ListIndicesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIndicesResponse] -> ShowS
$cshowList :: [ListIndicesResponse] -> ShowS
show :: ListIndicesResponse -> String
$cshow :: ListIndicesResponse -> String
showsPrec :: Int -> ListIndicesResponse -> ShowS
$cshowsPrec :: Int -> ListIndicesResponse -> ShowS
Prelude.Show, forall x. Rep ListIndicesResponse x -> ListIndicesResponse
forall x. ListIndicesResponse -> Rep ListIndicesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListIndicesResponse x -> ListIndicesResponse
$cfrom :: forall x. ListIndicesResponse -> Rep ListIndicesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListIndicesResponse' 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:
--
-- 'indexConfigurationSummaryItems', 'listIndicesResponse_indexConfigurationSummaryItems' - An array of summary information on the configuration of one or more
-- indexes.
--
-- 'nextToken', 'listIndicesResponse_nextToken' - If the response is truncated, Amazon Kendra returns this token that you
-- can use in the subsequent request to retrieve the next set of indexes.
--
-- 'httpStatus', 'listIndicesResponse_httpStatus' - The response's http status code.
newListIndicesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListIndicesResponse
newListIndicesResponse :: Int -> ListIndicesResponse
newListIndicesResponse Int
pHttpStatus_ =
  ListIndicesResponse'
    { $sel:indexConfigurationSummaryItems:ListIndicesResponse' :: Maybe [IndexConfigurationSummary]
indexConfigurationSummaryItems =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListIndicesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListIndicesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of summary information on the configuration of one or more
-- indexes.
listIndicesResponse_indexConfigurationSummaryItems :: Lens.Lens' ListIndicesResponse (Prelude.Maybe [IndexConfigurationSummary])
listIndicesResponse_indexConfigurationSummaryItems :: Lens' ListIndicesResponse (Maybe [IndexConfigurationSummary])
listIndicesResponse_indexConfigurationSummaryItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIndicesResponse' {Maybe [IndexConfigurationSummary]
indexConfigurationSummaryItems :: Maybe [IndexConfigurationSummary]
$sel:indexConfigurationSummaryItems:ListIndicesResponse' :: ListIndicesResponse -> Maybe [IndexConfigurationSummary]
indexConfigurationSummaryItems} -> Maybe [IndexConfigurationSummary]
indexConfigurationSummaryItems) (\s :: ListIndicesResponse
s@ListIndicesResponse' {} Maybe [IndexConfigurationSummary]
a -> ListIndicesResponse
s {$sel:indexConfigurationSummaryItems:ListIndicesResponse' :: Maybe [IndexConfigurationSummary]
indexConfigurationSummaryItems = Maybe [IndexConfigurationSummary]
a} :: ListIndicesResponse) 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 the response is truncated, Amazon Kendra returns this token that you
-- can use in the subsequent request to retrieve the next set of indexes.
listIndicesResponse_nextToken :: Lens.Lens' ListIndicesResponse (Prelude.Maybe Prelude.Text)
listIndicesResponse_nextToken :: Lens' ListIndicesResponse (Maybe Text)
listIndicesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIndicesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListIndicesResponse' :: ListIndicesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListIndicesResponse
s@ListIndicesResponse' {} Maybe Text
a -> ListIndicesResponse
s {$sel:nextToken:ListIndicesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListIndicesResponse)

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

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