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

import Amazonka.CloudTrail.Types.LookupAttributeKey
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(LookupAttribute -> LookupAttribute -> Bool)
-> (LookupAttribute -> LookupAttribute -> Bool)
-> Eq LookupAttribute
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]
(Int -> ReadS LookupAttribute)
-> ReadS [LookupAttribute]
-> ReadPrec LookupAttribute
-> ReadPrec [LookupAttribute]
-> Read 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
(Int -> LookupAttribute -> ShowS)
-> (LookupAttribute -> String)
-> ([LookupAttribute] -> ShowS)
-> Show LookupAttribute
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. LookupAttribute -> Rep LookupAttribute x)
-> (forall x. Rep LookupAttribute x -> LookupAttribute)
-> Generic LookupAttribute
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' :: LookupAttributeKey -> Text -> LookupAttribute
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 :: (LookupAttributeKey -> f LookupAttributeKey)
-> LookupAttribute -> f LookupAttribute
lookupAttribute_attributeKey = (LookupAttribute -> LookupAttributeKey)
-> (LookupAttribute -> LookupAttributeKey -> LookupAttribute)
-> Lens
     LookupAttribute
     LookupAttribute
     LookupAttributeKey
     LookupAttributeKey
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 :: (Text -> f Text) -> LookupAttribute -> f LookupAttribute
lookupAttribute_attributeValue = (LookupAttribute -> Text)
-> (LookupAttribute -> Text -> LookupAttribute)
-> Lens LookupAttribute LookupAttribute Text Text
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

instance Prelude.NFData LookupAttribute

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AttributeKey" Text -> LookupAttributeKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LookupAttributeKey
attributeKey),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AttributeValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
attributeValue)
          ]
      )