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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MacieV2.Types.JobScopeTerm
import qualified Amazonka.Prelude as Prelude

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

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

-- | An array of conditions, one for each property- or tag-based condition
-- that determines which objects to include or exclude from the job. If you
-- specify more than one condition, Amazon Macie uses AND logic to join the
-- conditions.
jobScopingBlock_and :: Lens.Lens' JobScopingBlock (Prelude.Maybe [JobScopeTerm])
jobScopingBlock_and :: Lens' JobScopingBlock (Maybe [JobScopeTerm])
jobScopingBlock_and = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobScopingBlock' {Maybe [JobScopeTerm]
and :: Maybe [JobScopeTerm]
$sel:and:JobScopingBlock' :: JobScopingBlock -> Maybe [JobScopeTerm]
and} -> Maybe [JobScopeTerm]
and) (\s :: JobScopingBlock
s@JobScopingBlock' {} Maybe [JobScopeTerm]
a -> JobScopingBlock
s {$sel:and:JobScopingBlock' :: Maybe [JobScopeTerm]
and = Maybe [JobScopeTerm]
a} :: JobScopingBlock) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable JobScopingBlock where
  hashWithSalt :: Int -> JobScopingBlock -> Int
hashWithSalt Int
_salt JobScopingBlock' {Maybe [JobScopeTerm]
and :: Maybe [JobScopeTerm]
$sel:and:JobScopingBlock' :: JobScopingBlock -> Maybe [JobScopeTerm]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [JobScopeTerm]
and

instance Prelude.NFData JobScopingBlock where
  rnf :: JobScopingBlock -> ()
rnf JobScopingBlock' {Maybe [JobScopeTerm]
and :: Maybe [JobScopeTerm]
$sel:and:JobScopingBlock' :: JobScopingBlock -> Maybe [JobScopeTerm]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [JobScopeTerm]
and

instance Data.ToJSON JobScopingBlock where
  toJSON :: JobScopingBlock -> Value
toJSON JobScopingBlock' {Maybe [JobScopeTerm]
and :: Maybe [JobScopeTerm]
$sel:and:JobScopingBlock' :: JobScopingBlock -> Maybe [JobScopeTerm]
..} =
    [Pair] -> Value
Data.object
      (forall a. [Maybe a] -> [a]
Prelude.catMaybes [(Key
"and" 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 [JobScopeTerm]
and])