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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.SearchResourcesComparator
import Amazonka.MacieV2.Types.SearchResourcesSimpleCriterionKey
import qualified Amazonka.Prelude as Prelude

-- | Specifies a property-based filter condition that determines which Amazon
-- Web Services resources are included or excluded from the query results.
--
-- /See:/ 'newSearchResourcesSimpleCriterion' smart constructor.
data SearchResourcesSimpleCriterion = SearchResourcesSimpleCriterion'
  { -- | 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 resource.
    --
    -- -   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 an S3 bucket.
    --
    -- -   S3_BUCKET_NAME - A string that represents the name of an S3 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 an S3 bucket.
    --
    -- Values are case sensitive. Also, Macie doesn\'t support use of partial
    -- values or wildcard characters in values.
    SearchResourcesSimpleCriterion -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    -- | The property to use in the condition.
    SearchResourcesSimpleCriterion
-> Maybe SearchResourcesSimpleCriterionKey
key :: Prelude.Maybe SearchResourcesSimpleCriterionKey,
    -- | The operator to use in the condition. Valid values are EQ (equals) and
    -- NE (not equals).
    SearchResourcesSimpleCriterion -> Maybe SearchResourcesComparator
comparator :: Prelude.Maybe SearchResourcesComparator
  }
  deriving (SearchResourcesSimpleCriterion
-> SearchResourcesSimpleCriterion -> Bool
(SearchResourcesSimpleCriterion
 -> SearchResourcesSimpleCriterion -> Bool)
-> (SearchResourcesSimpleCriterion
    -> SearchResourcesSimpleCriterion -> Bool)
-> Eq SearchResourcesSimpleCriterion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchResourcesSimpleCriterion
-> SearchResourcesSimpleCriterion -> Bool
$c/= :: SearchResourcesSimpleCriterion
-> SearchResourcesSimpleCriterion -> Bool
== :: SearchResourcesSimpleCriterion
-> SearchResourcesSimpleCriterion -> Bool
$c== :: SearchResourcesSimpleCriterion
-> SearchResourcesSimpleCriterion -> Bool
Prelude.Eq, ReadPrec [SearchResourcesSimpleCriterion]
ReadPrec SearchResourcesSimpleCriterion
Int -> ReadS SearchResourcesSimpleCriterion
ReadS [SearchResourcesSimpleCriterion]
(Int -> ReadS SearchResourcesSimpleCriterion)
-> ReadS [SearchResourcesSimpleCriterion]
-> ReadPrec SearchResourcesSimpleCriterion
-> ReadPrec [SearchResourcesSimpleCriterion]
-> Read SearchResourcesSimpleCriterion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchResourcesSimpleCriterion]
$creadListPrec :: ReadPrec [SearchResourcesSimpleCriterion]
readPrec :: ReadPrec SearchResourcesSimpleCriterion
$creadPrec :: ReadPrec SearchResourcesSimpleCriterion
readList :: ReadS [SearchResourcesSimpleCriterion]
$creadList :: ReadS [SearchResourcesSimpleCriterion]
readsPrec :: Int -> ReadS SearchResourcesSimpleCriterion
$creadsPrec :: Int -> ReadS SearchResourcesSimpleCriterion
Prelude.Read, Int -> SearchResourcesSimpleCriterion -> ShowS
[SearchResourcesSimpleCriterion] -> ShowS
SearchResourcesSimpleCriterion -> String
(Int -> SearchResourcesSimpleCriterion -> ShowS)
-> (SearchResourcesSimpleCriterion -> String)
-> ([SearchResourcesSimpleCriterion] -> ShowS)
-> Show SearchResourcesSimpleCriterion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchResourcesSimpleCriterion] -> ShowS
$cshowList :: [SearchResourcesSimpleCriterion] -> ShowS
show :: SearchResourcesSimpleCriterion -> String
$cshow :: SearchResourcesSimpleCriterion -> String
showsPrec :: Int -> SearchResourcesSimpleCriterion -> ShowS
$cshowsPrec :: Int -> SearchResourcesSimpleCriterion -> ShowS
Prelude.Show, (forall x.
 SearchResourcesSimpleCriterion
 -> Rep SearchResourcesSimpleCriterion x)
-> (forall x.
    Rep SearchResourcesSimpleCriterion x
    -> SearchResourcesSimpleCriterion)
-> Generic SearchResourcesSimpleCriterion
forall x.
Rep SearchResourcesSimpleCriterion x
-> SearchResourcesSimpleCriterion
forall x.
SearchResourcesSimpleCriterion
-> Rep SearchResourcesSimpleCriterion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SearchResourcesSimpleCriterion x
-> SearchResourcesSimpleCriterion
$cfrom :: forall x.
SearchResourcesSimpleCriterion
-> Rep SearchResourcesSimpleCriterion x
Prelude.Generic)

-- |
-- Create a value of 'SearchResourcesSimpleCriterion' 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', 'searchResourcesSimpleCriterion_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 resource.
--
-- -   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 an S3 bucket.
--
-- -   S3_BUCKET_NAME - A string that represents the name of an S3 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 an S3 bucket.
--
-- Values are case sensitive. Also, Macie doesn\'t support use of partial
-- values or wildcard characters in values.
--
-- 'key', 'searchResourcesSimpleCriterion_key' - The property to use in the condition.
--
-- 'comparator', 'searchResourcesSimpleCriterion_comparator' - The operator to use in the condition. Valid values are EQ (equals) and
-- NE (not equals).
newSearchResourcesSimpleCriterion ::
  SearchResourcesSimpleCriterion
newSearchResourcesSimpleCriterion :: SearchResourcesSimpleCriterion
newSearchResourcesSimpleCriterion =
  SearchResourcesSimpleCriterion' :: Maybe [Text]
-> Maybe SearchResourcesSimpleCriterionKey
-> Maybe SearchResourcesComparator
-> SearchResourcesSimpleCriterion
SearchResourcesSimpleCriterion'
    { $sel:values:SearchResourcesSimpleCriterion' :: Maybe [Text]
values =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:key:SearchResourcesSimpleCriterion' :: Maybe SearchResourcesSimpleCriterionKey
key = Maybe SearchResourcesSimpleCriterionKey
forall a. Maybe a
Prelude.Nothing,
      $sel:comparator:SearchResourcesSimpleCriterion' :: Maybe SearchResourcesComparator
comparator = Maybe SearchResourcesComparator
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 resource.
--
-- -   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 an S3 bucket.
--
-- -   S3_BUCKET_NAME - A string that represents the name of an S3 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 an S3 bucket.
--
-- Values are case sensitive. Also, Macie doesn\'t support use of partial
-- values or wildcard characters in values.
searchResourcesSimpleCriterion_values :: Lens.Lens' SearchResourcesSimpleCriterion (Prelude.Maybe [Prelude.Text])
searchResourcesSimpleCriterion_values :: (Maybe [Text] -> f (Maybe [Text]))
-> SearchResourcesSimpleCriterion
-> f SearchResourcesSimpleCriterion
searchResourcesSimpleCriterion_values = (SearchResourcesSimpleCriterion -> Maybe [Text])
-> (SearchResourcesSimpleCriterion
    -> Maybe [Text] -> SearchResourcesSimpleCriterion)
-> Lens
     SearchResourcesSimpleCriterion
     SearchResourcesSimpleCriterion
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResourcesSimpleCriterion' {Maybe [Text]
values :: Maybe [Text]
$sel:values:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: SearchResourcesSimpleCriterion
s@SearchResourcesSimpleCriterion' {} Maybe [Text]
a -> SearchResourcesSimpleCriterion
s {$sel:values:SearchResourcesSimpleCriterion' :: Maybe [Text]
values = Maybe [Text]
a} :: SearchResourcesSimpleCriterion) ((Maybe [Text] -> f (Maybe [Text]))
 -> SearchResourcesSimpleCriterion
 -> f SearchResourcesSimpleCriterion)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SearchResourcesSimpleCriterion
-> f SearchResourcesSimpleCriterion
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.
searchResourcesSimpleCriterion_key :: Lens.Lens' SearchResourcesSimpleCriterion (Prelude.Maybe SearchResourcesSimpleCriterionKey)
searchResourcesSimpleCriterion_key :: (Maybe SearchResourcesSimpleCriterionKey
 -> f (Maybe SearchResourcesSimpleCriterionKey))
-> SearchResourcesSimpleCriterion
-> f SearchResourcesSimpleCriterion
searchResourcesSimpleCriterion_key = (SearchResourcesSimpleCriterion
 -> Maybe SearchResourcesSimpleCriterionKey)
-> (SearchResourcesSimpleCriterion
    -> Maybe SearchResourcesSimpleCriterionKey
    -> SearchResourcesSimpleCriterion)
-> Lens
     SearchResourcesSimpleCriterion
     SearchResourcesSimpleCriterion
     (Maybe SearchResourcesSimpleCriterionKey)
     (Maybe SearchResourcesSimpleCriterionKey)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResourcesSimpleCriterion' {Maybe SearchResourcesSimpleCriterionKey
key :: Maybe SearchResourcesSimpleCriterionKey
$sel:key:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion
-> Maybe SearchResourcesSimpleCriterionKey
key} -> Maybe SearchResourcesSimpleCriterionKey
key) (\s :: SearchResourcesSimpleCriterion
s@SearchResourcesSimpleCriterion' {} Maybe SearchResourcesSimpleCriterionKey
a -> SearchResourcesSimpleCriterion
s {$sel:key:SearchResourcesSimpleCriterion' :: Maybe SearchResourcesSimpleCriterionKey
key = Maybe SearchResourcesSimpleCriterionKey
a} :: SearchResourcesSimpleCriterion)

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

instance
  Prelude.Hashable
    SearchResourcesSimpleCriterion

instance
  Prelude.NFData
    SearchResourcesSimpleCriterion

instance Core.ToJSON SearchResourcesSimpleCriterion where
  toJSON :: SearchResourcesSimpleCriterion -> Value
toJSON SearchResourcesSimpleCriterion' {Maybe [Text]
Maybe SearchResourcesComparator
Maybe SearchResourcesSimpleCriterionKey
comparator :: Maybe SearchResourcesComparator
key :: Maybe SearchResourcesSimpleCriterionKey
values :: Maybe [Text]
$sel:comparator:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion -> Maybe SearchResourcesComparator
$sel:key:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion
-> Maybe SearchResourcesSimpleCriterionKey
$sel:values:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion -> 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 -> SearchResourcesSimpleCriterionKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SearchResourcesSimpleCriterionKey -> Pair)
-> Maybe SearchResourcesSimpleCriterionKey -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SearchResourcesSimpleCriterionKey
key,
            (Text
"comparator" Text -> SearchResourcesComparator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SearchResourcesComparator -> Pair)
-> Maybe SearchResourcesComparator -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SearchResourcesComparator
comparator
          ]
      )