{-# 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.CloudTrail.Types.LookupAttribute
-- 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.CloudTrail.Types.LookupAttribute where

import Amazonka.CloudTrail.Types.LookupAttributeKey
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

-- | Specifies an attribute and value that filter the events returned.
--
-- /See:/ 'newLookupAttribute' smart constructor.
data LookupAttribute = LookupAttribute'
  { -- | Specifies an attribute on which to filter the events returned.
    LookupAttribute -> LookupAttributeKey
attributeKey :: LookupAttributeKey,
    -- | Specifies a value for the specified AttributeKey.
    LookupAttribute -> Text
attributeValue :: Prelude.Text
  }
  deriving (LookupAttribute -> LookupAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LookupAttribute -> LookupAttribute -> Bool
$c/= :: LookupAttribute -> LookupAttribute -> Bool
== :: LookupAttribute -> LookupAttribute -> Bool
$c== :: LookupAttribute -> LookupAttribute -> Bool
Prelude.Eq, ReadPrec [LookupAttribute]
ReadPrec LookupAttribute
Int -> ReadS LookupAttribute
ReadS [LookupAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LookupAttribute]
$creadListPrec :: ReadPrec [LookupAttribute]
readPrec :: ReadPrec LookupAttribute
$creadPrec :: ReadPrec LookupAttribute
readList :: ReadS [LookupAttribute]
$creadList :: ReadS [LookupAttribute]
readsPrec :: Int -> ReadS LookupAttribute
$creadsPrec :: Int -> ReadS LookupAttribute
Prelude.Read, Int -> LookupAttribute -> ShowS
[LookupAttribute] -> ShowS
LookupAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LookupAttribute] -> ShowS
$cshowList :: [LookupAttribute] -> ShowS
show :: LookupAttribute -> String
$cshow :: LookupAttribute -> String
showsPrec :: Int -> LookupAttribute -> ShowS
$cshowsPrec :: Int -> LookupAttribute -> ShowS
Prelude.Show, forall x. Rep LookupAttribute x -> LookupAttribute
forall x. LookupAttribute -> Rep LookupAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LookupAttribute x -> LookupAttribute
$cfrom :: forall x. LookupAttribute -> Rep LookupAttribute x
Prelude.Generic)

-- |
-- Create a value of 'LookupAttribute' 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:
--
-- 'attributeKey', 'lookupAttribute_attributeKey' - Specifies an attribute on which to filter the events returned.
--
-- 'attributeValue', 'lookupAttribute_attributeValue' - Specifies a value for the specified AttributeKey.
newLookupAttribute ::
  -- | 'attributeKey'
  LookupAttributeKey ->
  -- | 'attributeValue'
  Prelude.Text ->
  LookupAttribute
newLookupAttribute :: LookupAttributeKey -> Text -> LookupAttribute
newLookupAttribute LookupAttributeKey
pAttributeKey_ Text
pAttributeValue_ =
  LookupAttribute'
    { $sel:attributeKey:LookupAttribute' :: LookupAttributeKey
attributeKey = LookupAttributeKey
pAttributeKey_,
      $sel:attributeValue:LookupAttribute' :: Text
attributeValue = Text
pAttributeValue_
    }

-- | Specifies an attribute on which to filter the events returned.
lookupAttribute_attributeKey :: Lens.Lens' LookupAttribute LookupAttributeKey
lookupAttribute_attributeKey :: Lens' LookupAttribute LookupAttributeKey
lookupAttribute_attributeKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LookupAttribute' {LookupAttributeKey
attributeKey :: LookupAttributeKey
$sel:attributeKey:LookupAttribute' :: LookupAttribute -> LookupAttributeKey
attributeKey} -> LookupAttributeKey
attributeKey) (\s :: LookupAttribute
s@LookupAttribute' {} LookupAttributeKey
a -> LookupAttribute
s {$sel:attributeKey:LookupAttribute' :: LookupAttributeKey
attributeKey = LookupAttributeKey
a} :: LookupAttribute)

-- | Specifies a value for the specified AttributeKey.
lookupAttribute_attributeValue :: Lens.Lens' LookupAttribute Prelude.Text
lookupAttribute_attributeValue :: Lens' LookupAttribute Text
lookupAttribute_attributeValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LookupAttribute' {Text
attributeValue :: Text
$sel:attributeValue:LookupAttribute' :: LookupAttribute -> Text
attributeValue} -> Text
attributeValue) (\s :: LookupAttribute
s@LookupAttribute' {} Text
a -> LookupAttribute
s {$sel:attributeValue:LookupAttribute' :: Text
attributeValue = Text
a} :: LookupAttribute)

instance Prelude.Hashable LookupAttribute where
  hashWithSalt :: Int -> LookupAttribute -> Int
hashWithSalt Int
_salt LookupAttribute' {Text
LookupAttributeKey
attributeValue :: Text
attributeKey :: LookupAttributeKey
$sel:attributeValue:LookupAttribute' :: LookupAttribute -> Text
$sel:attributeKey:LookupAttribute' :: LookupAttribute -> LookupAttributeKey
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LookupAttributeKey
attributeKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
attributeValue

instance Prelude.NFData LookupAttribute where
  rnf :: LookupAttribute -> ()
rnf LookupAttribute' {Text
LookupAttributeKey
attributeValue :: Text
attributeKey :: LookupAttributeKey
$sel:attributeValue:LookupAttribute' :: LookupAttribute -> Text
$sel:attributeKey:LookupAttribute' :: LookupAttribute -> LookupAttributeKey
..} =
    forall a. NFData a => a -> ()
Prelude.rnf LookupAttributeKey
attributeKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
attributeValue

instance Data.ToJSON LookupAttribute where
  toJSON :: LookupAttribute -> Value
toJSON LookupAttribute' {Text
LookupAttributeKey
attributeValue :: Text
attributeKey :: LookupAttributeKey
$sel:attributeValue:LookupAttribute' :: LookupAttribute -> Text
$sel:attributeKey:LookupAttribute' :: LookupAttribute -> LookupAttributeKey
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"AttributeKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= LookupAttributeKey
attributeKey),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AttributeValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
attributeValue)
          ]
      )