{-# 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.LogGroupField
-- 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.LogGroupField where

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

-- | The fields contained in log events found by a @GetLogGroupFields@
-- operation, along with the percentage of queried log events in which each
-- field appears.
--
-- /See:/ 'newLogGroupField' smart constructor.
data LogGroupField = LogGroupField'
  { -- | The percentage of log events queried that contained the field.
    LogGroupField -> Maybe Natural
percent :: Prelude.Maybe Prelude.Natural,
    -- | The name of a log field.
    LogGroupField -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (LogGroupField -> LogGroupField -> Bool
(LogGroupField -> LogGroupField -> Bool)
-> (LogGroupField -> LogGroupField -> Bool) -> Eq LogGroupField
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogGroupField -> LogGroupField -> Bool
$c/= :: LogGroupField -> LogGroupField -> Bool
== :: LogGroupField -> LogGroupField -> Bool
$c== :: LogGroupField -> LogGroupField -> Bool
Prelude.Eq, ReadPrec [LogGroupField]
ReadPrec LogGroupField
Int -> ReadS LogGroupField
ReadS [LogGroupField]
(Int -> ReadS LogGroupField)
-> ReadS [LogGroupField]
-> ReadPrec LogGroupField
-> ReadPrec [LogGroupField]
-> Read LogGroupField
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogGroupField]
$creadListPrec :: ReadPrec [LogGroupField]
readPrec :: ReadPrec LogGroupField
$creadPrec :: ReadPrec LogGroupField
readList :: ReadS [LogGroupField]
$creadList :: ReadS [LogGroupField]
readsPrec :: Int -> ReadS LogGroupField
$creadsPrec :: Int -> ReadS LogGroupField
Prelude.Read, Int -> LogGroupField -> ShowS
[LogGroupField] -> ShowS
LogGroupField -> String
(Int -> LogGroupField -> ShowS)
-> (LogGroupField -> String)
-> ([LogGroupField] -> ShowS)
-> Show LogGroupField
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogGroupField] -> ShowS
$cshowList :: [LogGroupField] -> ShowS
show :: LogGroupField -> String
$cshow :: LogGroupField -> String
showsPrec :: Int -> LogGroupField -> ShowS
$cshowsPrec :: Int -> LogGroupField -> ShowS
Prelude.Show, (forall x. LogGroupField -> Rep LogGroupField x)
-> (forall x. Rep LogGroupField x -> LogGroupField)
-> Generic LogGroupField
forall x. Rep LogGroupField x -> LogGroupField
forall x. LogGroupField -> Rep LogGroupField x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogGroupField x -> LogGroupField
$cfrom :: forall x. LogGroupField -> Rep LogGroupField x
Prelude.Generic)

-- |
-- Create a value of 'LogGroupField' 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:
--
-- 'percent', 'logGroupField_percent' - The percentage of log events queried that contained the field.
--
-- 'name', 'logGroupField_name' - The name of a log field.
newLogGroupField ::
  LogGroupField
newLogGroupField :: LogGroupField
newLogGroupField =
  LogGroupField' :: Maybe Natural -> Maybe Text -> LogGroupField
LogGroupField'
    { $sel:percent:LogGroupField' :: Maybe Natural
percent = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:name:LogGroupField' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The percentage of log events queried that contained the field.
logGroupField_percent :: Lens.Lens' LogGroupField (Prelude.Maybe Prelude.Natural)
logGroupField_percent :: (Maybe Natural -> f (Maybe Natural))
-> LogGroupField -> f LogGroupField
logGroupField_percent = (LogGroupField -> Maybe Natural)
-> (LogGroupField -> Maybe Natural -> LogGroupField)
-> Lens LogGroupField LogGroupField (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroupField' {Maybe Natural
percent :: Maybe Natural
$sel:percent:LogGroupField' :: LogGroupField -> Maybe Natural
percent} -> Maybe Natural
percent) (\s :: LogGroupField
s@LogGroupField' {} Maybe Natural
a -> LogGroupField
s {$sel:percent:LogGroupField' :: Maybe Natural
percent = Maybe Natural
a} :: LogGroupField)

-- | The name of a log field.
logGroupField_name :: Lens.Lens' LogGroupField (Prelude.Maybe Prelude.Text)
logGroupField_name :: (Maybe Text -> f (Maybe Text)) -> LogGroupField -> f LogGroupField
logGroupField_name = (LogGroupField -> Maybe Text)
-> (LogGroupField -> Maybe Text -> LogGroupField)
-> Lens LogGroupField LogGroupField (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroupField' {Maybe Text
name :: Maybe Text
$sel:name:LogGroupField' :: LogGroupField -> Maybe Text
name} -> Maybe Text
name) (\s :: LogGroupField
s@LogGroupField' {} Maybe Text
a -> LogGroupField
s {$sel:name:LogGroupField' :: Maybe Text
name = Maybe Text
a} :: LogGroupField)

instance Core.FromJSON LogGroupField where
  parseJSON :: Value -> Parser LogGroupField
parseJSON =
    String
-> (Object -> Parser LogGroupField)
-> Value
-> Parser LogGroupField
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LogGroupField"
      ( \Object
x ->
          Maybe Natural -> Maybe Text -> LogGroupField
LogGroupField'
            (Maybe Natural -> Maybe Text -> LogGroupField)
-> Parser (Maybe Natural) -> Parser (Maybe Text -> LogGroupField)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"percent")
            Parser (Maybe Text -> LogGroupField)
-> Parser (Maybe Text) -> Parser LogGroupField
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
"name")
      )

instance Prelude.Hashable LogGroupField

instance Prelude.NFData LogGroupField