{-# 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.IoTEvents.DescribeDetectorModel
-- 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 detector model. If the @version@ parameter is not specified,
-- information about the latest version is returned.
module Amazonka.IoTEvents.DescribeDetectorModel
  ( -- * Creating a Request
    DescribeDetectorModel (..),
    newDescribeDetectorModel,

    -- * Request Lenses
    describeDetectorModel_detectorModelVersion,
    describeDetectorModel_detectorModelName,

    -- * Destructuring the Response
    DescribeDetectorModelResponse (..),
    newDescribeDetectorModelResponse,

    -- * Response Lenses
    describeDetectorModelResponse_detectorModel,
    describeDetectorModelResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.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:/ 'newDescribeDetectorModel' smart constructor.
data DescribeDetectorModel = DescribeDetectorModel'
  { -- | The version of the detector model.
    DescribeDetectorModel -> Maybe Text
detectorModelVersion :: Prelude.Maybe Prelude.Text,
    -- | The name of the detector model.
    DescribeDetectorModel -> Text
detectorModelName :: Prelude.Text
  }
  deriving (DescribeDetectorModel -> DescribeDetectorModel -> Bool
(DescribeDetectorModel -> DescribeDetectorModel -> Bool)
-> (DescribeDetectorModel -> DescribeDetectorModel -> Bool)
-> Eq DescribeDetectorModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDetectorModel -> DescribeDetectorModel -> Bool
$c/= :: DescribeDetectorModel -> DescribeDetectorModel -> Bool
== :: DescribeDetectorModel -> DescribeDetectorModel -> Bool
$c== :: DescribeDetectorModel -> DescribeDetectorModel -> Bool
Prelude.Eq, ReadPrec [DescribeDetectorModel]
ReadPrec DescribeDetectorModel
Int -> ReadS DescribeDetectorModel
ReadS [DescribeDetectorModel]
(Int -> ReadS DescribeDetectorModel)
-> ReadS [DescribeDetectorModel]
-> ReadPrec DescribeDetectorModel
-> ReadPrec [DescribeDetectorModel]
-> Read DescribeDetectorModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDetectorModel]
$creadListPrec :: ReadPrec [DescribeDetectorModel]
readPrec :: ReadPrec DescribeDetectorModel
$creadPrec :: ReadPrec DescribeDetectorModel
readList :: ReadS [DescribeDetectorModel]
$creadList :: ReadS [DescribeDetectorModel]
readsPrec :: Int -> ReadS DescribeDetectorModel
$creadsPrec :: Int -> ReadS DescribeDetectorModel
Prelude.Read, Int -> DescribeDetectorModel -> ShowS
[DescribeDetectorModel] -> ShowS
DescribeDetectorModel -> String
(Int -> DescribeDetectorModel -> ShowS)
-> (DescribeDetectorModel -> String)
-> ([DescribeDetectorModel] -> ShowS)
-> Show DescribeDetectorModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDetectorModel] -> ShowS
$cshowList :: [DescribeDetectorModel] -> ShowS
show :: DescribeDetectorModel -> String
$cshow :: DescribeDetectorModel -> String
showsPrec :: Int -> DescribeDetectorModel -> ShowS
$cshowsPrec :: Int -> DescribeDetectorModel -> ShowS
Prelude.Show, (forall x. DescribeDetectorModel -> Rep DescribeDetectorModel x)
-> (forall x. Rep DescribeDetectorModel x -> DescribeDetectorModel)
-> Generic DescribeDetectorModel
forall x. Rep DescribeDetectorModel x -> DescribeDetectorModel
forall x. DescribeDetectorModel -> Rep DescribeDetectorModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeDetectorModel x -> DescribeDetectorModel
$cfrom :: forall x. DescribeDetectorModel -> Rep DescribeDetectorModel x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDetectorModel' 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:
--
-- 'detectorModelVersion', 'describeDetectorModel_detectorModelVersion' - The version of the detector model.
--
-- 'detectorModelName', 'describeDetectorModel_detectorModelName' - The name of the detector model.
newDescribeDetectorModel ::
  -- | 'detectorModelName'
  Prelude.Text ->
  DescribeDetectorModel
newDescribeDetectorModel :: Text -> DescribeDetectorModel
newDescribeDetectorModel Text
pDetectorModelName_ =
  DescribeDetectorModel' :: Maybe Text -> Text -> DescribeDetectorModel
DescribeDetectorModel'
    { $sel:detectorModelVersion:DescribeDetectorModel' :: Maybe Text
detectorModelVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorModelName:DescribeDetectorModel' :: Text
detectorModelName = Text
pDetectorModelName_
    }

-- | The version of the detector model.
describeDetectorModel_detectorModelVersion :: Lens.Lens' DescribeDetectorModel (Prelude.Maybe Prelude.Text)
describeDetectorModel_detectorModelVersion :: (Maybe Text -> f (Maybe Text))
-> DescribeDetectorModel -> f DescribeDetectorModel
describeDetectorModel_detectorModelVersion = (DescribeDetectorModel -> Maybe Text)
-> (DescribeDetectorModel -> Maybe Text -> DescribeDetectorModel)
-> Lens
     DescribeDetectorModel
     DescribeDetectorModel
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDetectorModel' {Maybe Text
detectorModelVersion :: Maybe Text
$sel:detectorModelVersion:DescribeDetectorModel' :: DescribeDetectorModel -> Maybe Text
detectorModelVersion} -> Maybe Text
detectorModelVersion) (\s :: DescribeDetectorModel
s@DescribeDetectorModel' {} Maybe Text
a -> DescribeDetectorModel
s {$sel:detectorModelVersion:DescribeDetectorModel' :: Maybe Text
detectorModelVersion = Maybe Text
a} :: DescribeDetectorModel)

-- | The name of the detector model.
describeDetectorModel_detectorModelName :: Lens.Lens' DescribeDetectorModel Prelude.Text
describeDetectorModel_detectorModelName :: (Text -> f Text)
-> DescribeDetectorModel -> f DescribeDetectorModel
describeDetectorModel_detectorModelName = (DescribeDetectorModel -> Text)
-> (DescribeDetectorModel -> Text -> DescribeDetectorModel)
-> Lens DescribeDetectorModel DescribeDetectorModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDetectorModel' {Text
detectorModelName :: Text
$sel:detectorModelName:DescribeDetectorModel' :: DescribeDetectorModel -> Text
detectorModelName} -> Text
detectorModelName) (\s :: DescribeDetectorModel
s@DescribeDetectorModel' {} Text
a -> DescribeDetectorModel
s {$sel:detectorModelName:DescribeDetectorModel' :: Text
detectorModelName = Text
a} :: DescribeDetectorModel)

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

instance Prelude.NFData DescribeDetectorModel

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

instance Core.ToPath DescribeDetectorModel where
  toPath :: DescribeDetectorModel -> ByteString
toPath DescribeDetectorModel' {Maybe Text
Text
detectorModelName :: Text
detectorModelVersion :: Maybe Text
$sel:detectorModelName:DescribeDetectorModel' :: DescribeDetectorModel -> Text
$sel:detectorModelVersion:DescribeDetectorModel' :: DescribeDetectorModel -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/detector-models/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
detectorModelName]

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

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

-- |
-- Create a value of 'DescribeDetectorModelResponse' 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:
--
-- 'detectorModel', 'describeDetectorModelResponse_detectorModel' - Information about the detector model.
--
-- 'httpStatus', 'describeDetectorModelResponse_httpStatus' - The response's http status code.
newDescribeDetectorModelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeDetectorModelResponse
newDescribeDetectorModelResponse :: Int -> DescribeDetectorModelResponse
newDescribeDetectorModelResponse Int
pHttpStatus_ =
  DescribeDetectorModelResponse' :: Maybe DetectorModel -> Int -> DescribeDetectorModelResponse
DescribeDetectorModelResponse'
    { $sel:detectorModel:DescribeDetectorModelResponse' :: Maybe DetectorModel
detectorModel =
        Maybe DetectorModel
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeDetectorModelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the detector model.
describeDetectorModelResponse_detectorModel :: Lens.Lens' DescribeDetectorModelResponse (Prelude.Maybe DetectorModel)
describeDetectorModelResponse_detectorModel :: (Maybe DetectorModel -> f (Maybe DetectorModel))
-> DescribeDetectorModelResponse -> f DescribeDetectorModelResponse
describeDetectorModelResponse_detectorModel = (DescribeDetectorModelResponse -> Maybe DetectorModel)
-> (DescribeDetectorModelResponse
    -> Maybe DetectorModel -> DescribeDetectorModelResponse)
-> Lens
     DescribeDetectorModelResponse
     DescribeDetectorModelResponse
     (Maybe DetectorModel)
     (Maybe DetectorModel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDetectorModelResponse' {Maybe DetectorModel
detectorModel :: Maybe DetectorModel
$sel:detectorModel:DescribeDetectorModelResponse' :: DescribeDetectorModelResponse -> Maybe DetectorModel
detectorModel} -> Maybe DetectorModel
detectorModel) (\s :: DescribeDetectorModelResponse
s@DescribeDetectorModelResponse' {} Maybe DetectorModel
a -> DescribeDetectorModelResponse
s {$sel:detectorModel:DescribeDetectorModelResponse' :: Maybe DetectorModel
detectorModel = Maybe DetectorModel
a} :: DescribeDetectorModelResponse)

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

instance Prelude.NFData DescribeDetectorModelResponse