{-# 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.DescribeDetectorModelAnalysis
-- 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)
--
-- Retrieves runtime information about a detector model analysis.
--
-- After AWS IoT Events starts analyzing your detector model, you have up
-- to 24 hours to retrieve the analysis results.
module Amazonka.IoTEvents.DescribeDetectorModelAnalysis
  ( -- * Creating a Request
    DescribeDetectorModelAnalysis (..),
    newDescribeDetectorModelAnalysis,

    -- * Request Lenses
    describeDetectorModelAnalysis_analysisId,

    -- * Destructuring the Response
    DescribeDetectorModelAnalysisResponse (..),
    newDescribeDetectorModelAnalysisResponse,

    -- * Response Lenses
    describeDetectorModelAnalysisResponse_status,
    describeDetectorModelAnalysisResponse_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:/ 'newDescribeDetectorModelAnalysis' smart constructor.
data DescribeDetectorModelAnalysis = DescribeDetectorModelAnalysis'
  { -- | The ID of the analysis result that you want to retrieve.
    DescribeDetectorModelAnalysis -> Text
analysisId :: Prelude.Text
  }
  deriving (DescribeDetectorModelAnalysis
-> DescribeDetectorModelAnalysis -> Bool
(DescribeDetectorModelAnalysis
 -> DescribeDetectorModelAnalysis -> Bool)
-> (DescribeDetectorModelAnalysis
    -> DescribeDetectorModelAnalysis -> Bool)
-> Eq DescribeDetectorModelAnalysis
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDetectorModelAnalysis
-> DescribeDetectorModelAnalysis -> Bool
$c/= :: DescribeDetectorModelAnalysis
-> DescribeDetectorModelAnalysis -> Bool
== :: DescribeDetectorModelAnalysis
-> DescribeDetectorModelAnalysis -> Bool
$c== :: DescribeDetectorModelAnalysis
-> DescribeDetectorModelAnalysis -> Bool
Prelude.Eq, ReadPrec [DescribeDetectorModelAnalysis]
ReadPrec DescribeDetectorModelAnalysis
Int -> ReadS DescribeDetectorModelAnalysis
ReadS [DescribeDetectorModelAnalysis]
(Int -> ReadS DescribeDetectorModelAnalysis)
-> ReadS [DescribeDetectorModelAnalysis]
-> ReadPrec DescribeDetectorModelAnalysis
-> ReadPrec [DescribeDetectorModelAnalysis]
-> Read DescribeDetectorModelAnalysis
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDetectorModelAnalysis]
$creadListPrec :: ReadPrec [DescribeDetectorModelAnalysis]
readPrec :: ReadPrec DescribeDetectorModelAnalysis
$creadPrec :: ReadPrec DescribeDetectorModelAnalysis
readList :: ReadS [DescribeDetectorModelAnalysis]
$creadList :: ReadS [DescribeDetectorModelAnalysis]
readsPrec :: Int -> ReadS DescribeDetectorModelAnalysis
$creadsPrec :: Int -> ReadS DescribeDetectorModelAnalysis
Prelude.Read, Int -> DescribeDetectorModelAnalysis -> ShowS
[DescribeDetectorModelAnalysis] -> ShowS
DescribeDetectorModelAnalysis -> String
(Int -> DescribeDetectorModelAnalysis -> ShowS)
-> (DescribeDetectorModelAnalysis -> String)
-> ([DescribeDetectorModelAnalysis] -> ShowS)
-> Show DescribeDetectorModelAnalysis
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDetectorModelAnalysis] -> ShowS
$cshowList :: [DescribeDetectorModelAnalysis] -> ShowS
show :: DescribeDetectorModelAnalysis -> String
$cshow :: DescribeDetectorModelAnalysis -> String
showsPrec :: Int -> DescribeDetectorModelAnalysis -> ShowS
$cshowsPrec :: Int -> DescribeDetectorModelAnalysis -> ShowS
Prelude.Show, (forall x.
 DescribeDetectorModelAnalysis
 -> Rep DescribeDetectorModelAnalysis x)
-> (forall x.
    Rep DescribeDetectorModelAnalysis x
    -> DescribeDetectorModelAnalysis)
-> Generic DescribeDetectorModelAnalysis
forall x.
Rep DescribeDetectorModelAnalysis x
-> DescribeDetectorModelAnalysis
forall x.
DescribeDetectorModelAnalysis
-> Rep DescribeDetectorModelAnalysis x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeDetectorModelAnalysis x
-> DescribeDetectorModelAnalysis
$cfrom :: forall x.
DescribeDetectorModelAnalysis
-> Rep DescribeDetectorModelAnalysis x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDetectorModelAnalysis' 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:
--
-- 'analysisId', 'describeDetectorModelAnalysis_analysisId' - The ID of the analysis result that you want to retrieve.
newDescribeDetectorModelAnalysis ::
  -- | 'analysisId'
  Prelude.Text ->
  DescribeDetectorModelAnalysis
newDescribeDetectorModelAnalysis :: Text -> DescribeDetectorModelAnalysis
newDescribeDetectorModelAnalysis Text
pAnalysisId_ =
  DescribeDetectorModelAnalysis' :: Text -> DescribeDetectorModelAnalysis
DescribeDetectorModelAnalysis'
    { $sel:analysisId:DescribeDetectorModelAnalysis' :: Text
analysisId =
        Text
pAnalysisId_
    }

-- | The ID of the analysis result that you want to retrieve.
describeDetectorModelAnalysis_analysisId :: Lens.Lens' DescribeDetectorModelAnalysis Prelude.Text
describeDetectorModelAnalysis_analysisId :: (Text -> f Text)
-> DescribeDetectorModelAnalysis -> f DescribeDetectorModelAnalysis
describeDetectorModelAnalysis_analysisId = (DescribeDetectorModelAnalysis -> Text)
-> (DescribeDetectorModelAnalysis
    -> Text -> DescribeDetectorModelAnalysis)
-> Lens
     DescribeDetectorModelAnalysis
     DescribeDetectorModelAnalysis
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDetectorModelAnalysis' {Text
analysisId :: Text
$sel:analysisId:DescribeDetectorModelAnalysis' :: DescribeDetectorModelAnalysis -> Text
analysisId} -> Text
analysisId) (\s :: DescribeDetectorModelAnalysis
s@DescribeDetectorModelAnalysis' {} Text
a -> DescribeDetectorModelAnalysis
s {$sel:analysisId:DescribeDetectorModelAnalysis' :: Text
analysisId = Text
a} :: DescribeDetectorModelAnalysis)

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

instance Prelude.NFData DescribeDetectorModelAnalysis

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

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

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

-- | /See:/ 'newDescribeDetectorModelAnalysisResponse' smart constructor.
data DescribeDetectorModelAnalysisResponse = DescribeDetectorModelAnalysisResponse'
  { -- | The status of the analysis activity. The status can be one of the
    -- following values:
    --
    -- -   @RUNNING@ - AWS IoT Events is analyzing your detector model. This
    --     process can take several minutes to complete.
    --
    -- -   @COMPLETE@ - AWS IoT Events finished analyzing your detector model.
    --
    -- -   @FAILED@ - AWS IoT Events couldn\'t analyze your detector model. Try
    --     again later.
    DescribeDetectorModelAnalysisResponse -> Maybe AnalysisStatus
status :: Prelude.Maybe AnalysisStatus,
    -- | The response's http status code.
    DescribeDetectorModelAnalysisResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeDetectorModelAnalysisResponse
-> DescribeDetectorModelAnalysisResponse -> Bool
(DescribeDetectorModelAnalysisResponse
 -> DescribeDetectorModelAnalysisResponse -> Bool)
-> (DescribeDetectorModelAnalysisResponse
    -> DescribeDetectorModelAnalysisResponse -> Bool)
-> Eq DescribeDetectorModelAnalysisResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDetectorModelAnalysisResponse
-> DescribeDetectorModelAnalysisResponse -> Bool
$c/= :: DescribeDetectorModelAnalysisResponse
-> DescribeDetectorModelAnalysisResponse -> Bool
== :: DescribeDetectorModelAnalysisResponse
-> DescribeDetectorModelAnalysisResponse -> Bool
$c== :: DescribeDetectorModelAnalysisResponse
-> DescribeDetectorModelAnalysisResponse -> Bool
Prelude.Eq, ReadPrec [DescribeDetectorModelAnalysisResponse]
ReadPrec DescribeDetectorModelAnalysisResponse
Int -> ReadS DescribeDetectorModelAnalysisResponse
ReadS [DescribeDetectorModelAnalysisResponse]
(Int -> ReadS DescribeDetectorModelAnalysisResponse)
-> ReadS [DescribeDetectorModelAnalysisResponse]
-> ReadPrec DescribeDetectorModelAnalysisResponse
-> ReadPrec [DescribeDetectorModelAnalysisResponse]
-> Read DescribeDetectorModelAnalysisResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDetectorModelAnalysisResponse]
$creadListPrec :: ReadPrec [DescribeDetectorModelAnalysisResponse]
readPrec :: ReadPrec DescribeDetectorModelAnalysisResponse
$creadPrec :: ReadPrec DescribeDetectorModelAnalysisResponse
readList :: ReadS [DescribeDetectorModelAnalysisResponse]
$creadList :: ReadS [DescribeDetectorModelAnalysisResponse]
readsPrec :: Int -> ReadS DescribeDetectorModelAnalysisResponse
$creadsPrec :: Int -> ReadS DescribeDetectorModelAnalysisResponse
Prelude.Read, Int -> DescribeDetectorModelAnalysisResponse -> ShowS
[DescribeDetectorModelAnalysisResponse] -> ShowS
DescribeDetectorModelAnalysisResponse -> String
(Int -> DescribeDetectorModelAnalysisResponse -> ShowS)
-> (DescribeDetectorModelAnalysisResponse -> String)
-> ([DescribeDetectorModelAnalysisResponse] -> ShowS)
-> Show DescribeDetectorModelAnalysisResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDetectorModelAnalysisResponse] -> ShowS
$cshowList :: [DescribeDetectorModelAnalysisResponse] -> ShowS
show :: DescribeDetectorModelAnalysisResponse -> String
$cshow :: DescribeDetectorModelAnalysisResponse -> String
showsPrec :: Int -> DescribeDetectorModelAnalysisResponse -> ShowS
$cshowsPrec :: Int -> DescribeDetectorModelAnalysisResponse -> ShowS
Prelude.Show, (forall x.
 DescribeDetectorModelAnalysisResponse
 -> Rep DescribeDetectorModelAnalysisResponse x)
-> (forall x.
    Rep DescribeDetectorModelAnalysisResponse x
    -> DescribeDetectorModelAnalysisResponse)
-> Generic DescribeDetectorModelAnalysisResponse
forall x.
Rep DescribeDetectorModelAnalysisResponse x
-> DescribeDetectorModelAnalysisResponse
forall x.
DescribeDetectorModelAnalysisResponse
-> Rep DescribeDetectorModelAnalysisResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeDetectorModelAnalysisResponse x
-> DescribeDetectorModelAnalysisResponse
$cfrom :: forall x.
DescribeDetectorModelAnalysisResponse
-> Rep DescribeDetectorModelAnalysisResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDetectorModelAnalysisResponse' 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:
--
-- 'status', 'describeDetectorModelAnalysisResponse_status' - The status of the analysis activity. The status can be one of the
-- following values:
--
-- -   @RUNNING@ - AWS IoT Events is analyzing your detector model. This
--     process can take several minutes to complete.
--
-- -   @COMPLETE@ - AWS IoT Events finished analyzing your detector model.
--
-- -   @FAILED@ - AWS IoT Events couldn\'t analyze your detector model. Try
--     again later.
--
-- 'httpStatus', 'describeDetectorModelAnalysisResponse_httpStatus' - The response's http status code.
newDescribeDetectorModelAnalysisResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeDetectorModelAnalysisResponse
newDescribeDetectorModelAnalysisResponse :: Int -> DescribeDetectorModelAnalysisResponse
newDescribeDetectorModelAnalysisResponse Int
pHttpStatus_ =
  DescribeDetectorModelAnalysisResponse' :: Maybe AnalysisStatus
-> Int -> DescribeDetectorModelAnalysisResponse
DescribeDetectorModelAnalysisResponse'
    { $sel:status:DescribeDetectorModelAnalysisResponse' :: Maybe AnalysisStatus
status =
        Maybe AnalysisStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeDetectorModelAnalysisResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the analysis activity. The status can be one of the
-- following values:
--
-- -   @RUNNING@ - AWS IoT Events is analyzing your detector model. This
--     process can take several minutes to complete.
--
-- -   @COMPLETE@ - AWS IoT Events finished analyzing your detector model.
--
-- -   @FAILED@ - AWS IoT Events couldn\'t analyze your detector model. Try
--     again later.
describeDetectorModelAnalysisResponse_status :: Lens.Lens' DescribeDetectorModelAnalysisResponse (Prelude.Maybe AnalysisStatus)
describeDetectorModelAnalysisResponse_status :: (Maybe AnalysisStatus -> f (Maybe AnalysisStatus))
-> DescribeDetectorModelAnalysisResponse
-> f DescribeDetectorModelAnalysisResponse
describeDetectorModelAnalysisResponse_status = (DescribeDetectorModelAnalysisResponse -> Maybe AnalysisStatus)
-> (DescribeDetectorModelAnalysisResponse
    -> Maybe AnalysisStatus -> DescribeDetectorModelAnalysisResponse)
-> Lens
     DescribeDetectorModelAnalysisResponse
     DescribeDetectorModelAnalysisResponse
     (Maybe AnalysisStatus)
     (Maybe AnalysisStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDetectorModelAnalysisResponse' {Maybe AnalysisStatus
status :: Maybe AnalysisStatus
$sel:status:DescribeDetectorModelAnalysisResponse' :: DescribeDetectorModelAnalysisResponse -> Maybe AnalysisStatus
status} -> Maybe AnalysisStatus
status) (\s :: DescribeDetectorModelAnalysisResponse
s@DescribeDetectorModelAnalysisResponse' {} Maybe AnalysisStatus
a -> DescribeDetectorModelAnalysisResponse
s {$sel:status:DescribeDetectorModelAnalysisResponse' :: Maybe AnalysisStatus
status = Maybe AnalysisStatus
a} :: DescribeDetectorModelAnalysisResponse)

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

instance
  Prelude.NFData
    DescribeDetectorModelAnalysisResponse