{-# 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.CriteriaForJob
-- 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.CriteriaForJob 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.SimpleCriterionForJob
import Amazonka.MacieV2.Types.TagCriterionForJob
import qualified Amazonka.Prelude as Prelude

-- | Specifies a property- or tag-based condition that defines criteria for
-- including or excluding S3 buckets from a classification job.
--
-- /See:/ 'newCriteriaForJob' smart constructor.
data CriteriaForJob = CriteriaForJob'
  { -- | A property-based condition that defines a property, operator, and one or
    -- more values for including or excluding buckets from the job.
    CriteriaForJob -> Maybe SimpleCriterionForJob
simpleCriterion :: Prelude.Maybe SimpleCriterionForJob,
    -- | A tag-based condition that defines an operator and tag keys, tag values,
    -- or tag key and value pairs for including or excluding buckets from the
    -- job.
    CriteriaForJob -> Maybe TagCriterionForJob
tagCriterion :: Prelude.Maybe TagCriterionForJob
  }
  deriving (CriteriaForJob -> CriteriaForJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CriteriaForJob -> CriteriaForJob -> Bool
$c/= :: CriteriaForJob -> CriteriaForJob -> Bool
== :: CriteriaForJob -> CriteriaForJob -> Bool
$c== :: CriteriaForJob -> CriteriaForJob -> Bool
Prelude.Eq, ReadPrec [CriteriaForJob]
ReadPrec CriteriaForJob
Int -> ReadS CriteriaForJob
ReadS [CriteriaForJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CriteriaForJob]
$creadListPrec :: ReadPrec [CriteriaForJob]
readPrec :: ReadPrec CriteriaForJob
$creadPrec :: ReadPrec CriteriaForJob
readList :: ReadS [CriteriaForJob]
$creadList :: ReadS [CriteriaForJob]
readsPrec :: Int -> ReadS CriteriaForJob
$creadsPrec :: Int -> ReadS CriteriaForJob
Prelude.Read, Int -> CriteriaForJob -> ShowS
[CriteriaForJob] -> ShowS
CriteriaForJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CriteriaForJob] -> ShowS
$cshowList :: [CriteriaForJob] -> ShowS
show :: CriteriaForJob -> String
$cshow :: CriteriaForJob -> String
showsPrec :: Int -> CriteriaForJob -> ShowS
$cshowsPrec :: Int -> CriteriaForJob -> ShowS
Prelude.Show, forall x. Rep CriteriaForJob x -> CriteriaForJob
forall x. CriteriaForJob -> Rep CriteriaForJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CriteriaForJob x -> CriteriaForJob
$cfrom :: forall x. CriteriaForJob -> Rep CriteriaForJob x
Prelude.Generic)

-- |
-- Create a value of 'CriteriaForJob' 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:
--
-- 'simpleCriterion', 'criteriaForJob_simpleCriterion' - A property-based condition that defines a property, operator, and one or
-- more values for including or excluding buckets from the job.
--
-- 'tagCriterion', 'criteriaForJob_tagCriterion' - A tag-based condition that defines an operator and tag keys, tag values,
-- or tag key and value pairs for including or excluding buckets from the
-- job.
newCriteriaForJob ::
  CriteriaForJob
newCriteriaForJob :: CriteriaForJob
newCriteriaForJob =
  CriteriaForJob'
    { $sel:simpleCriterion:CriteriaForJob' :: Maybe SimpleCriterionForJob
simpleCriterion = forall a. Maybe a
Prelude.Nothing,
      $sel:tagCriterion:CriteriaForJob' :: Maybe TagCriterionForJob
tagCriterion = forall a. Maybe a
Prelude.Nothing
    }

-- | A property-based condition that defines a property, operator, and one or
-- more values for including or excluding buckets from the job.
criteriaForJob_simpleCriterion :: Lens.Lens' CriteriaForJob (Prelude.Maybe SimpleCriterionForJob)
criteriaForJob_simpleCriterion :: Lens' CriteriaForJob (Maybe SimpleCriterionForJob)
criteriaForJob_simpleCriterion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CriteriaForJob' {Maybe SimpleCriterionForJob
simpleCriterion :: Maybe SimpleCriterionForJob
$sel:simpleCriterion:CriteriaForJob' :: CriteriaForJob -> Maybe SimpleCriterionForJob
simpleCriterion} -> Maybe SimpleCriterionForJob
simpleCriterion) (\s :: CriteriaForJob
s@CriteriaForJob' {} Maybe SimpleCriterionForJob
a -> CriteriaForJob
s {$sel:simpleCriterion:CriteriaForJob' :: Maybe SimpleCriterionForJob
simpleCriterion = Maybe SimpleCriterionForJob
a} :: CriteriaForJob)

-- | A tag-based condition that defines an operator and tag keys, tag values,
-- or tag key and value pairs for including or excluding buckets from the
-- job.
criteriaForJob_tagCriterion :: Lens.Lens' CriteriaForJob (Prelude.Maybe TagCriterionForJob)
criteriaForJob_tagCriterion :: Lens' CriteriaForJob (Maybe TagCriterionForJob)
criteriaForJob_tagCriterion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CriteriaForJob' {Maybe TagCriterionForJob
tagCriterion :: Maybe TagCriterionForJob
$sel:tagCriterion:CriteriaForJob' :: CriteriaForJob -> Maybe TagCriterionForJob
tagCriterion} -> Maybe TagCriterionForJob
tagCriterion) (\s :: CriteriaForJob
s@CriteriaForJob' {} Maybe TagCriterionForJob
a -> CriteriaForJob
s {$sel:tagCriterion:CriteriaForJob' :: Maybe TagCriterionForJob
tagCriterion = Maybe TagCriterionForJob
a} :: CriteriaForJob)

instance Data.FromJSON CriteriaForJob where
  parseJSON :: Value -> Parser CriteriaForJob
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CriteriaForJob"
      ( \Object
x ->
          Maybe SimpleCriterionForJob
-> Maybe TagCriterionForJob -> CriteriaForJob
CriteriaForJob'
            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
"simpleCriterion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"tagCriterion")
      )

instance Prelude.Hashable CriteriaForJob where
  hashWithSalt :: Int -> CriteriaForJob -> Int
hashWithSalt Int
_salt CriteriaForJob' {Maybe SimpleCriterionForJob
Maybe TagCriterionForJob
tagCriterion :: Maybe TagCriterionForJob
simpleCriterion :: Maybe SimpleCriterionForJob
$sel:tagCriterion:CriteriaForJob' :: CriteriaForJob -> Maybe TagCriterionForJob
$sel:simpleCriterion:CriteriaForJob' :: CriteriaForJob -> Maybe SimpleCriterionForJob
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SimpleCriterionForJob
simpleCriterion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TagCriterionForJob
tagCriterion

instance Prelude.NFData CriteriaForJob where
  rnf :: CriteriaForJob -> ()
rnf CriteriaForJob' {Maybe SimpleCriterionForJob
Maybe TagCriterionForJob
tagCriterion :: Maybe TagCriterionForJob
simpleCriterion :: Maybe SimpleCriterionForJob
$sel:tagCriterion:CriteriaForJob' :: CriteriaForJob -> Maybe TagCriterionForJob
$sel:simpleCriterion:CriteriaForJob' :: CriteriaForJob -> Maybe SimpleCriterionForJob
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SimpleCriterionForJob
simpleCriterion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TagCriterionForJob
tagCriterion

instance Data.ToJSON CriteriaForJob where
  toJSON :: CriteriaForJob -> Value
toJSON CriteriaForJob' {Maybe SimpleCriterionForJob
Maybe TagCriterionForJob
tagCriterion :: Maybe TagCriterionForJob
simpleCriterion :: Maybe SimpleCriterionForJob
$sel:tagCriterion:CriteriaForJob' :: CriteriaForJob -> Maybe TagCriterionForJob
$sel:simpleCriterion:CriteriaForJob' :: CriteriaForJob -> Maybe SimpleCriterionForJob
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"simpleCriterion" 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 SimpleCriterionForJob
simpleCriterion,
            (Key
"tagCriterion" 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 TagCriterionForJob
tagCriterion
          ]
      )