{-# 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.LookoutMetrics.Types.DetectedField
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LookoutMetrics.Types.DetectedField where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LookoutMetrics.Types.AttributeValue
import Amazonka.LookoutMetrics.Types.Confidence
import qualified Amazonka.Prelude as Prelude

-- | An inferred field.
--
-- /See:/ 'newDetectedField' smart constructor.
data DetectedField = DetectedField'
  { -- | The field\'s confidence.
    DetectedField -> Maybe Confidence
confidence :: Prelude.Maybe Confidence,
    -- | The field\'s message.
    DetectedField -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The field\'s value.
    DetectedField -> Maybe AttributeValue
value :: Prelude.Maybe AttributeValue
  }
  deriving (DetectedField -> DetectedField -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectedField -> DetectedField -> Bool
$c/= :: DetectedField -> DetectedField -> Bool
== :: DetectedField -> DetectedField -> Bool
$c== :: DetectedField -> DetectedField -> Bool
Prelude.Eq, ReadPrec [DetectedField]
ReadPrec DetectedField
Int -> ReadS DetectedField
ReadS [DetectedField]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectedField]
$creadListPrec :: ReadPrec [DetectedField]
readPrec :: ReadPrec DetectedField
$creadPrec :: ReadPrec DetectedField
readList :: ReadS [DetectedField]
$creadList :: ReadS [DetectedField]
readsPrec :: Int -> ReadS DetectedField
$creadsPrec :: Int -> ReadS DetectedField
Prelude.Read, Int -> DetectedField -> ShowS
[DetectedField] -> ShowS
DetectedField -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectedField] -> ShowS
$cshowList :: [DetectedField] -> ShowS
show :: DetectedField -> String
$cshow :: DetectedField -> String
showsPrec :: Int -> DetectedField -> ShowS
$cshowsPrec :: Int -> DetectedField -> ShowS
Prelude.Show, forall x. Rep DetectedField x -> DetectedField
forall x. DetectedField -> Rep DetectedField x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectedField x -> DetectedField
$cfrom :: forall x. DetectedField -> Rep DetectedField x
Prelude.Generic)

-- |
-- Create a value of 'DetectedField' 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:
--
-- 'confidence', 'detectedField_confidence' - The field\'s confidence.
--
-- 'message', 'detectedField_message' - The field\'s message.
--
-- 'value', 'detectedField_value' - The field\'s value.
newDetectedField ::
  DetectedField
newDetectedField :: DetectedField
newDetectedField =
  DetectedField'
    { $sel:confidence:DetectedField' :: Maybe Confidence
confidence = forall a. Maybe a
Prelude.Nothing,
      $sel:message:DetectedField' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:value:DetectedField' :: Maybe AttributeValue
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The field\'s confidence.
detectedField_confidence :: Lens.Lens' DetectedField (Prelude.Maybe Confidence)
detectedField_confidence :: Lens' DetectedField (Maybe Confidence)
detectedField_confidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectedField' {Maybe Confidence
confidence :: Maybe Confidence
$sel:confidence:DetectedField' :: DetectedField -> Maybe Confidence
confidence} -> Maybe Confidence
confidence) (\s :: DetectedField
s@DetectedField' {} Maybe Confidence
a -> DetectedField
s {$sel:confidence:DetectedField' :: Maybe Confidence
confidence = Maybe Confidence
a} :: DetectedField)

-- | The field\'s message.
detectedField_message :: Lens.Lens' DetectedField (Prelude.Maybe Prelude.Text)
detectedField_message :: Lens' DetectedField (Maybe Text)
detectedField_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectedField' {Maybe Text
message :: Maybe Text
$sel:message:DetectedField' :: DetectedField -> Maybe Text
message} -> Maybe Text
message) (\s :: DetectedField
s@DetectedField' {} Maybe Text
a -> DetectedField
s {$sel:message:DetectedField' :: Maybe Text
message = Maybe Text
a} :: DetectedField)

-- | The field\'s value.
detectedField_value :: Lens.Lens' DetectedField (Prelude.Maybe AttributeValue)
detectedField_value :: Lens' DetectedField (Maybe AttributeValue)
detectedField_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectedField' {Maybe AttributeValue
value :: Maybe AttributeValue
$sel:value:DetectedField' :: DetectedField -> Maybe AttributeValue
value} -> Maybe AttributeValue
value) (\s :: DetectedField
s@DetectedField' {} Maybe AttributeValue
a -> DetectedField
s {$sel:value:DetectedField' :: Maybe AttributeValue
value = Maybe AttributeValue
a} :: DetectedField)

instance Data.FromJSON DetectedField where
  parseJSON :: Value -> Parser DetectedField
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DetectedField"
      ( \Object
x ->
          Maybe Confidence
-> Maybe Text -> Maybe AttributeValue -> DetectedField
DetectedField'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Confidence")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Message")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Value")
      )

instance Prelude.Hashable DetectedField where
  hashWithSalt :: Int -> DetectedField -> Int
hashWithSalt Int
_salt DetectedField' {Maybe Text
Maybe AttributeValue
Maybe Confidence
value :: Maybe AttributeValue
message :: Maybe Text
confidence :: Maybe Confidence
$sel:value:DetectedField' :: DetectedField -> Maybe AttributeValue
$sel:message:DetectedField' :: DetectedField -> Maybe Text
$sel:confidence:DetectedField' :: DetectedField -> Maybe Confidence
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Confidence
confidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttributeValue
value

instance Prelude.NFData DetectedField where
  rnf :: DetectedField -> ()
rnf DetectedField' {Maybe Text
Maybe AttributeValue
Maybe Confidence
value :: Maybe AttributeValue
message :: Maybe Text
confidence :: Maybe Confidence
$sel:value:DetectedField' :: DetectedField -> Maybe AttributeValue
$sel:message:DetectedField' :: DetectedField -> Maybe Text
$sel:confidence:DetectedField' :: DetectedField -> Maybe Confidence
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Confidence
confidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AttributeValue
value