{-# 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.JobScopeTerm
-- 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.JobScopeTerm 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.SimpleScopeTerm
import Amazonka.MacieV2.Types.TagScopeTerm
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'JobScopeTerm' 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:
--
-- 'simpleScopeTerm', 'jobScopeTerm_simpleScopeTerm' - A property-based condition that defines a property, operator, and one or
-- more values for including or excluding objects from the job.
--
-- 'tagScopeTerm', 'jobScopeTerm_tagScopeTerm' - A tag-based condition that defines the operator and tag keys or tag key
-- and value pairs for including or excluding objects from the job.
newJobScopeTerm ::
  JobScopeTerm
newJobScopeTerm :: JobScopeTerm
newJobScopeTerm =
  JobScopeTerm'
    { $sel:simpleScopeTerm:JobScopeTerm' :: Maybe SimpleScopeTerm
simpleScopeTerm = forall a. Maybe a
Prelude.Nothing,
      $sel:tagScopeTerm:JobScopeTerm' :: Maybe TagScopeTerm
tagScopeTerm = forall a. Maybe a
Prelude.Nothing
    }

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

-- | A tag-based condition that defines the operator and tag keys or tag key
-- and value pairs for including or excluding objects from the job.
jobScopeTerm_tagScopeTerm :: Lens.Lens' JobScopeTerm (Prelude.Maybe TagScopeTerm)
jobScopeTerm_tagScopeTerm :: Lens' JobScopeTerm (Maybe TagScopeTerm)
jobScopeTerm_tagScopeTerm = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobScopeTerm' {Maybe TagScopeTerm
tagScopeTerm :: Maybe TagScopeTerm
$sel:tagScopeTerm:JobScopeTerm' :: JobScopeTerm -> Maybe TagScopeTerm
tagScopeTerm} -> Maybe TagScopeTerm
tagScopeTerm) (\s :: JobScopeTerm
s@JobScopeTerm' {} Maybe TagScopeTerm
a -> JobScopeTerm
s {$sel:tagScopeTerm:JobScopeTerm' :: Maybe TagScopeTerm
tagScopeTerm = Maybe TagScopeTerm
a} :: JobScopeTerm)

instance Data.FromJSON JobScopeTerm where
  parseJSON :: Value -> Parser JobScopeTerm
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JobScopeTerm"
      ( \Object
x ->
          Maybe SimpleScopeTerm -> Maybe TagScopeTerm -> JobScopeTerm
JobScopeTerm'
            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
"simpleScopeTerm")
            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
"tagScopeTerm")
      )

instance Prelude.Hashable JobScopeTerm where
  hashWithSalt :: Int -> JobScopeTerm -> Int
hashWithSalt Int
_salt JobScopeTerm' {Maybe SimpleScopeTerm
Maybe TagScopeTerm
tagScopeTerm :: Maybe TagScopeTerm
simpleScopeTerm :: Maybe SimpleScopeTerm
$sel:tagScopeTerm:JobScopeTerm' :: JobScopeTerm -> Maybe TagScopeTerm
$sel:simpleScopeTerm:JobScopeTerm' :: JobScopeTerm -> Maybe SimpleScopeTerm
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SimpleScopeTerm
simpleScopeTerm
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TagScopeTerm
tagScopeTerm

instance Prelude.NFData JobScopeTerm where
  rnf :: JobScopeTerm -> ()
rnf JobScopeTerm' {Maybe SimpleScopeTerm
Maybe TagScopeTerm
tagScopeTerm :: Maybe TagScopeTerm
simpleScopeTerm :: Maybe SimpleScopeTerm
$sel:tagScopeTerm:JobScopeTerm' :: JobScopeTerm -> Maybe TagScopeTerm
$sel:simpleScopeTerm:JobScopeTerm' :: JobScopeTerm -> Maybe SimpleScopeTerm
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SimpleScopeTerm
simpleScopeTerm
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TagScopeTerm
tagScopeTerm

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