{-# 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.IoTEventsData.DescribeDetector
-- 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)
--
-- Returns information about the specified detector (instance).
module Amazonka.IoTEventsData.DescribeDetector
  ( -- * Creating a Request
    DescribeDetector (..),
    newDescribeDetector,

    -- * Request Lenses
    describeDetector_keyValue,
    describeDetector_detectorModelName,

    -- * Destructuring the Response
    DescribeDetectorResponse (..),
    newDescribeDetectorResponse,

    -- * Response Lenses
    describeDetectorResponse_detector,
    describeDetectorResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTEventsData.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:/ 'newDescribeDetector' smart constructor.
data DescribeDetector = DescribeDetector'
  { -- | A filter used to limit results to detectors (instances) created because
    -- of the given key ID.
    DescribeDetector -> Maybe Text
keyValue :: Prelude.Maybe Prelude.Text,
    -- | The name of the detector model whose detectors (instances) you want
    -- information about.
    DescribeDetector -> Text
detectorModelName :: Prelude.Text
  }
  deriving (DescribeDetector -> DescribeDetector -> Bool
(DescribeDetector -> DescribeDetector -> Bool)
-> (DescribeDetector -> DescribeDetector -> Bool)
-> Eq DescribeDetector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDetector -> DescribeDetector -> Bool
$c/= :: DescribeDetector -> DescribeDetector -> Bool
== :: DescribeDetector -> DescribeDetector -> Bool
$c== :: DescribeDetector -> DescribeDetector -> Bool
Prelude.Eq, ReadPrec [DescribeDetector]
ReadPrec DescribeDetector
Int -> ReadS DescribeDetector
ReadS [DescribeDetector]
(Int -> ReadS DescribeDetector)
-> ReadS [DescribeDetector]
-> ReadPrec DescribeDetector
-> ReadPrec [DescribeDetector]
-> Read DescribeDetector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDetector]
$creadListPrec :: ReadPrec [DescribeDetector]
readPrec :: ReadPrec DescribeDetector
$creadPrec :: ReadPrec DescribeDetector
readList :: ReadS [DescribeDetector]
$creadList :: ReadS [DescribeDetector]
readsPrec :: Int -> ReadS DescribeDetector
$creadsPrec :: Int -> ReadS DescribeDetector
Prelude.Read, Int -> DescribeDetector -> ShowS
[DescribeDetector] -> ShowS
DescribeDetector -> String
(Int -> DescribeDetector -> ShowS)
-> (DescribeDetector -> String)
-> ([DescribeDetector] -> ShowS)
-> Show DescribeDetector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDetector] -> ShowS
$cshowList :: [DescribeDetector] -> ShowS
show :: DescribeDetector -> String
$cshow :: DescribeDetector -> String
showsPrec :: Int -> DescribeDetector -> ShowS
$cshowsPrec :: Int -> DescribeDetector -> ShowS
Prelude.Show, (forall x. DescribeDetector -> Rep DescribeDetector x)
-> (forall x. Rep DescribeDetector x -> DescribeDetector)
-> Generic DescribeDetector
forall x. Rep DescribeDetector x -> DescribeDetector
forall x. DescribeDetector -> Rep DescribeDetector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeDetector x -> DescribeDetector
$cfrom :: forall x. DescribeDetector -> Rep DescribeDetector x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDetector' 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:
--
-- 'keyValue', 'describeDetector_keyValue' - A filter used to limit results to detectors (instances) created because
-- of the given key ID.
--
-- 'detectorModelName', 'describeDetector_detectorModelName' - The name of the detector model whose detectors (instances) you want
-- information about.
newDescribeDetector ::
  -- | 'detectorModelName'
  Prelude.Text ->
  DescribeDetector
newDescribeDetector :: Text -> DescribeDetector
newDescribeDetector Text
pDetectorModelName_ =
  DescribeDetector' :: Maybe Text -> Text -> DescribeDetector
DescribeDetector'
    { $sel:keyValue:DescribeDetector' :: Maybe Text
keyValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorModelName:DescribeDetector' :: Text
detectorModelName = Text
pDetectorModelName_
    }

-- | A filter used to limit results to detectors (instances) created because
-- of the given key ID.
describeDetector_keyValue :: Lens.Lens' DescribeDetector (Prelude.Maybe Prelude.Text)
describeDetector_keyValue :: (Maybe Text -> f (Maybe Text))
-> DescribeDetector -> f DescribeDetector
describeDetector_keyValue = (DescribeDetector -> Maybe Text)
-> (DescribeDetector -> Maybe Text -> DescribeDetector)
-> Lens DescribeDetector DescribeDetector (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDetector' {Maybe Text
keyValue :: Maybe Text
$sel:keyValue:DescribeDetector' :: DescribeDetector -> Maybe Text
keyValue} -> Maybe Text
keyValue) (\s :: DescribeDetector
s@DescribeDetector' {} Maybe Text
a -> DescribeDetector
s {$sel:keyValue:DescribeDetector' :: Maybe Text
keyValue = Maybe Text
a} :: DescribeDetector)

-- | The name of the detector model whose detectors (instances) you want
-- information about.
describeDetector_detectorModelName :: Lens.Lens' DescribeDetector Prelude.Text
describeDetector_detectorModelName :: (Text -> f Text) -> DescribeDetector -> f DescribeDetector
describeDetector_detectorModelName = (DescribeDetector -> Text)
-> (DescribeDetector -> Text -> DescribeDetector)
-> Lens DescribeDetector DescribeDetector Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDetector' {Text
detectorModelName :: Text
$sel:detectorModelName:DescribeDetector' :: DescribeDetector -> Text
detectorModelName} -> Text
detectorModelName) (\s :: DescribeDetector
s@DescribeDetector' {} Text
a -> DescribeDetector
s {$sel:detectorModelName:DescribeDetector' :: Text
detectorModelName = Text
a} :: DescribeDetector)

instance Core.AWSRequest DescribeDetector where
  type
    AWSResponse DescribeDetector =
      DescribeDetectorResponse
  request :: DescribeDetector -> Request DescribeDetector
request = Service -> DescribeDetector -> Request DescribeDetector
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeDetector
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeDetector)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeDetector))
-> Logger
-> Service
-> Proxy DescribeDetector
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeDetector)))
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 Detector -> Int -> DescribeDetectorResponse
DescribeDetectorResponse'
            (Maybe Detector -> Int -> DescribeDetectorResponse)
-> Either String (Maybe Detector)
-> Either String (Int -> DescribeDetectorResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Detector)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"detector")
            Either String (Int -> DescribeDetectorResponse)
-> Either String Int -> Either String DescribeDetectorResponse
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 DescribeDetector

instance Prelude.NFData DescribeDetector

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

instance Core.ToPath DescribeDetector where
  toPath :: DescribeDetector -> ByteString
toPath DescribeDetector' {Maybe Text
Text
detectorModelName :: Text
keyValue :: Maybe Text
$sel:detectorModelName:DescribeDetector' :: DescribeDetector -> Text
$sel:keyValue:DescribeDetector' :: DescribeDetector -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/detectors/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
detectorModelName,
        ByteString
"/keyValues/"
      ]

instance Core.ToQuery DescribeDetector where
  toQuery :: DescribeDetector -> QueryString
toQuery DescribeDetector' {Maybe Text
Text
detectorModelName :: Text
keyValue :: Maybe Text
$sel:detectorModelName:DescribeDetector' :: DescribeDetector -> Text
$sel:keyValue:DescribeDetector' :: DescribeDetector -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"keyValue" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
keyValue]

-- | /See:/ 'newDescribeDetectorResponse' smart constructor.
data DescribeDetectorResponse = DescribeDetectorResponse'
  { -- | Information about the detector (instance).
    DescribeDetectorResponse -> Maybe Detector
detector :: Prelude.Maybe Detector,
    -- | The response's http status code.
    DescribeDetectorResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeDetectorResponse -> DescribeDetectorResponse -> Bool
(DescribeDetectorResponse -> DescribeDetectorResponse -> Bool)
-> (DescribeDetectorResponse -> DescribeDetectorResponse -> Bool)
-> Eq DescribeDetectorResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDetectorResponse -> DescribeDetectorResponse -> Bool
$c/= :: DescribeDetectorResponse -> DescribeDetectorResponse -> Bool
== :: DescribeDetectorResponse -> DescribeDetectorResponse -> Bool
$c== :: DescribeDetectorResponse -> DescribeDetectorResponse -> Bool
Prelude.Eq, ReadPrec [DescribeDetectorResponse]
ReadPrec DescribeDetectorResponse
Int -> ReadS DescribeDetectorResponse
ReadS [DescribeDetectorResponse]
(Int -> ReadS DescribeDetectorResponse)
-> ReadS [DescribeDetectorResponse]
-> ReadPrec DescribeDetectorResponse
-> ReadPrec [DescribeDetectorResponse]
-> Read DescribeDetectorResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDetectorResponse]
$creadListPrec :: ReadPrec [DescribeDetectorResponse]
readPrec :: ReadPrec DescribeDetectorResponse
$creadPrec :: ReadPrec DescribeDetectorResponse
readList :: ReadS [DescribeDetectorResponse]
$creadList :: ReadS [DescribeDetectorResponse]
readsPrec :: Int -> ReadS DescribeDetectorResponse
$creadsPrec :: Int -> ReadS DescribeDetectorResponse
Prelude.Read, Int -> DescribeDetectorResponse -> ShowS
[DescribeDetectorResponse] -> ShowS
DescribeDetectorResponse -> String
(Int -> DescribeDetectorResponse -> ShowS)
-> (DescribeDetectorResponse -> String)
-> ([DescribeDetectorResponse] -> ShowS)
-> Show DescribeDetectorResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDetectorResponse] -> ShowS
$cshowList :: [DescribeDetectorResponse] -> ShowS
show :: DescribeDetectorResponse -> String
$cshow :: DescribeDetectorResponse -> String
showsPrec :: Int -> DescribeDetectorResponse -> ShowS
$cshowsPrec :: Int -> DescribeDetectorResponse -> ShowS
Prelude.Show, (forall x.
 DescribeDetectorResponse -> Rep DescribeDetectorResponse x)
-> (forall x.
    Rep DescribeDetectorResponse x -> DescribeDetectorResponse)
-> Generic DescribeDetectorResponse
forall x.
Rep DescribeDetectorResponse x -> DescribeDetectorResponse
forall x.
DescribeDetectorResponse -> Rep DescribeDetectorResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeDetectorResponse x -> DescribeDetectorResponse
$cfrom :: forall x.
DescribeDetectorResponse -> Rep DescribeDetectorResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDetectorResponse' 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:
--
-- 'detector', 'describeDetectorResponse_detector' - Information about the detector (instance).
--
-- 'httpStatus', 'describeDetectorResponse_httpStatus' - The response's http status code.
newDescribeDetectorResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeDetectorResponse
newDescribeDetectorResponse :: Int -> DescribeDetectorResponse
newDescribeDetectorResponse Int
pHttpStatus_ =
  DescribeDetectorResponse' :: Maybe Detector -> Int -> DescribeDetectorResponse
DescribeDetectorResponse'
    { $sel:detector:DescribeDetectorResponse' :: Maybe Detector
detector =
        Maybe Detector
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeDetectorResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the detector (instance).
describeDetectorResponse_detector :: Lens.Lens' DescribeDetectorResponse (Prelude.Maybe Detector)
describeDetectorResponse_detector :: (Maybe Detector -> f (Maybe Detector))
-> DescribeDetectorResponse -> f DescribeDetectorResponse
describeDetectorResponse_detector = (DescribeDetectorResponse -> Maybe Detector)
-> (DescribeDetectorResponse
    -> Maybe Detector -> DescribeDetectorResponse)
-> Lens
     DescribeDetectorResponse
     DescribeDetectorResponse
     (Maybe Detector)
     (Maybe Detector)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDetectorResponse' {Maybe Detector
detector :: Maybe Detector
$sel:detector:DescribeDetectorResponse' :: DescribeDetectorResponse -> Maybe Detector
detector} -> Maybe Detector
detector) (\s :: DescribeDetectorResponse
s@DescribeDetectorResponse' {} Maybe Detector
a -> DescribeDetectorResponse
s {$sel:detector:DescribeDetectorResponse' :: Maybe Detector
detector = Maybe Detector
a} :: DescribeDetectorResponse)

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

instance Prelude.NFData DescribeDetectorResponse