{-# 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.IoT.DescribeIndex
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes a search index.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DescribeIndex>
-- action.
module Amazonka.IoT.DescribeIndex
  ( -- * Creating a Request
    DescribeIndex (..),
    newDescribeIndex,

    -- * Request Lenses
    describeIndex_indexName,

    -- * Destructuring the Response
    DescribeIndexResponse (..),
    newDescribeIndexResponse,

    -- * Response Lenses
    describeIndexResponse_indexName,
    describeIndexResponse_indexStatus,
    describeIndexResponse_schema,
    describeIndexResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeIndex' smart constructor.
data DescribeIndex = DescribeIndex'
  { -- | The index name.
    DescribeIndex -> Text
indexName :: Prelude.Text
  }
  deriving (DescribeIndex -> DescribeIndex -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeIndex -> DescribeIndex -> Bool
$c/= :: DescribeIndex -> DescribeIndex -> Bool
== :: DescribeIndex -> DescribeIndex -> Bool
$c== :: DescribeIndex -> DescribeIndex -> Bool
Prelude.Eq, ReadPrec [DescribeIndex]
ReadPrec DescribeIndex
Int -> ReadS DescribeIndex
ReadS [DescribeIndex]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeIndex]
$creadListPrec :: ReadPrec [DescribeIndex]
readPrec :: ReadPrec DescribeIndex
$creadPrec :: ReadPrec DescribeIndex
readList :: ReadS [DescribeIndex]
$creadList :: ReadS [DescribeIndex]
readsPrec :: Int -> ReadS DescribeIndex
$creadsPrec :: Int -> ReadS DescribeIndex
Prelude.Read, Int -> DescribeIndex -> ShowS
[DescribeIndex] -> ShowS
DescribeIndex -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeIndex] -> ShowS
$cshowList :: [DescribeIndex] -> ShowS
show :: DescribeIndex -> String
$cshow :: DescribeIndex -> String
showsPrec :: Int -> DescribeIndex -> ShowS
$cshowsPrec :: Int -> DescribeIndex -> ShowS
Prelude.Show, forall x. Rep DescribeIndex x -> DescribeIndex
forall x. DescribeIndex -> Rep DescribeIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeIndex x -> DescribeIndex
$cfrom :: forall x. DescribeIndex -> Rep DescribeIndex x
Prelude.Generic)

-- |
-- Create a value of 'DescribeIndex' 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:
--
-- 'indexName', 'describeIndex_indexName' - The index name.
newDescribeIndex ::
  -- | 'indexName'
  Prelude.Text ->
  DescribeIndex
newDescribeIndex :: Text -> DescribeIndex
newDescribeIndex Text
pIndexName_ =
  DescribeIndex' {$sel:indexName:DescribeIndex' :: Text
indexName = Text
pIndexName_}

-- | The index name.
describeIndex_indexName :: Lens.Lens' DescribeIndex Prelude.Text
describeIndex_indexName :: Lens' DescribeIndex Text
describeIndex_indexName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIndex' {Text
indexName :: Text
$sel:indexName:DescribeIndex' :: DescribeIndex -> Text
indexName} -> Text
indexName) (\s :: DescribeIndex
s@DescribeIndex' {} Text
a -> DescribeIndex
s {$sel:indexName:DescribeIndex' :: Text
indexName = Text
a} :: DescribeIndex)

instance Core.AWSRequest DescribeIndex where
  type
    AWSResponse DescribeIndex =
      DescribeIndexResponse
  request :: (Service -> Service) -> DescribeIndex -> Request DescribeIndex
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 DescribeIndex
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeIndex)))
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
-> Maybe IndexStatus -> Maybe Text -> Int -> DescribeIndexResponse
DescribeIndexResponse'
            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
"indexName")
            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
"indexStatus")
            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
"schema")
            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 DescribeIndex where
  hashWithSalt :: Int -> DescribeIndex -> Int
hashWithSalt Int
_salt DescribeIndex' {Text
indexName :: Text
$sel:indexName:DescribeIndex' :: DescribeIndex -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
indexName

instance Prelude.NFData DescribeIndex where
  rnf :: DescribeIndex -> ()
rnf DescribeIndex' {Text
indexName :: Text
$sel:indexName:DescribeIndex' :: DescribeIndex -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
indexName

instance Data.ToHeaders DescribeIndex where
  toHeaders :: DescribeIndex -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath DescribeIndex where
  toPath :: DescribeIndex -> ByteString
toPath DescribeIndex' {Text
indexName :: Text
$sel:indexName:DescribeIndex' :: DescribeIndex -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/indices/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
indexName]

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

-- | /See:/ 'newDescribeIndexResponse' smart constructor.
data DescribeIndexResponse = DescribeIndexResponse'
  { -- | The index name.
    DescribeIndexResponse -> Maybe Text
indexName :: Prelude.Maybe Prelude.Text,
    -- | The index status.
    DescribeIndexResponse -> Maybe IndexStatus
indexStatus :: Prelude.Maybe IndexStatus,
    -- | Contains a value that specifies the type of indexing performed. Valid
    -- values are:
    --
    -- -   REGISTRY – Your thing index contains only registry data.
    --
    -- -   REGISTRY_AND_SHADOW - Your thing index contains registry data and
    --     shadow data.
    --
    -- -   REGISTRY_AND_CONNECTIVITY_STATUS - Your thing index contains
    --     registry data and thing connectivity status data.
    --
    -- -   REGISTRY_AND_SHADOW_AND_CONNECTIVITY_STATUS - Your thing index
    --     contains registry data, shadow data, and thing connectivity status
    --     data.
    --
    -- -   MULTI_INDEXING_MODE - Your thing index contains multiple data
    --     sources. For more information, see
    --     <https://docs.aws.amazon.com/iot/latest/apireference/API_GetIndexingConfiguration.html GetIndexingConfiguration>.
    DescribeIndexResponse -> Maybe Text
schema :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeIndexResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeIndexResponse -> DescribeIndexResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeIndexResponse -> DescribeIndexResponse -> Bool
$c/= :: DescribeIndexResponse -> DescribeIndexResponse -> Bool
== :: DescribeIndexResponse -> DescribeIndexResponse -> Bool
$c== :: DescribeIndexResponse -> DescribeIndexResponse -> Bool
Prelude.Eq, ReadPrec [DescribeIndexResponse]
ReadPrec DescribeIndexResponse
Int -> ReadS DescribeIndexResponse
ReadS [DescribeIndexResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeIndexResponse]
$creadListPrec :: ReadPrec [DescribeIndexResponse]
readPrec :: ReadPrec DescribeIndexResponse
$creadPrec :: ReadPrec DescribeIndexResponse
readList :: ReadS [DescribeIndexResponse]
$creadList :: ReadS [DescribeIndexResponse]
readsPrec :: Int -> ReadS DescribeIndexResponse
$creadsPrec :: Int -> ReadS DescribeIndexResponse
Prelude.Read, Int -> DescribeIndexResponse -> ShowS
[DescribeIndexResponse] -> ShowS
DescribeIndexResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeIndexResponse] -> ShowS
$cshowList :: [DescribeIndexResponse] -> ShowS
show :: DescribeIndexResponse -> String
$cshow :: DescribeIndexResponse -> String
showsPrec :: Int -> DescribeIndexResponse -> ShowS
$cshowsPrec :: Int -> DescribeIndexResponse -> ShowS
Prelude.Show, forall x. Rep DescribeIndexResponse x -> DescribeIndexResponse
forall x. DescribeIndexResponse -> Rep DescribeIndexResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeIndexResponse x -> DescribeIndexResponse
$cfrom :: forall x. DescribeIndexResponse -> Rep DescribeIndexResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeIndexResponse' 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:
--
-- 'indexName', 'describeIndexResponse_indexName' - The index name.
--
-- 'indexStatus', 'describeIndexResponse_indexStatus' - The index status.
--
-- 'schema', 'describeIndexResponse_schema' - Contains a value that specifies the type of indexing performed. Valid
-- values are:
--
-- -   REGISTRY – Your thing index contains only registry data.
--
-- -   REGISTRY_AND_SHADOW - Your thing index contains registry data and
--     shadow data.
--
-- -   REGISTRY_AND_CONNECTIVITY_STATUS - Your thing index contains
--     registry data and thing connectivity status data.
--
-- -   REGISTRY_AND_SHADOW_AND_CONNECTIVITY_STATUS - Your thing index
--     contains registry data, shadow data, and thing connectivity status
--     data.
--
-- -   MULTI_INDEXING_MODE - Your thing index contains multiple data
--     sources. For more information, see
--     <https://docs.aws.amazon.com/iot/latest/apireference/API_GetIndexingConfiguration.html GetIndexingConfiguration>.
--
-- 'httpStatus', 'describeIndexResponse_httpStatus' - The response's http status code.
newDescribeIndexResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeIndexResponse
newDescribeIndexResponse :: Int -> DescribeIndexResponse
newDescribeIndexResponse Int
pHttpStatus_ =
  DescribeIndexResponse'
    { $sel:indexName:DescribeIndexResponse' :: Maybe Text
indexName = forall a. Maybe a
Prelude.Nothing,
      $sel:indexStatus:DescribeIndexResponse' :: Maybe IndexStatus
indexStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:schema:DescribeIndexResponse' :: Maybe Text
schema = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeIndexResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The index name.
describeIndexResponse_indexName :: Lens.Lens' DescribeIndexResponse (Prelude.Maybe Prelude.Text)
describeIndexResponse_indexName :: Lens' DescribeIndexResponse (Maybe Text)
describeIndexResponse_indexName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIndexResponse' {Maybe Text
indexName :: Maybe Text
$sel:indexName:DescribeIndexResponse' :: DescribeIndexResponse -> Maybe Text
indexName} -> Maybe Text
indexName) (\s :: DescribeIndexResponse
s@DescribeIndexResponse' {} Maybe Text
a -> DescribeIndexResponse
s {$sel:indexName:DescribeIndexResponse' :: Maybe Text
indexName = Maybe Text
a} :: DescribeIndexResponse)

-- | The index status.
describeIndexResponse_indexStatus :: Lens.Lens' DescribeIndexResponse (Prelude.Maybe IndexStatus)
describeIndexResponse_indexStatus :: Lens' DescribeIndexResponse (Maybe IndexStatus)
describeIndexResponse_indexStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIndexResponse' {Maybe IndexStatus
indexStatus :: Maybe IndexStatus
$sel:indexStatus:DescribeIndexResponse' :: DescribeIndexResponse -> Maybe IndexStatus
indexStatus} -> Maybe IndexStatus
indexStatus) (\s :: DescribeIndexResponse
s@DescribeIndexResponse' {} Maybe IndexStatus
a -> DescribeIndexResponse
s {$sel:indexStatus:DescribeIndexResponse' :: Maybe IndexStatus
indexStatus = Maybe IndexStatus
a} :: DescribeIndexResponse)

-- | Contains a value that specifies the type of indexing performed. Valid
-- values are:
--
-- -   REGISTRY – Your thing index contains only registry data.
--
-- -   REGISTRY_AND_SHADOW - Your thing index contains registry data and
--     shadow data.
--
-- -   REGISTRY_AND_CONNECTIVITY_STATUS - Your thing index contains
--     registry data and thing connectivity status data.
--
-- -   REGISTRY_AND_SHADOW_AND_CONNECTIVITY_STATUS - Your thing index
--     contains registry data, shadow data, and thing connectivity status
--     data.
--
-- -   MULTI_INDEXING_MODE - Your thing index contains multiple data
--     sources. For more information, see
--     <https://docs.aws.amazon.com/iot/latest/apireference/API_GetIndexingConfiguration.html GetIndexingConfiguration>.
describeIndexResponse_schema :: Lens.Lens' DescribeIndexResponse (Prelude.Maybe Prelude.Text)
describeIndexResponse_schema :: Lens' DescribeIndexResponse (Maybe Text)
describeIndexResponse_schema = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIndexResponse' {Maybe Text
schema :: Maybe Text
$sel:schema:DescribeIndexResponse' :: DescribeIndexResponse -> Maybe Text
schema} -> Maybe Text
schema) (\s :: DescribeIndexResponse
s@DescribeIndexResponse' {} Maybe Text
a -> DescribeIndexResponse
s {$sel:schema:DescribeIndexResponse' :: Maybe Text
schema = Maybe Text
a} :: DescribeIndexResponse)

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

instance Prelude.NFData DescribeIndexResponse where
  rnf :: DescribeIndexResponse -> ()
rnf DescribeIndexResponse' {Int
Maybe Text
Maybe IndexStatus
httpStatus :: Int
schema :: Maybe Text
indexStatus :: Maybe IndexStatus
indexName :: Maybe Text
$sel:httpStatus:DescribeIndexResponse' :: DescribeIndexResponse -> Int
$sel:schema:DescribeIndexResponse' :: DescribeIndexResponse -> Maybe Text
$sel:indexStatus:DescribeIndexResponse' :: DescribeIndexResponse -> Maybe IndexStatus
$sel:indexName:DescribeIndexResponse' :: DescribeIndexResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
indexName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IndexStatus
indexStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
schema
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus