{-# 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.ScanCondition
-- 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.ScanCondition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GuardDuty.Types.ScanConditionPair
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the condition.
--
-- /See:/ 'newScanCondition' smart constructor.
data ScanCondition = ScanCondition'
  { -- | Represents an /mapEqual/ ____ condition to be applied to a single field
    -- when triggering for malware scan.
    ScanCondition -> [ScanConditionPair]
mapEquals :: [ScanConditionPair]
  }
  deriving (ScanCondition -> ScanCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScanCondition -> ScanCondition -> Bool
$c/= :: ScanCondition -> ScanCondition -> Bool
== :: ScanCondition -> ScanCondition -> Bool
$c== :: ScanCondition -> ScanCondition -> Bool
Prelude.Eq, ReadPrec [ScanCondition]
ReadPrec ScanCondition
Int -> ReadS ScanCondition
ReadS [ScanCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScanCondition]
$creadListPrec :: ReadPrec [ScanCondition]
readPrec :: ReadPrec ScanCondition
$creadPrec :: ReadPrec ScanCondition
readList :: ReadS [ScanCondition]
$creadList :: ReadS [ScanCondition]
readsPrec :: Int -> ReadS ScanCondition
$creadsPrec :: Int -> ReadS ScanCondition
Prelude.Read, Int -> ScanCondition -> ShowS
[ScanCondition] -> ShowS
ScanCondition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScanCondition] -> ShowS
$cshowList :: [ScanCondition] -> ShowS
show :: ScanCondition -> String
$cshow :: ScanCondition -> String
showsPrec :: Int -> ScanCondition -> ShowS
$cshowsPrec :: Int -> ScanCondition -> ShowS
Prelude.Show, forall x. Rep ScanCondition x -> ScanCondition
forall x. ScanCondition -> Rep ScanCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScanCondition x -> ScanCondition
$cfrom :: forall x. ScanCondition -> Rep ScanCondition x
Prelude.Generic)

-- |
-- Create a value of 'ScanCondition' 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:
--
-- 'mapEquals', 'scanCondition_mapEquals' - Represents an /mapEqual/ ____ condition to be applied to a single field
-- when triggering for malware scan.
newScanCondition ::
  ScanCondition
newScanCondition :: ScanCondition
newScanCondition =
  ScanCondition' {$sel:mapEquals:ScanCondition' :: [ScanConditionPair]
mapEquals = forall a. Monoid a => a
Prelude.mempty}

-- | Represents an /mapEqual/ ____ condition to be applied to a single field
-- when triggering for malware scan.
scanCondition_mapEquals :: Lens.Lens' ScanCondition [ScanConditionPair]
scanCondition_mapEquals :: Lens' ScanCondition [ScanConditionPair]
scanCondition_mapEquals = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScanCondition' {[ScanConditionPair]
mapEquals :: [ScanConditionPair]
$sel:mapEquals:ScanCondition' :: ScanCondition -> [ScanConditionPair]
mapEquals} -> [ScanConditionPair]
mapEquals) (\s :: ScanCondition
s@ScanCondition' {} [ScanConditionPair]
a -> ScanCondition
s {$sel:mapEquals:ScanCondition' :: [ScanConditionPair]
mapEquals = [ScanConditionPair]
a} :: ScanCondition) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ScanCondition where
  parseJSON :: Value -> Parser ScanCondition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ScanCondition"
      ( \Object
x ->
          [ScanConditionPair] -> ScanCondition
ScanCondition'
            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
"mapEquals" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ScanCondition where
  hashWithSalt :: Int -> ScanCondition -> Int
hashWithSalt Int
_salt ScanCondition' {[ScanConditionPair]
mapEquals :: [ScanConditionPair]
$sel:mapEquals:ScanCondition' :: ScanCondition -> [ScanConditionPair]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ScanConditionPair]
mapEquals

instance Prelude.NFData ScanCondition where
  rnf :: ScanCondition -> ()
rnf ScanCondition' {[ScanConditionPair]
mapEquals :: [ScanConditionPair]
$sel:mapEquals:ScanCondition' :: ScanCondition -> [ScanConditionPair]
..} = forall a. NFData a => a -> ()
Prelude.rnf [ScanConditionPair]
mapEquals

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