{-# 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.AuditManager.Types.SourceKeyword
-- 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.AuditManager.Types.SourceKeyword where

import Amazonka.AuditManager.Types.KeywordInputType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The keyword to search for in CloudTrail logs, Config rules, Security Hub
-- checks, and Amazon Web Services API names.
--
-- /See:/ 'newSourceKeyword' smart constructor.
data SourceKeyword = SourceKeyword'
  { -- | The method of input for the specified keyword.
    SourceKeyword -> Maybe KeywordInputType
keywordInputType :: Prelude.Maybe KeywordInputType,
    -- | The value of the keyword used to search CloudTrail logs, Config rules,
    -- Security Hub checks, and Amazon Web Services API names when mapping a
    -- control data source.
    SourceKeyword -> Maybe Text
keywordValue :: Prelude.Maybe Prelude.Text
  }
  deriving (SourceKeyword -> SourceKeyword -> Bool
(SourceKeyword -> SourceKeyword -> Bool)
-> (SourceKeyword -> SourceKeyword -> Bool) -> Eq SourceKeyword
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceKeyword -> SourceKeyword -> Bool
$c/= :: SourceKeyword -> SourceKeyword -> Bool
== :: SourceKeyword -> SourceKeyword -> Bool
$c== :: SourceKeyword -> SourceKeyword -> Bool
Prelude.Eq, ReadPrec [SourceKeyword]
ReadPrec SourceKeyword
Int -> ReadS SourceKeyword
ReadS [SourceKeyword]
(Int -> ReadS SourceKeyword)
-> ReadS [SourceKeyword]
-> ReadPrec SourceKeyword
-> ReadPrec [SourceKeyword]
-> Read SourceKeyword
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceKeyword]
$creadListPrec :: ReadPrec [SourceKeyword]
readPrec :: ReadPrec SourceKeyword
$creadPrec :: ReadPrec SourceKeyword
readList :: ReadS [SourceKeyword]
$creadList :: ReadS [SourceKeyword]
readsPrec :: Int -> ReadS SourceKeyword
$creadsPrec :: Int -> ReadS SourceKeyword
Prelude.Read, Int -> SourceKeyword -> ShowS
[SourceKeyword] -> ShowS
SourceKeyword -> String
(Int -> SourceKeyword -> ShowS)
-> (SourceKeyword -> String)
-> ([SourceKeyword] -> ShowS)
-> Show SourceKeyword
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceKeyword] -> ShowS
$cshowList :: [SourceKeyword] -> ShowS
show :: SourceKeyword -> String
$cshow :: SourceKeyword -> String
showsPrec :: Int -> SourceKeyword -> ShowS
$cshowsPrec :: Int -> SourceKeyword -> ShowS
Prelude.Show, (forall x. SourceKeyword -> Rep SourceKeyword x)
-> (forall x. Rep SourceKeyword x -> SourceKeyword)
-> Generic SourceKeyword
forall x. Rep SourceKeyword x -> SourceKeyword
forall x. SourceKeyword -> Rep SourceKeyword x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceKeyword x -> SourceKeyword
$cfrom :: forall x. SourceKeyword -> Rep SourceKeyword x
Prelude.Generic)

-- |
-- Create a value of 'SourceKeyword' 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:
--
-- 'keywordInputType', 'sourceKeyword_keywordInputType' - The method of input for the specified keyword.
--
-- 'keywordValue', 'sourceKeyword_keywordValue' - The value of the keyword used to search CloudTrail logs, Config rules,
-- Security Hub checks, and Amazon Web Services API names when mapping a
-- control data source.
newSourceKeyword ::
  SourceKeyword
newSourceKeyword :: SourceKeyword
newSourceKeyword =
  SourceKeyword' :: Maybe KeywordInputType -> Maybe Text -> SourceKeyword
SourceKeyword'
    { $sel:keywordInputType:SourceKeyword' :: Maybe KeywordInputType
keywordInputType = Maybe KeywordInputType
forall a. Maybe a
Prelude.Nothing,
      $sel:keywordValue:SourceKeyword' :: Maybe Text
keywordValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The method of input for the specified keyword.
sourceKeyword_keywordInputType :: Lens.Lens' SourceKeyword (Prelude.Maybe KeywordInputType)
sourceKeyword_keywordInputType :: (Maybe KeywordInputType -> f (Maybe KeywordInputType))
-> SourceKeyword -> f SourceKeyword
sourceKeyword_keywordInputType = (SourceKeyword -> Maybe KeywordInputType)
-> (SourceKeyword -> Maybe KeywordInputType -> SourceKeyword)
-> Lens
     SourceKeyword
     SourceKeyword
     (Maybe KeywordInputType)
     (Maybe KeywordInputType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceKeyword' {Maybe KeywordInputType
keywordInputType :: Maybe KeywordInputType
$sel:keywordInputType:SourceKeyword' :: SourceKeyword -> Maybe KeywordInputType
keywordInputType} -> Maybe KeywordInputType
keywordInputType) (\s :: SourceKeyword
s@SourceKeyword' {} Maybe KeywordInputType
a -> SourceKeyword
s {$sel:keywordInputType:SourceKeyword' :: Maybe KeywordInputType
keywordInputType = Maybe KeywordInputType
a} :: SourceKeyword)

-- | The value of the keyword used to search CloudTrail logs, Config rules,
-- Security Hub checks, and Amazon Web Services API names when mapping a
-- control data source.
sourceKeyword_keywordValue :: Lens.Lens' SourceKeyword (Prelude.Maybe Prelude.Text)
sourceKeyword_keywordValue :: (Maybe Text -> f (Maybe Text)) -> SourceKeyword -> f SourceKeyword
sourceKeyword_keywordValue = (SourceKeyword -> Maybe Text)
-> (SourceKeyword -> Maybe Text -> SourceKeyword)
-> Lens SourceKeyword SourceKeyword (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceKeyword' {Maybe Text
keywordValue :: Maybe Text
$sel:keywordValue:SourceKeyword' :: SourceKeyword -> Maybe Text
keywordValue} -> Maybe Text
keywordValue) (\s :: SourceKeyword
s@SourceKeyword' {} Maybe Text
a -> SourceKeyword
s {$sel:keywordValue:SourceKeyword' :: Maybe Text
keywordValue = Maybe Text
a} :: SourceKeyword)

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

instance Prelude.Hashable SourceKeyword

instance Prelude.NFData SourceKeyword

instance Core.ToJSON SourceKeyword where
  toJSON :: SourceKeyword -> Value
toJSON SourceKeyword' {Maybe Text
Maybe KeywordInputType
keywordValue :: Maybe Text
keywordInputType :: Maybe KeywordInputType
$sel:keywordValue:SourceKeyword' :: SourceKeyword -> Maybe Text
$sel:keywordInputType:SourceKeyword' :: SourceKeyword -> Maybe KeywordInputType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"keywordInputType" Text -> KeywordInputType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (KeywordInputType -> Pair) -> Maybe KeywordInputType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KeywordInputType
keywordInputType,
            (Text
"keywordValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
keywordValue
          ]
      )