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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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],
    -- | The property to use in the condition.
    SimpleCriterionForJob -> Maybe SimpleCriterionKeyForJob
key :: Prelude.Maybe SimpleCriterionKeyForJob,
    -- | The operator to use in the condition. Valid values are EQ (equals) and
    -- NE (not equals).
    SimpleCriterionForJob -> Maybe JobComparator
comparator :: Prelude.Maybe JobComparator
  }
  deriving (SimpleCriterionForJob -> SimpleCriterionForJob -> Bool
(SimpleCriterionForJob -> SimpleCriterionForJob -> Bool)
-> (SimpleCriterionForJob -> SimpleCriterionForJob -> Bool)
-> Eq SimpleCriterionForJob
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]
(Int -> ReadS SimpleCriterionForJob)
-> ReadS [SimpleCriterionForJob]
-> ReadPrec SimpleCriterionForJob
-> ReadPrec [SimpleCriterionForJob]
-> Read 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
(Int -> SimpleCriterionForJob -> ShowS)
-> (SimpleCriterionForJob -> String)
-> ([SimpleCriterionForJob] -> ShowS)
-> Show SimpleCriterionForJob
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. SimpleCriterionForJob -> Rep SimpleCriterionForJob x)
-> (forall x. Rep SimpleCriterionForJob x -> SimpleCriterionForJob)
-> Generic SimpleCriterionForJob
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:
--
-- '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.
--
-- 'key', 'simpleCriterionForJob_key' - The property to use in the condition.
--
-- 'comparator', 'simpleCriterionForJob_comparator' - The operator to use in the condition. Valid values are EQ (equals) and
-- NE (not equals).
newSimpleCriterionForJob ::
  SimpleCriterionForJob
newSimpleCriterionForJob :: SimpleCriterionForJob
newSimpleCriterionForJob =
  SimpleCriterionForJob' :: Maybe [Text]
-> Maybe SimpleCriterionKeyForJob
-> Maybe JobComparator
-> SimpleCriterionForJob
SimpleCriterionForJob'
    { $sel:values:SimpleCriterionForJob' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:key:SimpleCriterionForJob' :: Maybe SimpleCriterionKeyForJob
key = Maybe SimpleCriterionKeyForJob
forall a. Maybe a
Prelude.Nothing,
      $sel:comparator:SimpleCriterionForJob' :: Maybe JobComparator
comparator = Maybe JobComparator
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe [Text] -> f (Maybe [Text]))
-> SimpleCriterionForJob -> f SimpleCriterionForJob
simpleCriterionForJob_values = (SimpleCriterionForJob -> Maybe [Text])
-> (SimpleCriterionForJob -> Maybe [Text] -> SimpleCriterionForJob)
-> Lens
     SimpleCriterionForJob
     SimpleCriterionForJob
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> SimpleCriterionForJob -> f SimpleCriterionForJob)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SimpleCriterionForJob
-> f SimpleCriterionForJob
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The property to use in the condition.
simpleCriterionForJob_key :: Lens.Lens' SimpleCriterionForJob (Prelude.Maybe SimpleCriterionKeyForJob)
simpleCriterionForJob_key :: (Maybe SimpleCriterionKeyForJob
 -> f (Maybe SimpleCriterionKeyForJob))
-> SimpleCriterionForJob -> f SimpleCriterionForJob
simpleCriterionForJob_key = (SimpleCriterionForJob -> Maybe SimpleCriterionKeyForJob)
-> (SimpleCriterionForJob
    -> Maybe SimpleCriterionKeyForJob -> SimpleCriterionForJob)
-> Lens
     SimpleCriterionForJob
     SimpleCriterionForJob
     (Maybe SimpleCriterionKeyForJob)
     (Maybe SimpleCriterionKeyForJob)
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)

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

instance Core.FromJSON SimpleCriterionForJob where
  parseJSON :: Value -> Parser SimpleCriterionForJob
parseJSON =
    String
-> (Object -> Parser SimpleCriterionForJob)
-> Value
-> Parser SimpleCriterionForJob
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SimpleCriterionForJob"
      ( \Object
x ->
          Maybe [Text]
-> Maybe SimpleCriterionKeyForJob
-> Maybe JobComparator
-> SimpleCriterionForJob
SimpleCriterionForJob'
            (Maybe [Text]
 -> Maybe SimpleCriterionKeyForJob
 -> Maybe JobComparator
 -> SimpleCriterionForJob)
-> Parser (Maybe [Text])
-> Parser
     (Maybe SimpleCriterionKeyForJob
      -> Maybe JobComparator -> SimpleCriterionForJob)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"values" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe SimpleCriterionKeyForJob
   -> Maybe JobComparator -> SimpleCriterionForJob)
-> Parser (Maybe SimpleCriterionKeyForJob)
-> Parser (Maybe JobComparator -> SimpleCriterionForJob)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SimpleCriterionKeyForJob)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"key")
            Parser (Maybe JobComparator -> SimpleCriterionForJob)
-> Parser (Maybe JobComparator) -> Parser SimpleCriterionForJob
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JobComparator)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"comparator")
      )

instance Prelude.Hashable SimpleCriterionForJob

instance Prelude.NFData SimpleCriterionForJob

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