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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(JobScopeTerm -> JobScopeTerm -> Bool)
-> (JobScopeTerm -> JobScopeTerm -> Bool) -> Eq JobScopeTerm
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]
(Int -> ReadS JobScopeTerm)
-> ReadS [JobScopeTerm]
-> ReadPrec JobScopeTerm
-> ReadPrec [JobScopeTerm]
-> Read 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
(Int -> JobScopeTerm -> ShowS)
-> (JobScopeTerm -> String)
-> ([JobScopeTerm] -> ShowS)
-> Show JobScopeTerm
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. JobScopeTerm -> Rep JobScopeTerm x)
-> (forall x. Rep JobScopeTerm x -> JobScopeTerm)
-> Generic JobScopeTerm
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' :: Maybe SimpleScopeTerm -> Maybe TagScopeTerm -> JobScopeTerm
JobScopeTerm'
    { $sel:simpleScopeTerm:JobScopeTerm' :: Maybe SimpleScopeTerm
simpleScopeTerm = Maybe SimpleScopeTerm
forall a. Maybe a
Prelude.Nothing,
      $sel:tagScopeTerm:JobScopeTerm' :: Maybe TagScopeTerm
tagScopeTerm = Maybe 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 :: (Maybe SimpleScopeTerm -> f (Maybe SimpleScopeTerm))
-> JobScopeTerm -> f JobScopeTerm
jobScopeTerm_simpleScopeTerm = (JobScopeTerm -> Maybe SimpleScopeTerm)
-> (JobScopeTerm -> Maybe SimpleScopeTerm -> JobScopeTerm)
-> Lens
     JobScopeTerm
     JobScopeTerm
     (Maybe SimpleScopeTerm)
     (Maybe 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 :: (Maybe TagScopeTerm -> f (Maybe TagScopeTerm))
-> JobScopeTerm -> f JobScopeTerm
jobScopeTerm_tagScopeTerm = (JobScopeTerm -> Maybe TagScopeTerm)
-> (JobScopeTerm -> Maybe TagScopeTerm -> JobScopeTerm)
-> Lens
     JobScopeTerm JobScopeTerm (Maybe TagScopeTerm) (Maybe 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 Core.FromJSON JobScopeTerm where
  parseJSON :: Value -> Parser JobScopeTerm
parseJSON =
    String
-> (Object -> Parser JobScopeTerm) -> Value -> Parser JobScopeTerm
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JobScopeTerm"
      ( \Object
x ->
          Maybe SimpleScopeTerm -> Maybe TagScopeTerm -> JobScopeTerm
JobScopeTerm'
            (Maybe SimpleScopeTerm -> Maybe TagScopeTerm -> JobScopeTerm)
-> Parser (Maybe SimpleScopeTerm)
-> Parser (Maybe TagScopeTerm -> JobScopeTerm)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SimpleScopeTerm)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"simpleScopeTerm")
            Parser (Maybe TagScopeTerm -> JobScopeTerm)
-> Parser (Maybe TagScopeTerm) -> Parser JobScopeTerm
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TagScopeTerm)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tagScopeTerm")
      )

instance Prelude.Hashable JobScopeTerm

instance Prelude.NFData JobScopeTerm

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"simpleScopeTerm" Text -> SimpleScopeTerm -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SimpleScopeTerm -> Pair) -> Maybe SimpleScopeTerm -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SimpleScopeTerm
simpleScopeTerm,
            (Text
"tagScopeTerm" Text -> TagScopeTerm -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TagScopeTerm -> Pair) -> Maybe TagScopeTerm -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TagScopeTerm
tagScopeTerm
          ]
      )