{-# 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.LookoutVision.Types.DetectAnomalyResult
-- 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.LookoutVision.Types.DetectAnomalyResult where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutVision.Types.ImageSource
import qualified Amazonka.Prelude as Prelude

-- | The prediction results from a call to DetectAnomalies.
--
-- /See:/ 'newDetectAnomalyResult' smart constructor.
data DetectAnomalyResult = DetectAnomalyResult'
  { -- | True if the image contains an anomaly, otherwise false.
    DetectAnomalyResult -> Maybe Bool
isAnomalous :: Prelude.Maybe Prelude.Bool,
    -- | The confidence that Amazon Lookout for Vision has in the accuracy of the
    -- prediction.
    DetectAnomalyResult -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | The source of the image that was analyzed. @direct@ means that the
    -- images was supplied from the local computer. No other values are
    -- supported.
    DetectAnomalyResult -> Maybe ImageSource
source :: Prelude.Maybe ImageSource
  }
  deriving (DetectAnomalyResult -> DetectAnomalyResult -> Bool
(DetectAnomalyResult -> DetectAnomalyResult -> Bool)
-> (DetectAnomalyResult -> DetectAnomalyResult -> Bool)
-> Eq DetectAnomalyResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectAnomalyResult -> DetectAnomalyResult -> Bool
$c/= :: DetectAnomalyResult -> DetectAnomalyResult -> Bool
== :: DetectAnomalyResult -> DetectAnomalyResult -> Bool
$c== :: DetectAnomalyResult -> DetectAnomalyResult -> Bool
Prelude.Eq, ReadPrec [DetectAnomalyResult]
ReadPrec DetectAnomalyResult
Int -> ReadS DetectAnomalyResult
ReadS [DetectAnomalyResult]
(Int -> ReadS DetectAnomalyResult)
-> ReadS [DetectAnomalyResult]
-> ReadPrec DetectAnomalyResult
-> ReadPrec [DetectAnomalyResult]
-> Read DetectAnomalyResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectAnomalyResult]
$creadListPrec :: ReadPrec [DetectAnomalyResult]
readPrec :: ReadPrec DetectAnomalyResult
$creadPrec :: ReadPrec DetectAnomalyResult
readList :: ReadS [DetectAnomalyResult]
$creadList :: ReadS [DetectAnomalyResult]
readsPrec :: Int -> ReadS DetectAnomalyResult
$creadsPrec :: Int -> ReadS DetectAnomalyResult
Prelude.Read, Int -> DetectAnomalyResult -> ShowS
[DetectAnomalyResult] -> ShowS
DetectAnomalyResult -> String
(Int -> DetectAnomalyResult -> ShowS)
-> (DetectAnomalyResult -> String)
-> ([DetectAnomalyResult] -> ShowS)
-> Show DetectAnomalyResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectAnomalyResult] -> ShowS
$cshowList :: [DetectAnomalyResult] -> ShowS
show :: DetectAnomalyResult -> String
$cshow :: DetectAnomalyResult -> String
showsPrec :: Int -> DetectAnomalyResult -> ShowS
$cshowsPrec :: Int -> DetectAnomalyResult -> ShowS
Prelude.Show, (forall x. DetectAnomalyResult -> Rep DetectAnomalyResult x)
-> (forall x. Rep DetectAnomalyResult x -> DetectAnomalyResult)
-> Generic DetectAnomalyResult
forall x. Rep DetectAnomalyResult x -> DetectAnomalyResult
forall x. DetectAnomalyResult -> Rep DetectAnomalyResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectAnomalyResult x -> DetectAnomalyResult
$cfrom :: forall x. DetectAnomalyResult -> Rep DetectAnomalyResult x
Prelude.Generic)

-- |
-- Create a value of 'DetectAnomalyResult' 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:
--
-- 'isAnomalous', 'detectAnomalyResult_isAnomalous' - True if the image contains an anomaly, otherwise false.
--
-- 'confidence', 'detectAnomalyResult_confidence' - The confidence that Amazon Lookout for Vision has in the accuracy of the
-- prediction.
--
-- 'source', 'detectAnomalyResult_source' - The source of the image that was analyzed. @direct@ means that the
-- images was supplied from the local computer. No other values are
-- supported.
newDetectAnomalyResult ::
  DetectAnomalyResult
newDetectAnomalyResult :: DetectAnomalyResult
newDetectAnomalyResult =
  DetectAnomalyResult' :: Maybe Bool
-> Maybe Double -> Maybe ImageSource -> DetectAnomalyResult
DetectAnomalyResult'
    { $sel:isAnomalous:DetectAnomalyResult' :: Maybe Bool
isAnomalous = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:confidence:DetectAnomalyResult' :: Maybe Double
confidence = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:source:DetectAnomalyResult' :: Maybe ImageSource
source = Maybe ImageSource
forall a. Maybe a
Prelude.Nothing
    }

-- | True if the image contains an anomaly, otherwise false.
detectAnomalyResult_isAnomalous :: Lens.Lens' DetectAnomalyResult (Prelude.Maybe Prelude.Bool)
detectAnomalyResult_isAnomalous :: (Maybe Bool -> f (Maybe Bool))
-> DetectAnomalyResult -> f DetectAnomalyResult
detectAnomalyResult_isAnomalous = (DetectAnomalyResult -> Maybe Bool)
-> (DetectAnomalyResult -> Maybe Bool -> DetectAnomalyResult)
-> Lens
     DetectAnomalyResult DetectAnomalyResult (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectAnomalyResult' {Maybe Bool
isAnomalous :: Maybe Bool
$sel:isAnomalous:DetectAnomalyResult' :: DetectAnomalyResult -> Maybe Bool
isAnomalous} -> Maybe Bool
isAnomalous) (\s :: DetectAnomalyResult
s@DetectAnomalyResult' {} Maybe Bool
a -> DetectAnomalyResult
s {$sel:isAnomalous:DetectAnomalyResult' :: Maybe Bool
isAnomalous = Maybe Bool
a} :: DetectAnomalyResult)

-- | The confidence that Amazon Lookout for Vision has in the accuracy of the
-- prediction.
detectAnomalyResult_confidence :: Lens.Lens' DetectAnomalyResult (Prelude.Maybe Prelude.Double)
detectAnomalyResult_confidence :: (Maybe Double -> f (Maybe Double))
-> DetectAnomalyResult -> f DetectAnomalyResult
detectAnomalyResult_confidence = (DetectAnomalyResult -> Maybe Double)
-> (DetectAnomalyResult -> Maybe Double -> DetectAnomalyResult)
-> Lens
     DetectAnomalyResult
     DetectAnomalyResult
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectAnomalyResult' {Maybe Double
confidence :: Maybe Double
$sel:confidence:DetectAnomalyResult' :: DetectAnomalyResult -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: DetectAnomalyResult
s@DetectAnomalyResult' {} Maybe Double
a -> DetectAnomalyResult
s {$sel:confidence:DetectAnomalyResult' :: Maybe Double
confidence = Maybe Double
a} :: DetectAnomalyResult)

-- | The source of the image that was analyzed. @direct@ means that the
-- images was supplied from the local computer. No other values are
-- supported.
detectAnomalyResult_source :: Lens.Lens' DetectAnomalyResult (Prelude.Maybe ImageSource)
detectAnomalyResult_source :: (Maybe ImageSource -> f (Maybe ImageSource))
-> DetectAnomalyResult -> f DetectAnomalyResult
detectAnomalyResult_source = (DetectAnomalyResult -> Maybe ImageSource)
-> (DetectAnomalyResult
    -> Maybe ImageSource -> DetectAnomalyResult)
-> Lens
     DetectAnomalyResult
     DetectAnomalyResult
     (Maybe ImageSource)
     (Maybe ImageSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectAnomalyResult' {Maybe ImageSource
source :: Maybe ImageSource
$sel:source:DetectAnomalyResult' :: DetectAnomalyResult -> Maybe ImageSource
source} -> Maybe ImageSource
source) (\s :: DetectAnomalyResult
s@DetectAnomalyResult' {} Maybe ImageSource
a -> DetectAnomalyResult
s {$sel:source:DetectAnomalyResult' :: Maybe ImageSource
source = Maybe ImageSource
a} :: DetectAnomalyResult)

instance Core.FromJSON DetectAnomalyResult where
  parseJSON :: Value -> Parser DetectAnomalyResult
parseJSON =
    String
-> (Object -> Parser DetectAnomalyResult)
-> Value
-> Parser DetectAnomalyResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DetectAnomalyResult"
      ( \Object
x ->
          Maybe Bool
-> Maybe Double -> Maybe ImageSource -> DetectAnomalyResult
DetectAnomalyResult'
            (Maybe Bool
 -> Maybe Double -> Maybe ImageSource -> DetectAnomalyResult)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Double -> Maybe ImageSource -> DetectAnomalyResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IsAnomalous")
            Parser (Maybe Double -> Maybe ImageSource -> DetectAnomalyResult)
-> Parser (Maybe Double)
-> Parser (Maybe ImageSource -> DetectAnomalyResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Confidence")
            Parser (Maybe ImageSource -> DetectAnomalyResult)
-> Parser (Maybe ImageSource) -> Parser DetectAnomalyResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ImageSource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Source")
      )

instance Prelude.Hashable DetectAnomalyResult

instance Prelude.NFData DetectAnomalyResult