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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (CriteriaForJob -> CriteriaForJob -> Bool
(CriteriaForJob -> CriteriaForJob -> Bool)
-> (CriteriaForJob -> CriteriaForJob -> Bool) -> Eq CriteriaForJob
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]
(Int -> ReadS CriteriaForJob)
-> ReadS [CriteriaForJob]
-> ReadPrec CriteriaForJob
-> ReadPrec [CriteriaForJob]
-> Read 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
(Int -> CriteriaForJob -> ShowS)
-> (CriteriaForJob -> String)
-> ([CriteriaForJob] -> ShowS)
-> Show CriteriaForJob
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. CriteriaForJob -> Rep CriteriaForJob x)
-> (forall x. Rep CriteriaForJob x -> CriteriaForJob)
-> Generic CriteriaForJob
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:
--
-- '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.
--
-- '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.
newCriteriaForJob ::
  CriteriaForJob
newCriteriaForJob :: CriteriaForJob
newCriteriaForJob =
  CriteriaForJob' :: Maybe TagCriterionForJob
-> Maybe SimpleCriterionForJob -> CriteriaForJob
CriteriaForJob'
    { $sel:tagCriterion:CriteriaForJob' :: Maybe TagCriterionForJob
tagCriterion = Maybe TagCriterionForJob
forall a. Maybe a
Prelude.Nothing,
      $sel:simpleCriterion:CriteriaForJob' :: Maybe SimpleCriterionForJob
simpleCriterion = Maybe SimpleCriterionForJob
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe TagCriterionForJob -> f (Maybe TagCriterionForJob))
-> CriteriaForJob -> f CriteriaForJob
criteriaForJob_tagCriterion = (CriteriaForJob -> Maybe TagCriterionForJob)
-> (CriteriaForJob -> Maybe TagCriterionForJob -> CriteriaForJob)
-> Lens
     CriteriaForJob
     CriteriaForJob
     (Maybe TagCriterionForJob)
     (Maybe TagCriterionForJob)
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)

-- | 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 :: (Maybe SimpleCriterionForJob -> f (Maybe SimpleCriterionForJob))
-> CriteriaForJob -> f CriteriaForJob
criteriaForJob_simpleCriterion = (CriteriaForJob -> Maybe SimpleCriterionForJob)
-> (CriteriaForJob
    -> Maybe SimpleCriterionForJob -> CriteriaForJob)
-> Lens
     CriteriaForJob
     CriteriaForJob
     (Maybe SimpleCriterionForJob)
     (Maybe SimpleCriterionForJob)
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)

instance Core.FromJSON CriteriaForJob where
  parseJSON :: Value -> Parser CriteriaForJob
parseJSON =
    String
-> (Object -> Parser CriteriaForJob)
-> Value
-> Parser CriteriaForJob
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CriteriaForJob"
      ( \Object
x ->
          Maybe TagCriterionForJob
-> Maybe SimpleCriterionForJob -> CriteriaForJob
CriteriaForJob'
            (Maybe TagCriterionForJob
 -> Maybe SimpleCriterionForJob -> CriteriaForJob)
-> Parser (Maybe TagCriterionForJob)
-> Parser (Maybe SimpleCriterionForJob -> CriteriaForJob)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TagCriterionForJob)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tagCriterion")
            Parser (Maybe SimpleCriterionForJob -> CriteriaForJob)
-> Parser (Maybe SimpleCriterionForJob) -> Parser CriteriaForJob
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SimpleCriterionForJob)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"simpleCriterion")
      )

instance Prelude.Hashable CriteriaForJob

instance Prelude.NFData CriteriaForJob

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