{-# 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.WAFV2.Types.LabelNameCondition
-- 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.WAFV2.Types.LabelNameCondition 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

-- | A single label name condition for a Condition in a logging filter.
--
-- /See:/ 'newLabelNameCondition' smart constructor.
data LabelNameCondition = LabelNameCondition'
  { -- | The label name that a log record must contain in order to meet the
    -- condition. This must be a fully qualified label name. Fully qualified
    -- labels have a prefix, optional namespaces, and label name. The prefix
    -- identifies the rule group or web ACL context of the rule that added the
    -- label.
    LabelNameCondition -> Text
labelName :: Prelude.Text
  }
  deriving (LabelNameCondition -> LabelNameCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LabelNameCondition -> LabelNameCondition -> Bool
$c/= :: LabelNameCondition -> LabelNameCondition -> Bool
== :: LabelNameCondition -> LabelNameCondition -> Bool
$c== :: LabelNameCondition -> LabelNameCondition -> Bool
Prelude.Eq, ReadPrec [LabelNameCondition]
ReadPrec LabelNameCondition
Int -> ReadS LabelNameCondition
ReadS [LabelNameCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LabelNameCondition]
$creadListPrec :: ReadPrec [LabelNameCondition]
readPrec :: ReadPrec LabelNameCondition
$creadPrec :: ReadPrec LabelNameCondition
readList :: ReadS [LabelNameCondition]
$creadList :: ReadS [LabelNameCondition]
readsPrec :: Int -> ReadS LabelNameCondition
$creadsPrec :: Int -> ReadS LabelNameCondition
Prelude.Read, Int -> LabelNameCondition -> ShowS
[LabelNameCondition] -> ShowS
LabelNameCondition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LabelNameCondition] -> ShowS
$cshowList :: [LabelNameCondition] -> ShowS
show :: LabelNameCondition -> String
$cshow :: LabelNameCondition -> String
showsPrec :: Int -> LabelNameCondition -> ShowS
$cshowsPrec :: Int -> LabelNameCondition -> ShowS
Prelude.Show, forall x. Rep LabelNameCondition x -> LabelNameCondition
forall x. LabelNameCondition -> Rep LabelNameCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LabelNameCondition x -> LabelNameCondition
$cfrom :: forall x. LabelNameCondition -> Rep LabelNameCondition x
Prelude.Generic)

-- |
-- Create a value of 'LabelNameCondition' 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:
--
-- 'labelName', 'labelNameCondition_labelName' - The label name that a log record must contain in order to meet the
-- condition. This must be a fully qualified label name. Fully qualified
-- labels have a prefix, optional namespaces, and label name. The prefix
-- identifies the rule group or web ACL context of the rule that added the
-- label.
newLabelNameCondition ::
  -- | 'labelName'
  Prelude.Text ->
  LabelNameCondition
newLabelNameCondition :: Text -> LabelNameCondition
newLabelNameCondition Text
pLabelName_ =
  LabelNameCondition' {$sel:labelName:LabelNameCondition' :: Text
labelName = Text
pLabelName_}

-- | The label name that a log record must contain in order to meet the
-- condition. This must be a fully qualified label name. Fully qualified
-- labels have a prefix, optional namespaces, and label name. The prefix
-- identifies the rule group or web ACL context of the rule that added the
-- label.
labelNameCondition_labelName :: Lens.Lens' LabelNameCondition Prelude.Text
labelNameCondition_labelName :: Lens' LabelNameCondition Text
labelNameCondition_labelName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelNameCondition' {Text
labelName :: Text
$sel:labelName:LabelNameCondition' :: LabelNameCondition -> Text
labelName} -> Text
labelName) (\s :: LabelNameCondition
s@LabelNameCondition' {} Text
a -> LabelNameCondition
s {$sel:labelName:LabelNameCondition' :: Text
labelName = Text
a} :: LabelNameCondition)

instance Data.FromJSON LabelNameCondition where
  parseJSON :: Value -> Parser LabelNameCondition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LabelNameCondition"
      ( \Object
x ->
          Text -> LabelNameCondition
LabelNameCondition'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"LabelName")
      )

instance Prelude.Hashable LabelNameCondition where
  hashWithSalt :: Int -> LabelNameCondition -> Int
hashWithSalt Int
_salt LabelNameCondition' {Text
labelName :: Text
$sel:labelName:LabelNameCondition' :: LabelNameCondition -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
labelName

instance Prelude.NFData LabelNameCondition where
  rnf :: LabelNameCondition -> ()
rnf LabelNameCondition' {Text
labelName :: Text
$sel:labelName:LabelNameCondition' :: LabelNameCondition -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
labelName

instance Data.ToJSON LabelNameCondition where
  toJSON :: LabelNameCondition -> Value
toJSON LabelNameCondition' {Text
labelName :: Text
$sel:labelName:LabelNameCondition' :: LabelNameCondition -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"LabelName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
labelName)]
      )