{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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_indexStatus,
    describeIndexResponse_schema,
    describeIndexResponse_indexName,
    describeIndexResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
import qualified Amazonka.Lens as Lens
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
(DescribeIndex -> DescribeIndex -> Bool)
-> (DescribeIndex -> DescribeIndex -> Bool) -> Eq DescribeIndex
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]
(Int -> ReadS DescribeIndex)
-> ReadS [DescribeIndex]
-> ReadPrec DescribeIndex
-> ReadPrec [DescribeIndex]
-> Read 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
(Int -> DescribeIndex -> ShowS)
-> (DescribeIndex -> String)
-> ([DescribeIndex] -> ShowS)
-> Show DescribeIndex
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. DescribeIndex -> Rep DescribeIndex x)
-> (forall x. Rep DescribeIndex x -> DescribeIndex)
-> Generic DescribeIndex
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' :: Text -> DescribeIndex
DescribeIndex' {$sel:indexName:DescribeIndex' :: Text
indexName = Text
pIndexName_}

-- | The index name.
describeIndex_indexName :: Lens.Lens' DescribeIndex Prelude.Text
describeIndex_indexName :: (Text -> f Text) -> DescribeIndex -> f DescribeIndex
describeIndex_indexName = (DescribeIndex -> Text)
-> (DescribeIndex -> Text -> DescribeIndex)
-> Lens DescribeIndex DescribeIndex Text Text
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 :: DescribeIndex -> Request DescribeIndex
request = Service -> DescribeIndex -> Request DescribeIndex
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeIndex
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeIndex)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeIndex))
-> Logger
-> Service
-> Proxy DescribeIndex
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeIndex)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe IndexStatus
-> Maybe Text -> Maybe Text -> Int -> DescribeIndexResponse
DescribeIndexResponse'
            (Maybe IndexStatus
 -> Maybe Text -> Maybe Text -> Int -> DescribeIndexResponse)
-> Either String (Maybe IndexStatus)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> DescribeIndexResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe IndexStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"indexStatus")
            Either
  String (Maybe Text -> Maybe Text -> Int -> DescribeIndexResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> DescribeIndexResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"schema")
            Either String (Maybe Text -> Int -> DescribeIndexResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeIndexResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"indexName")
            Either String (Int -> DescribeIndexResponse)
-> Either String Int -> Either String DescribeIndexResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeIndex

instance Prelude.NFData DescribeIndex

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

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

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

-- | /See:/ 'newDescribeIndexResponse' smart constructor.
data DescribeIndexResponse = DescribeIndexResponse'
  { -- | 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.
    DescribeIndexResponse -> Maybe Text
schema :: Prelude.Maybe Prelude.Text,
    -- | The index name.
    DescribeIndexResponse -> Maybe Text
indexName :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeIndexResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeIndexResponse -> DescribeIndexResponse -> Bool
(DescribeIndexResponse -> DescribeIndexResponse -> Bool)
-> (DescribeIndexResponse -> DescribeIndexResponse -> Bool)
-> Eq DescribeIndexResponse
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]
(Int -> ReadS DescribeIndexResponse)
-> ReadS [DescribeIndexResponse]
-> ReadPrec DescribeIndexResponse
-> ReadPrec [DescribeIndexResponse]
-> Read 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
(Int -> DescribeIndexResponse -> ShowS)
-> (DescribeIndexResponse -> String)
-> ([DescribeIndexResponse] -> ShowS)
-> Show DescribeIndexResponse
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. DescribeIndexResponse -> Rep DescribeIndexResponse x)
-> (forall x. Rep DescribeIndexResponse x -> DescribeIndexResponse)
-> Generic DescribeIndexResponse
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:
--
-- '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.
--
-- 'indexName', 'describeIndexResponse_indexName' - The index name.
--
-- 'httpStatus', 'describeIndexResponse_httpStatus' - The response's http status code.
newDescribeIndexResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeIndexResponse
newDescribeIndexResponse :: Int -> DescribeIndexResponse
newDescribeIndexResponse Int
pHttpStatus_ =
  DescribeIndexResponse' :: Maybe IndexStatus
-> Maybe Text -> Maybe Text -> Int -> DescribeIndexResponse
DescribeIndexResponse'
    { $sel:indexStatus:DescribeIndexResponse' :: Maybe IndexStatus
indexStatus =
        Maybe IndexStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:schema:DescribeIndexResponse' :: Maybe Text
schema = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:indexName:DescribeIndexResponse' :: Maybe Text
indexName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeIndexResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The index status.
describeIndexResponse_indexStatus :: Lens.Lens' DescribeIndexResponse (Prelude.Maybe IndexStatus)
describeIndexResponse_indexStatus :: (Maybe IndexStatus -> f (Maybe IndexStatus))
-> DescribeIndexResponse -> f DescribeIndexResponse
describeIndexResponse_indexStatus = (DescribeIndexResponse -> Maybe IndexStatus)
-> (DescribeIndexResponse
    -> Maybe IndexStatus -> DescribeIndexResponse)
-> Lens
     DescribeIndexResponse
     DescribeIndexResponse
     (Maybe IndexStatus)
     (Maybe 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.
describeIndexResponse_schema :: Lens.Lens' DescribeIndexResponse (Prelude.Maybe Prelude.Text)
describeIndexResponse_schema :: (Maybe Text -> f (Maybe Text))
-> DescribeIndexResponse -> f DescribeIndexResponse
describeIndexResponse_schema = (DescribeIndexResponse -> Maybe Text)
-> (DescribeIndexResponse -> Maybe Text -> DescribeIndexResponse)
-> Lens
     DescribeIndexResponse
     DescribeIndexResponse
     (Maybe Text)
     (Maybe Text)
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 index name.
describeIndexResponse_indexName :: Lens.Lens' DescribeIndexResponse (Prelude.Maybe Prelude.Text)
describeIndexResponse_indexName :: (Maybe Text -> f (Maybe Text))
-> DescribeIndexResponse -> f DescribeIndexResponse
describeIndexResponse_indexName = (DescribeIndexResponse -> Maybe Text)
-> (DescribeIndexResponse -> Maybe Text -> DescribeIndexResponse)
-> Lens
     DescribeIndexResponse
     DescribeIndexResponse
     (Maybe Text)
     (Maybe Text)
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 response's http status code.
describeIndexResponse_httpStatus :: Lens.Lens' DescribeIndexResponse Prelude.Int
describeIndexResponse_httpStatus :: (Int -> f Int) -> DescribeIndexResponse -> f DescribeIndexResponse
describeIndexResponse_httpStatus = (DescribeIndexResponse -> Int)
-> (DescribeIndexResponse -> Int -> DescribeIndexResponse)
-> Lens DescribeIndexResponse DescribeIndexResponse Int Int
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