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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ResultField -> ResultField -> Bool)
-> (ResultField -> ResultField -> Bool) -> Eq ResultField
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]
(Int -> ReadS ResultField)
-> ReadS [ResultField]
-> ReadPrec ResultField
-> ReadPrec [ResultField]
-> Read 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
(Int -> ResultField -> ShowS)
-> (ResultField -> String)
-> ([ResultField] -> ShowS)
-> Show ResultField
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. ResultField -> Rep ResultField x)
-> (forall x. Rep ResultField x -> ResultField)
-> Generic ResultField
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' :: Maybe Text -> Maybe Text -> ResultField
ResultField'
    { $sel:field:ResultField' :: Maybe Text
field = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:value:ResultField' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The log event field.
resultField_field :: Lens.Lens' ResultField (Prelude.Maybe Prelude.Text)
resultField_field :: (Maybe Text -> f (Maybe Text)) -> ResultField -> f ResultField
resultField_field = (ResultField -> Maybe Text)
-> (ResultField -> Maybe Text -> ResultField)
-> Lens ResultField ResultField (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> ResultField -> f ResultField
resultField_value = (ResultField -> Maybe Text)
-> (ResultField -> Maybe Text -> ResultField)
-> Lens ResultField ResultField (Maybe Text) (Maybe Text)
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 Core.FromJSON ResultField where
  parseJSON :: Value -> Parser ResultField
parseJSON =
    String
-> (Object -> Parser ResultField) -> Value -> Parser ResultField
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResultField"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ResultField
ResultField'
            (Maybe Text -> Maybe Text -> ResultField)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ResultField)
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
"field")
            Parser (Maybe Text -> ResultField)
-> Parser (Maybe Text) -> Parser ResultField
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
"value")
      )

instance Prelude.Hashable ResultField

instance Prelude.NFData ResultField