{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.AnalysisResult
-- 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)
module Amazonka.IoTEvents.Types.AnalysisResult where

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.AnalysisResultLevel
import Amazonka.IoTEvents.Types.AnalysisResultLocation
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the result of the analysis.
--
-- /See:/ 'newAnalysisResult' smart constructor.
data AnalysisResult = AnalysisResult'
  { -- | The type of the analysis result. Analyses fall into the following types
    -- based on the validators used to generate the analysis result:
    --
    -- -   @supported-actions@ - You must specify AWS IoT Events supported
    --     actions that work with other AWS services in a supported AWS Region.
    --
    -- -   @service-limits@ - Resources or API operations can\'t exceed service
    --     quotas (also known as limits). Update your detector model or request
    --     a quota increase.
    --
    -- -   @structure@ - The detector model must follow a structure that AWS
    --     IoT Events supports.
    --
    -- -   @expression-syntax@ - Your expression must follow the required
    --     syntax.
    --
    -- -   @data-type@ - Data types referenced in the detector model must be
    --     compatible.
    --
    -- -   @referenced-data@ - You must define the data referenced in your
    --     detector model before you can use the data.
    --
    -- -   @referenced-resource@ - Resources that the detector model uses must
    --     be available.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-analyze-api.html Running detector model analyses>
    -- in the /AWS IoT Events Developer Guide/.
    AnalysisResult -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | Contains additional information about the analysis result.
    AnalysisResult -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The severity level of the analysis result. Based on the severity level,
    -- analysis results fall into three general categories:
    --
    -- -   @INFO@ - An information result tells you about a significant field
    --     in your detector model. This type of result usually doesn\'t require
    --     immediate action.
    --
    -- -   @WARNING@ - A warning result draws special attention to fields that
    --     might cause issues for your detector model. We recommend that you
    --     review warnings and take necessary actions before you use your
    --     detector model in production environments. Otherwise, the detector
    --     model might not work as expected.
    --
    -- -   @ERROR@ - An error result notifies you about a problem found in your
    --     detector model. You must fix all errors before you can publish your
    --     detector model.
    AnalysisResult -> Maybe AnalysisResultLevel
level :: Prelude.Maybe AnalysisResultLevel,
    -- | Contains one or more locations that you can use to locate the fields in
    -- your detector model that the analysis result references.
    AnalysisResult -> Maybe [AnalysisResultLocation]
locations :: Prelude.Maybe [AnalysisResultLocation]
  }
  deriving (AnalysisResult -> AnalysisResult -> Bool
(AnalysisResult -> AnalysisResult -> Bool)
-> (AnalysisResult -> AnalysisResult -> Bool) -> Eq AnalysisResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalysisResult -> AnalysisResult -> Bool
$c/= :: AnalysisResult -> AnalysisResult -> Bool
== :: AnalysisResult -> AnalysisResult -> Bool
$c== :: AnalysisResult -> AnalysisResult -> Bool
Prelude.Eq, ReadPrec [AnalysisResult]
ReadPrec AnalysisResult
Int -> ReadS AnalysisResult
ReadS [AnalysisResult]
(Int -> ReadS AnalysisResult)
-> ReadS [AnalysisResult]
-> ReadPrec AnalysisResult
-> ReadPrec [AnalysisResult]
-> Read AnalysisResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalysisResult]
$creadListPrec :: ReadPrec [AnalysisResult]
readPrec :: ReadPrec AnalysisResult
$creadPrec :: ReadPrec AnalysisResult
readList :: ReadS [AnalysisResult]
$creadList :: ReadS [AnalysisResult]
readsPrec :: Int -> ReadS AnalysisResult
$creadsPrec :: Int -> ReadS AnalysisResult
Prelude.Read, Int -> AnalysisResult -> ShowS
[AnalysisResult] -> ShowS
AnalysisResult -> String
(Int -> AnalysisResult -> ShowS)
-> (AnalysisResult -> String)
-> ([AnalysisResult] -> ShowS)
-> Show AnalysisResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalysisResult] -> ShowS
$cshowList :: [AnalysisResult] -> ShowS
show :: AnalysisResult -> String
$cshow :: AnalysisResult -> String
showsPrec :: Int -> AnalysisResult -> ShowS
$cshowsPrec :: Int -> AnalysisResult -> ShowS
Prelude.Show, (forall x. AnalysisResult -> Rep AnalysisResult x)
-> (forall x. Rep AnalysisResult x -> AnalysisResult)
-> Generic AnalysisResult
forall x. Rep AnalysisResult x -> AnalysisResult
forall x. AnalysisResult -> Rep AnalysisResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalysisResult x -> AnalysisResult
$cfrom :: forall x. AnalysisResult -> Rep AnalysisResult x
Prelude.Generic)

-- |
-- Create a value of 'AnalysisResult' 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:
--
-- 'type'', 'analysisResult_type' - The type of the analysis result. Analyses fall into the following types
-- based on the validators used to generate the analysis result:
--
-- -   @supported-actions@ - You must specify AWS IoT Events supported
--     actions that work with other AWS services in a supported AWS Region.
--
-- -   @service-limits@ - Resources or API operations can\'t exceed service
--     quotas (also known as limits). Update your detector model or request
--     a quota increase.
--
-- -   @structure@ - The detector model must follow a structure that AWS
--     IoT Events supports.
--
-- -   @expression-syntax@ - Your expression must follow the required
--     syntax.
--
-- -   @data-type@ - Data types referenced in the detector model must be
--     compatible.
--
-- -   @referenced-data@ - You must define the data referenced in your
--     detector model before you can use the data.
--
-- -   @referenced-resource@ - Resources that the detector model uses must
--     be available.
--
-- For more information, see
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-analyze-api.html Running detector model analyses>
-- in the /AWS IoT Events Developer Guide/.
--
-- 'message', 'analysisResult_message' - Contains additional information about the analysis result.
--
-- 'level', 'analysisResult_level' - The severity level of the analysis result. Based on the severity level,
-- analysis results fall into three general categories:
--
-- -   @INFO@ - An information result tells you about a significant field
--     in your detector model. This type of result usually doesn\'t require
--     immediate action.
--
-- -   @WARNING@ - A warning result draws special attention to fields that
--     might cause issues for your detector model. We recommend that you
--     review warnings and take necessary actions before you use your
--     detector model in production environments. Otherwise, the detector
--     model might not work as expected.
--
-- -   @ERROR@ - An error result notifies you about a problem found in your
--     detector model. You must fix all errors before you can publish your
--     detector model.
--
-- 'locations', 'analysisResult_locations' - Contains one or more locations that you can use to locate the fields in
-- your detector model that the analysis result references.
newAnalysisResult ::
  AnalysisResult
newAnalysisResult :: AnalysisResult
newAnalysisResult =
  AnalysisResult' :: Maybe Text
-> Maybe Text
-> Maybe AnalysisResultLevel
-> Maybe [AnalysisResultLocation]
-> AnalysisResult
AnalysisResult'
    { $sel:type':AnalysisResult' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:AnalysisResult' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:level:AnalysisResult' :: Maybe AnalysisResultLevel
level = Maybe AnalysisResultLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:locations:AnalysisResult' :: Maybe [AnalysisResultLocation]
locations = Maybe [AnalysisResultLocation]
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of the analysis result. Analyses fall into the following types
-- based on the validators used to generate the analysis result:
--
-- -   @supported-actions@ - You must specify AWS IoT Events supported
--     actions that work with other AWS services in a supported AWS Region.
--
-- -   @service-limits@ - Resources or API operations can\'t exceed service
--     quotas (also known as limits). Update your detector model or request
--     a quota increase.
--
-- -   @structure@ - The detector model must follow a structure that AWS
--     IoT Events supports.
--
-- -   @expression-syntax@ - Your expression must follow the required
--     syntax.
--
-- -   @data-type@ - Data types referenced in the detector model must be
--     compatible.
--
-- -   @referenced-data@ - You must define the data referenced in your
--     detector model before you can use the data.
--
-- -   @referenced-resource@ - Resources that the detector model uses must
--     be available.
--
-- For more information, see
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-analyze-api.html Running detector model analyses>
-- in the /AWS IoT Events Developer Guide/.
analysisResult_type :: Lens.Lens' AnalysisResult (Prelude.Maybe Prelude.Text)
analysisResult_type :: (Maybe Text -> f (Maybe Text))
-> AnalysisResult -> f AnalysisResult
analysisResult_type = (AnalysisResult -> Maybe Text)
-> (AnalysisResult -> Maybe Text -> AnalysisResult)
-> Lens AnalysisResult AnalysisResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisResult' {Maybe Text
type' :: Maybe Text
$sel:type':AnalysisResult' :: AnalysisResult -> Maybe Text
type'} -> Maybe Text
type') (\s :: AnalysisResult
s@AnalysisResult' {} Maybe Text
a -> AnalysisResult
s {$sel:type':AnalysisResult' :: Maybe Text
type' = Maybe Text
a} :: AnalysisResult)

-- | Contains additional information about the analysis result.
analysisResult_message :: Lens.Lens' AnalysisResult (Prelude.Maybe Prelude.Text)
analysisResult_message :: (Maybe Text -> f (Maybe Text))
-> AnalysisResult -> f AnalysisResult
analysisResult_message = (AnalysisResult -> Maybe Text)
-> (AnalysisResult -> Maybe Text -> AnalysisResult)
-> Lens AnalysisResult AnalysisResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisResult' {Maybe Text
message :: Maybe Text
$sel:message:AnalysisResult' :: AnalysisResult -> Maybe Text
message} -> Maybe Text
message) (\s :: AnalysisResult
s@AnalysisResult' {} Maybe Text
a -> AnalysisResult
s {$sel:message:AnalysisResult' :: Maybe Text
message = Maybe Text
a} :: AnalysisResult)

-- | The severity level of the analysis result. Based on the severity level,
-- analysis results fall into three general categories:
--
-- -   @INFO@ - An information result tells you about a significant field
--     in your detector model. This type of result usually doesn\'t require
--     immediate action.
--
-- -   @WARNING@ - A warning result draws special attention to fields that
--     might cause issues for your detector model. We recommend that you
--     review warnings and take necessary actions before you use your
--     detector model in production environments. Otherwise, the detector
--     model might not work as expected.
--
-- -   @ERROR@ - An error result notifies you about a problem found in your
--     detector model. You must fix all errors before you can publish your
--     detector model.
analysisResult_level :: Lens.Lens' AnalysisResult (Prelude.Maybe AnalysisResultLevel)
analysisResult_level :: (Maybe AnalysisResultLevel -> f (Maybe AnalysisResultLevel))
-> AnalysisResult -> f AnalysisResult
analysisResult_level = (AnalysisResult -> Maybe AnalysisResultLevel)
-> (AnalysisResult -> Maybe AnalysisResultLevel -> AnalysisResult)
-> Lens
     AnalysisResult
     AnalysisResult
     (Maybe AnalysisResultLevel)
     (Maybe AnalysisResultLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisResult' {Maybe AnalysisResultLevel
level :: Maybe AnalysisResultLevel
$sel:level:AnalysisResult' :: AnalysisResult -> Maybe AnalysisResultLevel
level} -> Maybe AnalysisResultLevel
level) (\s :: AnalysisResult
s@AnalysisResult' {} Maybe AnalysisResultLevel
a -> AnalysisResult
s {$sel:level:AnalysisResult' :: Maybe AnalysisResultLevel
level = Maybe AnalysisResultLevel
a} :: AnalysisResult)

-- | Contains one or more locations that you can use to locate the fields in
-- your detector model that the analysis result references.
analysisResult_locations :: Lens.Lens' AnalysisResult (Prelude.Maybe [AnalysisResultLocation])
analysisResult_locations :: (Maybe [AnalysisResultLocation]
 -> f (Maybe [AnalysisResultLocation]))
-> AnalysisResult -> f AnalysisResult
analysisResult_locations = (AnalysisResult -> Maybe [AnalysisResultLocation])
-> (AnalysisResult
    -> Maybe [AnalysisResultLocation] -> AnalysisResult)
-> Lens
     AnalysisResult
     AnalysisResult
     (Maybe [AnalysisResultLocation])
     (Maybe [AnalysisResultLocation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisResult' {Maybe [AnalysisResultLocation]
locations :: Maybe [AnalysisResultLocation]
$sel:locations:AnalysisResult' :: AnalysisResult -> Maybe [AnalysisResultLocation]
locations} -> Maybe [AnalysisResultLocation]
locations) (\s :: AnalysisResult
s@AnalysisResult' {} Maybe [AnalysisResultLocation]
a -> AnalysisResult
s {$sel:locations:AnalysisResult' :: Maybe [AnalysisResultLocation]
locations = Maybe [AnalysisResultLocation]
a} :: AnalysisResult) ((Maybe [AnalysisResultLocation]
  -> f (Maybe [AnalysisResultLocation]))
 -> AnalysisResult -> f AnalysisResult)
-> ((Maybe [AnalysisResultLocation]
     -> f (Maybe [AnalysisResultLocation]))
    -> Maybe [AnalysisResultLocation]
    -> f (Maybe [AnalysisResultLocation]))
-> (Maybe [AnalysisResultLocation]
    -> f (Maybe [AnalysisResultLocation]))
-> AnalysisResult
-> f AnalysisResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AnalysisResultLocation]
  [AnalysisResultLocation]
  [AnalysisResultLocation]
  [AnalysisResultLocation]
-> Iso
     (Maybe [AnalysisResultLocation])
     (Maybe [AnalysisResultLocation])
     (Maybe [AnalysisResultLocation])
     (Maybe [AnalysisResultLocation])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [AnalysisResultLocation]
  [AnalysisResultLocation]
  [AnalysisResultLocation]
  [AnalysisResultLocation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AnalysisResult where
  parseJSON :: Value -> Parser AnalysisResult
parseJSON =
    String
-> (Object -> Parser AnalysisResult)
-> Value
-> Parser AnalysisResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AnalysisResult"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe AnalysisResultLevel
-> Maybe [AnalysisResultLocation]
-> AnalysisResult
AnalysisResult'
            (Maybe Text
 -> Maybe Text
 -> Maybe AnalysisResultLevel
 -> Maybe [AnalysisResultLocation]
 -> AnalysisResult)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe AnalysisResultLevel
      -> Maybe [AnalysisResultLocation]
      -> AnalysisResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
            Parser
  (Maybe Text
   -> Maybe AnalysisResultLevel
   -> Maybe [AnalysisResultLocation]
   -> AnalysisResult)
-> Parser (Maybe Text)
-> Parser
     (Maybe AnalysisResultLevel
      -> Maybe [AnalysisResultLocation] -> AnalysisResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"message")
            Parser
  (Maybe AnalysisResultLevel
   -> Maybe [AnalysisResultLocation] -> AnalysisResult)
-> Parser (Maybe AnalysisResultLevel)
-> Parser (Maybe [AnalysisResultLocation] -> AnalysisResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AnalysisResultLevel)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"level")
            Parser (Maybe [AnalysisResultLocation] -> AnalysisResult)
-> Parser (Maybe [AnalysisResultLocation]) -> Parser AnalysisResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [AnalysisResultLocation]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"locations" Parser (Maybe (Maybe [AnalysisResultLocation]))
-> Maybe [AnalysisResultLocation]
-> Parser (Maybe [AnalysisResultLocation])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AnalysisResultLocation]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AnalysisResult

instance Prelude.NFData AnalysisResult