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

-- | Specifies a property-based condition that determines whether an S3
-- bucket is included or excluded from a classification job.
--
-- /See:/ 'newSimpleCriterionForJob' smart constructor.
data SimpleCriterionForJob = SimpleCriterionForJob'
  { -- | The operator to use in the condition. Valid values are EQ (equals) and
    -- NE (not equals).
    SimpleCriterionForJob -> Maybe JobComparator
comparator :: Prelude.Maybe JobComparator,
    -- | The property to use in the condition.
    SimpleCriterionForJob -> Maybe SimpleCriterionKeyForJob
key :: Prelude.Maybe SimpleCriterionKeyForJob,
    -- | An array that lists one or more values to use in the condition. If you
    -- specify multiple values, Amazon Macie uses OR logic to join the values.
    -- Valid values for each supported property (key) are:
    --
    -- -   ACCOUNT_ID - A string that represents the unique identifier for the
    --     Amazon Web Services account that owns the bucket.
    --
    -- -   S3_BUCKET_EFFECTIVE_PERMISSION - A string that represents an
    --     enumerated value that Macie defines for the
    --     <https://docs.aws.amazon.com/macie/latest/APIReference/datasources-s3.html#datasources-s3-prop-bucketpublicaccess-effectivepermission BucketPublicAccess.effectivePermission>
    --     property of a bucket.
    --
    -- -   S3_BUCKET_NAME - A string that represents the name of a bucket.
    --
    -- -   S3_BUCKET_SHARED_ACCESS - A string that represents an enumerated
    --     value that Macie defines for the
    --     <https://docs.aws.amazon.com/macie/latest/APIReference/datasources-s3.html#datasources-s3-prop-bucketmetadata-sharedaccess BucketMetadata.sharedAccess>
    --     property of a bucket.
    --
    -- Values are case sensitive. Also, Macie doesn\'t support use of partial
    -- values or wildcard characters in these values.
    SimpleCriterionForJob -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (SimpleCriterionForJob -> SimpleCriterionForJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SimpleCriterionForJob -> SimpleCriterionForJob -> Bool
$c/= :: SimpleCriterionForJob -> SimpleCriterionForJob -> Bool
== :: SimpleCriterionForJob -> SimpleCriterionForJob -> Bool
$c== :: SimpleCriterionForJob -> SimpleCriterionForJob -> Bool
Prelude.Eq, ReadPrec [SimpleCriterionForJob]
ReadPrec SimpleCriterionForJob
Int -> ReadS SimpleCriterionForJob
ReadS [SimpleCriterionForJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimpleCriterionForJob]
$creadListPrec :: ReadPrec [SimpleCriterionForJob]
readPrec :: ReadPrec SimpleCriterionForJob
$creadPrec :: ReadPrec SimpleCriterionForJob
readList :: ReadS [SimpleCriterionForJob]
$creadList :: ReadS [SimpleCriterionForJob]
readsPrec :: Int -> ReadS SimpleCriterionForJob
$creadsPrec :: Int -> ReadS SimpleCriterionForJob
Prelude.Read, Int -> SimpleCriterionForJob -> ShowS
[SimpleCriterionForJob] -> ShowS
SimpleCriterionForJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimpleCriterionForJob] -> ShowS
$cshowList :: [SimpleCriterionForJob] -> ShowS
show :: SimpleCriterionForJob -> String
$cshow :: SimpleCriterionForJob -> String
showsPrec :: Int -> SimpleCriterionForJob -> ShowS
$cshowsPrec :: Int -> SimpleCriterionForJob -> ShowS
Prelude.Show, forall x. Rep SimpleCriterionForJob x -> SimpleCriterionForJob
forall x. SimpleCriterionForJob -> Rep SimpleCriterionForJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SimpleCriterionForJob x -> SimpleCriterionForJob
$cfrom :: forall x. SimpleCriterionForJob -> Rep SimpleCriterionForJob x
Prelude.Generic)

-- |
-- Create a value of 'SimpleCriterionForJob' 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:
--
-- 'comparator', 'simpleCriterionForJob_comparator' - The operator to use in the condition. Valid values are EQ (equals) and
-- NE (not equals).
--
-- 'key', 'simpleCriterionForJob_key' - The property to use in the condition.
--
-- 'values', 'simpleCriterionForJob_values' - An array that lists one or more values to use in the condition. If you
-- specify multiple values, Amazon Macie uses OR logic to join the values.
-- Valid values for each supported property (key) are:
--
-- -   ACCOUNT_ID - A string that represents the unique identifier for the
--     Amazon Web Services account that owns the bucket.
--
-- -   S3_BUCKET_EFFECTIVE_PERMISSION - A string that represents an
--     enumerated value that Macie defines for the
--     <https://docs.aws.amazon.com/macie/latest/APIReference/datasources-s3.html#datasources-s3-prop-bucketpublicaccess-effectivepermission BucketPublicAccess.effectivePermission>
--     property of a bucket.
--
-- -   S3_BUCKET_NAME - A string that represents the name of a bucket.
--
-- -   S3_BUCKET_SHARED_ACCESS - A string that represents an enumerated
--     value that Macie defines for the
--     <https://docs.aws.amazon.com/macie/latest/APIReference/datasources-s3.html#datasources-s3-prop-bucketmetadata-sharedaccess BucketMetadata.sharedAccess>
--     property of a bucket.
--
-- Values are case sensitive. Also, Macie doesn\'t support use of partial
-- values or wildcard characters in these values.
newSimpleCriterionForJob ::
  SimpleCriterionForJob
newSimpleCriterionForJob :: SimpleCriterionForJob
newSimpleCriterionForJob =
  SimpleCriterionForJob'
    { $sel:comparator:SimpleCriterionForJob' :: Maybe JobComparator
comparator =
        forall a. Maybe a
Prelude.Nothing,
      $sel:key:SimpleCriterionForJob' :: Maybe SimpleCriterionKeyForJob
key = forall a. Maybe a
Prelude.Nothing,
      $sel:values:SimpleCriterionForJob' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The operator to use in the condition. Valid values are EQ (equals) and
-- NE (not equals).
simpleCriterionForJob_comparator :: Lens.Lens' SimpleCriterionForJob (Prelude.Maybe JobComparator)
simpleCriterionForJob_comparator :: Lens' SimpleCriterionForJob (Maybe JobComparator)
simpleCriterionForJob_comparator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleCriterionForJob' {Maybe JobComparator
comparator :: Maybe JobComparator
$sel:comparator:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe JobComparator
comparator} -> Maybe JobComparator
comparator) (\s :: SimpleCriterionForJob
s@SimpleCriterionForJob' {} Maybe JobComparator
a -> SimpleCriterionForJob
s {$sel:comparator:SimpleCriterionForJob' :: Maybe JobComparator
comparator = Maybe JobComparator
a} :: SimpleCriterionForJob)

-- | The property to use in the condition.
simpleCriterionForJob_key :: Lens.Lens' SimpleCriterionForJob (Prelude.Maybe SimpleCriterionKeyForJob)
simpleCriterionForJob_key :: Lens' SimpleCriterionForJob (Maybe SimpleCriterionKeyForJob)
simpleCriterionForJob_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleCriterionForJob' {Maybe SimpleCriterionKeyForJob
key :: Maybe SimpleCriterionKeyForJob
$sel:key:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe SimpleCriterionKeyForJob
key} -> Maybe SimpleCriterionKeyForJob
key) (\s :: SimpleCriterionForJob
s@SimpleCriterionForJob' {} Maybe SimpleCriterionKeyForJob
a -> SimpleCriterionForJob
s {$sel:key:SimpleCriterionForJob' :: Maybe SimpleCriterionKeyForJob
key = Maybe SimpleCriterionKeyForJob
a} :: SimpleCriterionForJob)

-- | An array that lists one or more values to use in the condition. If you
-- specify multiple values, Amazon Macie uses OR logic to join the values.
-- Valid values for each supported property (key) are:
--
-- -   ACCOUNT_ID - A string that represents the unique identifier for the
--     Amazon Web Services account that owns the bucket.
--
-- -   S3_BUCKET_EFFECTIVE_PERMISSION - A string that represents an
--     enumerated value that Macie defines for the
--     <https://docs.aws.amazon.com/macie/latest/APIReference/datasources-s3.html#datasources-s3-prop-bucketpublicaccess-effectivepermission BucketPublicAccess.effectivePermission>
--     property of a bucket.
--
-- -   S3_BUCKET_NAME - A string that represents the name of a bucket.
--
-- -   S3_BUCKET_SHARED_ACCESS - A string that represents an enumerated
--     value that Macie defines for the
--     <https://docs.aws.amazon.com/macie/latest/APIReference/datasources-s3.html#datasources-s3-prop-bucketmetadata-sharedaccess BucketMetadata.sharedAccess>
--     property of a bucket.
--
-- Values are case sensitive. Also, Macie doesn\'t support use of partial
-- values or wildcard characters in these values.
simpleCriterionForJob_values :: Lens.Lens' SimpleCriterionForJob (Prelude.Maybe [Prelude.Text])
simpleCriterionForJob_values :: Lens' SimpleCriterionForJob (Maybe [Text])
simpleCriterionForJob_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleCriterionForJob' {Maybe [Text]
values :: Maybe [Text]
$sel:values:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: SimpleCriterionForJob
s@SimpleCriterionForJob' {} Maybe [Text]
a -> SimpleCriterionForJob
s {$sel:values:SimpleCriterionForJob' :: Maybe [Text]
values = Maybe [Text]
a} :: SimpleCriterionForJob) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SimpleCriterionForJob where
  parseJSON :: Value -> Parser SimpleCriterionForJob
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SimpleCriterionForJob"
      ( \Object
x ->
          Maybe JobComparator
-> Maybe SimpleCriterionKeyForJob
-> Maybe [Text]
-> SimpleCriterionForJob
SimpleCriterionForJob'
            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
"comparator")
            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
"key")
            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
"values" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SimpleCriterionForJob where
  hashWithSalt :: Int -> SimpleCriterionForJob -> Int
hashWithSalt Int
_salt SimpleCriterionForJob' {Maybe [Text]
Maybe JobComparator
Maybe SimpleCriterionKeyForJob
values :: Maybe [Text]
key :: Maybe SimpleCriterionKeyForJob
comparator :: Maybe JobComparator
$sel:values:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe [Text]
$sel:key:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe SimpleCriterionKeyForJob
$sel:comparator:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe JobComparator
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JobComparator
comparator
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SimpleCriterionKeyForJob
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

instance Prelude.NFData SimpleCriterionForJob where
  rnf :: SimpleCriterionForJob -> ()
rnf SimpleCriterionForJob' {Maybe [Text]
Maybe JobComparator
Maybe SimpleCriterionKeyForJob
values :: Maybe [Text]
key :: Maybe SimpleCriterionKeyForJob
comparator :: Maybe JobComparator
$sel:values:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe [Text]
$sel:key:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe SimpleCriterionKeyForJob
$sel:comparator:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe JobComparator
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe JobComparator
comparator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SimpleCriterionKeyForJob
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values

instance Data.ToJSON SimpleCriterionForJob where
  toJSON :: SimpleCriterionForJob -> Value
toJSON SimpleCriterionForJob' {Maybe [Text]
Maybe JobComparator
Maybe SimpleCriterionKeyForJob
values :: Maybe [Text]
key :: Maybe SimpleCriterionKeyForJob
comparator :: Maybe JobComparator
$sel:values:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe [Text]
$sel:key:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe SimpleCriterionKeyForJob
$sel:comparator:SimpleCriterionForJob' :: SimpleCriterionForJob -> Maybe JobComparator
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"comparator" 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 JobComparator
comparator,
            (Key
"key" 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 SimpleCriterionKeyForJob
key,
            (Key
"values" 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 [Text]
values
          ]
      )