{-# 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.MacieV2.Types.CriteriaBlockForJob
-- 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.MacieV2.Types.CriteriaBlockForJob where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.CriteriaForJob
import qualified Amazonka.Prelude as Prelude

-- | Specifies one or more property- and tag-based conditions that define
-- criteria for including or excluding S3 buckets from a classification
-- job.
--
-- /See:/ 'newCriteriaBlockForJob' smart constructor.
data CriteriaBlockForJob = CriteriaBlockForJob'
  { -- | An array of conditions, one for each condition that determines which
    -- buckets to include or exclude from the job. If you specify more than one
    -- condition, Amazon Macie uses AND logic to join the conditions.
    CriteriaBlockForJob -> Maybe [CriteriaForJob]
and :: Prelude.Maybe [CriteriaForJob]
  }
  deriving (CriteriaBlockForJob -> CriteriaBlockForJob -> Bool
(CriteriaBlockForJob -> CriteriaBlockForJob -> Bool)
-> (CriteriaBlockForJob -> CriteriaBlockForJob -> Bool)
-> Eq CriteriaBlockForJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CriteriaBlockForJob -> CriteriaBlockForJob -> Bool
$c/= :: CriteriaBlockForJob -> CriteriaBlockForJob -> Bool
== :: CriteriaBlockForJob -> CriteriaBlockForJob -> Bool
$c== :: CriteriaBlockForJob -> CriteriaBlockForJob -> Bool
Prelude.Eq, ReadPrec [CriteriaBlockForJob]
ReadPrec CriteriaBlockForJob
Int -> ReadS CriteriaBlockForJob
ReadS [CriteriaBlockForJob]
(Int -> ReadS CriteriaBlockForJob)
-> ReadS [CriteriaBlockForJob]
-> ReadPrec CriteriaBlockForJob
-> ReadPrec [CriteriaBlockForJob]
-> Read CriteriaBlockForJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CriteriaBlockForJob]
$creadListPrec :: ReadPrec [CriteriaBlockForJob]
readPrec :: ReadPrec CriteriaBlockForJob
$creadPrec :: ReadPrec CriteriaBlockForJob
readList :: ReadS [CriteriaBlockForJob]
$creadList :: ReadS [CriteriaBlockForJob]
readsPrec :: Int -> ReadS CriteriaBlockForJob
$creadsPrec :: Int -> ReadS CriteriaBlockForJob
Prelude.Read, Int -> CriteriaBlockForJob -> ShowS
[CriteriaBlockForJob] -> ShowS
CriteriaBlockForJob -> String
(Int -> CriteriaBlockForJob -> ShowS)
-> (CriteriaBlockForJob -> String)
-> ([CriteriaBlockForJob] -> ShowS)
-> Show CriteriaBlockForJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CriteriaBlockForJob] -> ShowS
$cshowList :: [CriteriaBlockForJob] -> ShowS
show :: CriteriaBlockForJob -> String
$cshow :: CriteriaBlockForJob -> String
showsPrec :: Int -> CriteriaBlockForJob -> ShowS
$cshowsPrec :: Int -> CriteriaBlockForJob -> ShowS
Prelude.Show, (forall x. CriteriaBlockForJob -> Rep CriteriaBlockForJob x)
-> (forall x. Rep CriteriaBlockForJob x -> CriteriaBlockForJob)
-> Generic CriteriaBlockForJob
forall x. Rep CriteriaBlockForJob x -> CriteriaBlockForJob
forall x. CriteriaBlockForJob -> Rep CriteriaBlockForJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CriteriaBlockForJob x -> CriteriaBlockForJob
$cfrom :: forall x. CriteriaBlockForJob -> Rep CriteriaBlockForJob x
Prelude.Generic)

-- |
-- Create a value of 'CriteriaBlockForJob' 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:
--
-- 'and', 'criteriaBlockForJob_and' - An array of conditions, one for each condition that determines which
-- buckets to include or exclude from the job. If you specify more than one
-- condition, Amazon Macie uses AND logic to join the conditions.
newCriteriaBlockForJob ::
  CriteriaBlockForJob
newCriteriaBlockForJob :: CriteriaBlockForJob
newCriteriaBlockForJob =
  CriteriaBlockForJob' :: Maybe [CriteriaForJob] -> CriteriaBlockForJob
CriteriaBlockForJob' {$sel:and:CriteriaBlockForJob' :: Maybe [CriteriaForJob]
and = Maybe [CriteriaForJob]
forall a. Maybe a
Prelude.Nothing}

-- | An array of conditions, one for each condition that determines which
-- buckets to include or exclude from the job. If you specify more than one
-- condition, Amazon Macie uses AND logic to join the conditions.
criteriaBlockForJob_and :: Lens.Lens' CriteriaBlockForJob (Prelude.Maybe [CriteriaForJob])
criteriaBlockForJob_and :: (Maybe [CriteriaForJob] -> f (Maybe [CriteriaForJob]))
-> CriteriaBlockForJob -> f CriteriaBlockForJob
criteriaBlockForJob_and = (CriteriaBlockForJob -> Maybe [CriteriaForJob])
-> (CriteriaBlockForJob
    -> Maybe [CriteriaForJob] -> CriteriaBlockForJob)
-> Lens
     CriteriaBlockForJob
     CriteriaBlockForJob
     (Maybe [CriteriaForJob])
     (Maybe [CriteriaForJob])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CriteriaBlockForJob' {Maybe [CriteriaForJob]
and :: Maybe [CriteriaForJob]
$sel:and:CriteriaBlockForJob' :: CriteriaBlockForJob -> Maybe [CriteriaForJob]
and} -> Maybe [CriteriaForJob]
and) (\s :: CriteriaBlockForJob
s@CriteriaBlockForJob' {} Maybe [CriteriaForJob]
a -> CriteriaBlockForJob
s {$sel:and:CriteriaBlockForJob' :: Maybe [CriteriaForJob]
and = Maybe [CriteriaForJob]
a} :: CriteriaBlockForJob) ((Maybe [CriteriaForJob] -> f (Maybe [CriteriaForJob]))
 -> CriteriaBlockForJob -> f CriteriaBlockForJob)
-> ((Maybe [CriteriaForJob] -> f (Maybe [CriteriaForJob]))
    -> Maybe [CriteriaForJob] -> f (Maybe [CriteriaForJob]))
-> (Maybe [CriteriaForJob] -> f (Maybe [CriteriaForJob]))
-> CriteriaBlockForJob
-> f CriteriaBlockForJob
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CriteriaForJob] [CriteriaForJob] [CriteriaForJob] [CriteriaForJob]
-> Iso
     (Maybe [CriteriaForJob])
     (Maybe [CriteriaForJob])
     (Maybe [CriteriaForJob])
     (Maybe [CriteriaForJob])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [CriteriaForJob] [CriteriaForJob] [CriteriaForJob] [CriteriaForJob]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON CriteriaBlockForJob where
  parseJSON :: Value -> Parser CriteriaBlockForJob
parseJSON =
    String
-> (Object -> Parser CriteriaBlockForJob)
-> Value
-> Parser CriteriaBlockForJob
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CriteriaBlockForJob"
      ( \Object
x ->
          Maybe [CriteriaForJob] -> CriteriaBlockForJob
CriteriaBlockForJob'
            (Maybe [CriteriaForJob] -> CriteriaBlockForJob)
-> Parser (Maybe [CriteriaForJob]) -> Parser CriteriaBlockForJob
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [CriteriaForJob]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"and" Parser (Maybe (Maybe [CriteriaForJob]))
-> Maybe [CriteriaForJob] -> Parser (Maybe [CriteriaForJob])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CriteriaForJob]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable CriteriaBlockForJob

instance Prelude.NFData CriteriaBlockForJob

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