{-# 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.CloudWatchLogs.Types.ResultField
-- 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.CloudWatchLogs.Types.ResultField where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Contains one field from one log event returned by a CloudWatch Logs
-- Insights query, along with the value of that field.
--
-- For more information about the fields that are generated by CloudWatch
-- logs, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_AnalyzeLogData-discoverable-fields.html Supported Logs and Discovered Fields>.
--
-- /See:/ 'newResultField' smart constructor.
data ResultField = ResultField'
  { -- | The log event field.
    ResultField -> Maybe Text
field :: Prelude.Maybe Prelude.Text,
    -- | The value of this field.
    ResultField -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (ResultField -> ResultField -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultField -> ResultField -> Bool
$c/= :: ResultField -> ResultField -> Bool
== :: ResultField -> ResultField -> Bool
$c== :: ResultField -> ResultField -> Bool
Prelude.Eq, ReadPrec [ResultField]
ReadPrec ResultField
Int -> ReadS ResultField
ReadS [ResultField]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResultField]
$creadListPrec :: ReadPrec [ResultField]
readPrec :: ReadPrec ResultField
$creadPrec :: ReadPrec ResultField
readList :: ReadS [ResultField]
$creadList :: ReadS [ResultField]
readsPrec :: Int -> ReadS ResultField
$creadsPrec :: Int -> ReadS ResultField
Prelude.Read, Int -> ResultField -> ShowS
[ResultField] -> ShowS
ResultField -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultField] -> ShowS
$cshowList :: [ResultField] -> ShowS
show :: ResultField -> String
$cshow :: ResultField -> String
showsPrec :: Int -> ResultField -> ShowS
$cshowsPrec :: Int -> ResultField -> ShowS
Prelude.Show, forall x. Rep ResultField x -> ResultField
forall x. ResultField -> Rep ResultField x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultField x -> ResultField
$cfrom :: forall x. ResultField -> Rep ResultField x
Prelude.Generic)

-- |
-- Create a value of 'ResultField' 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:
--
-- 'field', 'resultField_field' - The log event field.
--
-- 'value', 'resultField_value' - The value of this field.
newResultField ::
  ResultField
newResultField :: ResultField
newResultField =
  ResultField'
    { $sel:field:ResultField' :: Maybe Text
field = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ResultField' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The log event field.
resultField_field :: Lens.Lens' ResultField (Prelude.Maybe Prelude.Text)
resultField_field :: Lens' ResultField (Maybe Text)
resultField_field = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultField' {Maybe Text
field :: Maybe Text
$sel:field:ResultField' :: ResultField -> Maybe Text
field} -> Maybe Text
field) (\s :: ResultField
s@ResultField' {} Maybe Text
a -> ResultField
s {$sel:field:ResultField' :: Maybe Text
field = Maybe Text
a} :: ResultField)

-- | The value of this field.
resultField_value :: Lens.Lens' ResultField (Prelude.Maybe Prelude.Text)
resultField_value :: Lens' ResultField (Maybe Text)
resultField_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultField' {Maybe Text
value :: Maybe Text
$sel:value:ResultField' :: ResultField -> Maybe Text
value} -> Maybe Text
value) (\s :: ResultField
s@ResultField' {} Maybe Text
a -> ResultField
s {$sel:value:ResultField' :: Maybe Text
value = Maybe Text
a} :: ResultField)

instance Data.FromJSON ResultField where
  parseJSON :: Value -> Parser ResultField
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResultField"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ResultField
ResultField'
            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
"field")
            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 ResultField where
  hashWithSalt :: Int -> ResultField -> Int
hashWithSalt Int
_salt ResultField' {Maybe Text
value :: Maybe Text
field :: Maybe Text
$sel:value:ResultField' :: ResultField -> Maybe Text
$sel:field:ResultField' :: ResultField -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
field
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData ResultField where
  rnf :: ResultField -> ()
rnf ResultField' {Maybe Text
value :: Maybe Text
field :: Maybe Text
$sel:value:ResultField' :: ResultField -> Maybe Text
$sel:field:ResultField' :: ResultField -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
field seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value