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

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

-- | Specifies property- and tag-based conditions that define criteria for
-- including or excluding S3 buckets from a classification job. Exclude
-- conditions take precedence over include conditions.
--
-- /See:/ 'newS3BucketCriteriaForJob' smart constructor.
data S3BucketCriteriaForJob = S3BucketCriteriaForJob'
  { -- | The property- and tag-based conditions that determine which buckets to
    -- include in the job.
    S3BucketCriteriaForJob -> Maybe CriteriaBlockForJob
includes :: Prelude.Maybe CriteriaBlockForJob,
    -- | The property- and tag-based conditions that determine which buckets to
    -- exclude from the job.
    S3BucketCriteriaForJob -> Maybe CriteriaBlockForJob
excludes :: Prelude.Maybe CriteriaBlockForJob
  }
  deriving (S3BucketCriteriaForJob -> S3BucketCriteriaForJob -> Bool
(S3BucketCriteriaForJob -> S3BucketCriteriaForJob -> Bool)
-> (S3BucketCriteriaForJob -> S3BucketCriteriaForJob -> Bool)
-> Eq S3BucketCriteriaForJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3BucketCriteriaForJob -> S3BucketCriteriaForJob -> Bool
$c/= :: S3BucketCriteriaForJob -> S3BucketCriteriaForJob -> Bool
== :: S3BucketCriteriaForJob -> S3BucketCriteriaForJob -> Bool
$c== :: S3BucketCriteriaForJob -> S3BucketCriteriaForJob -> Bool
Prelude.Eq, ReadPrec [S3BucketCriteriaForJob]
ReadPrec S3BucketCriteriaForJob
Int -> ReadS S3BucketCriteriaForJob
ReadS [S3BucketCriteriaForJob]
(Int -> ReadS S3BucketCriteriaForJob)
-> ReadS [S3BucketCriteriaForJob]
-> ReadPrec S3BucketCriteriaForJob
-> ReadPrec [S3BucketCriteriaForJob]
-> Read S3BucketCriteriaForJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3BucketCriteriaForJob]
$creadListPrec :: ReadPrec [S3BucketCriteriaForJob]
readPrec :: ReadPrec S3BucketCriteriaForJob
$creadPrec :: ReadPrec S3BucketCriteriaForJob
readList :: ReadS [S3BucketCriteriaForJob]
$creadList :: ReadS [S3BucketCriteriaForJob]
readsPrec :: Int -> ReadS S3BucketCriteriaForJob
$creadsPrec :: Int -> ReadS S3BucketCriteriaForJob
Prelude.Read, Int -> S3BucketCriteriaForJob -> ShowS
[S3BucketCriteriaForJob] -> ShowS
S3BucketCriteriaForJob -> String
(Int -> S3BucketCriteriaForJob -> ShowS)
-> (S3BucketCriteriaForJob -> String)
-> ([S3BucketCriteriaForJob] -> ShowS)
-> Show S3BucketCriteriaForJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3BucketCriteriaForJob] -> ShowS
$cshowList :: [S3BucketCriteriaForJob] -> ShowS
show :: S3BucketCriteriaForJob -> String
$cshow :: S3BucketCriteriaForJob -> String
showsPrec :: Int -> S3BucketCriteriaForJob -> ShowS
$cshowsPrec :: Int -> S3BucketCriteriaForJob -> ShowS
Prelude.Show, (forall x. S3BucketCriteriaForJob -> Rep S3BucketCriteriaForJob x)
-> (forall x.
    Rep S3BucketCriteriaForJob x -> S3BucketCriteriaForJob)
-> Generic S3BucketCriteriaForJob
forall x. Rep S3BucketCriteriaForJob x -> S3BucketCriteriaForJob
forall x. S3BucketCriteriaForJob -> Rep S3BucketCriteriaForJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3BucketCriteriaForJob x -> S3BucketCriteriaForJob
$cfrom :: forall x. S3BucketCriteriaForJob -> Rep S3BucketCriteriaForJob x
Prelude.Generic)

-- |
-- Create a value of 'S3BucketCriteriaForJob' 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:
--
-- 'includes', 's3BucketCriteriaForJob_includes' - The property- and tag-based conditions that determine which buckets to
-- include in the job.
--
-- 'excludes', 's3BucketCriteriaForJob_excludes' - The property- and tag-based conditions that determine which buckets to
-- exclude from the job.
newS3BucketCriteriaForJob ::
  S3BucketCriteriaForJob
newS3BucketCriteriaForJob :: S3BucketCriteriaForJob
newS3BucketCriteriaForJob =
  S3BucketCriteriaForJob' :: Maybe CriteriaBlockForJob
-> Maybe CriteriaBlockForJob -> S3BucketCriteriaForJob
S3BucketCriteriaForJob'
    { $sel:includes:S3BucketCriteriaForJob' :: Maybe CriteriaBlockForJob
includes = Maybe CriteriaBlockForJob
forall a. Maybe a
Prelude.Nothing,
      $sel:excludes:S3BucketCriteriaForJob' :: Maybe CriteriaBlockForJob
excludes = Maybe CriteriaBlockForJob
forall a. Maybe a
Prelude.Nothing
    }

-- | The property- and tag-based conditions that determine which buckets to
-- include in the job.
s3BucketCriteriaForJob_includes :: Lens.Lens' S3BucketCriteriaForJob (Prelude.Maybe CriteriaBlockForJob)
s3BucketCriteriaForJob_includes :: (Maybe CriteriaBlockForJob -> f (Maybe CriteriaBlockForJob))
-> S3BucketCriteriaForJob -> f S3BucketCriteriaForJob
s3BucketCriteriaForJob_includes = (S3BucketCriteriaForJob -> Maybe CriteriaBlockForJob)
-> (S3BucketCriteriaForJob
    -> Maybe CriteriaBlockForJob -> S3BucketCriteriaForJob)
-> Lens
     S3BucketCriteriaForJob
     S3BucketCriteriaForJob
     (Maybe CriteriaBlockForJob)
     (Maybe CriteriaBlockForJob)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3BucketCriteriaForJob' {Maybe CriteriaBlockForJob
includes :: Maybe CriteriaBlockForJob
$sel:includes:S3BucketCriteriaForJob' :: S3BucketCriteriaForJob -> Maybe CriteriaBlockForJob
includes} -> Maybe CriteriaBlockForJob
includes) (\s :: S3BucketCriteriaForJob
s@S3BucketCriteriaForJob' {} Maybe CriteriaBlockForJob
a -> S3BucketCriteriaForJob
s {$sel:includes:S3BucketCriteriaForJob' :: Maybe CriteriaBlockForJob
includes = Maybe CriteriaBlockForJob
a} :: S3BucketCriteriaForJob)

-- | The property- and tag-based conditions that determine which buckets to
-- exclude from the job.
s3BucketCriteriaForJob_excludes :: Lens.Lens' S3BucketCriteriaForJob (Prelude.Maybe CriteriaBlockForJob)
s3BucketCriteriaForJob_excludes :: (Maybe CriteriaBlockForJob -> f (Maybe CriteriaBlockForJob))
-> S3BucketCriteriaForJob -> f S3BucketCriteriaForJob
s3BucketCriteriaForJob_excludes = (S3BucketCriteriaForJob -> Maybe CriteriaBlockForJob)
-> (S3BucketCriteriaForJob
    -> Maybe CriteriaBlockForJob -> S3BucketCriteriaForJob)
-> Lens
     S3BucketCriteriaForJob
     S3BucketCriteriaForJob
     (Maybe CriteriaBlockForJob)
     (Maybe CriteriaBlockForJob)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3BucketCriteriaForJob' {Maybe CriteriaBlockForJob
excludes :: Maybe CriteriaBlockForJob
$sel:excludes:S3BucketCriteriaForJob' :: S3BucketCriteriaForJob -> Maybe CriteriaBlockForJob
excludes} -> Maybe CriteriaBlockForJob
excludes) (\s :: S3BucketCriteriaForJob
s@S3BucketCriteriaForJob' {} Maybe CriteriaBlockForJob
a -> S3BucketCriteriaForJob
s {$sel:excludes:S3BucketCriteriaForJob' :: Maybe CriteriaBlockForJob
excludes = Maybe CriteriaBlockForJob
a} :: S3BucketCriteriaForJob)

instance Core.FromJSON S3BucketCriteriaForJob where
  parseJSON :: Value -> Parser S3BucketCriteriaForJob
parseJSON =
    String
-> (Object -> Parser S3BucketCriteriaForJob)
-> Value
-> Parser S3BucketCriteriaForJob
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3BucketCriteriaForJob"
      ( \Object
x ->
          Maybe CriteriaBlockForJob
-> Maybe CriteriaBlockForJob -> S3BucketCriteriaForJob
S3BucketCriteriaForJob'
            (Maybe CriteriaBlockForJob
 -> Maybe CriteriaBlockForJob -> S3BucketCriteriaForJob)
-> Parser (Maybe CriteriaBlockForJob)
-> Parser (Maybe CriteriaBlockForJob -> S3BucketCriteriaForJob)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CriteriaBlockForJob)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"includes")
            Parser (Maybe CriteriaBlockForJob -> S3BucketCriteriaForJob)
-> Parser (Maybe CriteriaBlockForJob)
-> Parser S3BucketCriteriaForJob
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CriteriaBlockForJob)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"excludes")
      )

instance Prelude.Hashable S3BucketCriteriaForJob

instance Prelude.NFData S3BucketCriteriaForJob

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