{-# 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.GuardDuty.Types.ScanConditionPair
-- 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.GuardDuty.Types.ScanConditionPair 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

-- | Represents key, value pair to be matched against given resource
-- property.
--
-- /See:/ 'newScanConditionPair' smart constructor.
data ScanConditionPair = ScanConditionPair'
  { -- | Represents optional /value/ ____ in the map condition. If not specified,
    -- only /key/ ____ will be matched.
    ScanConditionPair -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | Represents /key/ ____ in the map condition.
    ScanConditionPair -> Text
key :: Prelude.Text
  }
  deriving (ScanConditionPair -> ScanConditionPair -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScanConditionPair -> ScanConditionPair -> Bool
$c/= :: ScanConditionPair -> ScanConditionPair -> Bool
== :: ScanConditionPair -> ScanConditionPair -> Bool
$c== :: ScanConditionPair -> ScanConditionPair -> Bool
Prelude.Eq, ReadPrec [ScanConditionPair]
ReadPrec ScanConditionPair
Int -> ReadS ScanConditionPair
ReadS [ScanConditionPair]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScanConditionPair]
$creadListPrec :: ReadPrec [ScanConditionPair]
readPrec :: ReadPrec ScanConditionPair
$creadPrec :: ReadPrec ScanConditionPair
readList :: ReadS [ScanConditionPair]
$creadList :: ReadS [ScanConditionPair]
readsPrec :: Int -> ReadS ScanConditionPair
$creadsPrec :: Int -> ReadS ScanConditionPair
Prelude.Read, Int -> ScanConditionPair -> ShowS
[ScanConditionPair] -> ShowS
ScanConditionPair -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScanConditionPair] -> ShowS
$cshowList :: [ScanConditionPair] -> ShowS
show :: ScanConditionPair -> String
$cshow :: ScanConditionPair -> String
showsPrec :: Int -> ScanConditionPair -> ShowS
$cshowsPrec :: Int -> ScanConditionPair -> ShowS
Prelude.Show, forall x. Rep ScanConditionPair x -> ScanConditionPair
forall x. ScanConditionPair -> Rep ScanConditionPair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScanConditionPair x -> ScanConditionPair
$cfrom :: forall x. ScanConditionPair -> Rep ScanConditionPair x
Prelude.Generic)

-- |
-- Create a value of 'ScanConditionPair' 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:
--
-- 'value', 'scanConditionPair_value' - Represents optional /value/ ____ in the map condition. If not specified,
-- only /key/ ____ will be matched.
--
-- 'key', 'scanConditionPair_key' - Represents /key/ ____ in the map condition.
newScanConditionPair ::
  -- | 'key'
  Prelude.Text ->
  ScanConditionPair
newScanConditionPair :: Text -> ScanConditionPair
newScanConditionPair Text
pKey_ =
  ScanConditionPair'
    { $sel:value:ScanConditionPair' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing,
      $sel:key:ScanConditionPair' :: Text
key = Text
pKey_
    }

-- | Represents optional /value/ ____ in the map condition. If not specified,
-- only /key/ ____ will be matched.
scanConditionPair_value :: Lens.Lens' ScanConditionPair (Prelude.Maybe Prelude.Text)
scanConditionPair_value :: Lens' ScanConditionPair (Maybe Text)
scanConditionPair_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScanConditionPair' {Maybe Text
value :: Maybe Text
$sel:value:ScanConditionPair' :: ScanConditionPair -> Maybe Text
value} -> Maybe Text
value) (\s :: ScanConditionPair
s@ScanConditionPair' {} Maybe Text
a -> ScanConditionPair
s {$sel:value:ScanConditionPair' :: Maybe Text
value = Maybe Text
a} :: ScanConditionPair)

-- | Represents /key/ ____ in the map condition.
scanConditionPair_key :: Lens.Lens' ScanConditionPair Prelude.Text
scanConditionPair_key :: Lens' ScanConditionPair Text
scanConditionPair_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScanConditionPair' {Text
key :: Text
$sel:key:ScanConditionPair' :: ScanConditionPair -> Text
key} -> Text
key) (\s :: ScanConditionPair
s@ScanConditionPair' {} Text
a -> ScanConditionPair
s {$sel:key:ScanConditionPair' :: Text
key = Text
a} :: ScanConditionPair)

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

instance Prelude.Hashable ScanConditionPair where
  hashWithSalt :: Int -> ScanConditionPair -> Int
hashWithSalt Int
_salt ScanConditionPair' {Maybe Text
Text
key :: Text
value :: Maybe Text
$sel:key:ScanConditionPair' :: ScanConditionPair -> Text
$sel:value:ScanConditionPair' :: ScanConditionPair -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key

instance Prelude.NFData ScanConditionPair where
  rnf :: ScanConditionPair -> ()
rnf ScanConditionPair' {Maybe Text
Text
key :: Text
value :: Maybe Text
$sel:key:ScanConditionPair' :: ScanConditionPair -> Text
$sel:value:ScanConditionPair' :: ScanConditionPair -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
key

instance Data.ToJSON ScanConditionPair where
  toJSON :: ScanConditionPair -> Value
toJSON ScanConditionPair' {Maybe Text
Text
key :: Text
value :: Maybe Text
$sel:key:ScanConditionPair' :: ScanConditionPair -> Text
$sel:value:ScanConditionPair' :: ScanConditionPair -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
value,
            forall a. a -> Maybe a
Prelude.Just (Key
"key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key)
          ]
      )