{-# 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-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.SearchResourcesSimpleCriterion 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.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'
  { -- | The operator to use in the condition. Valid values are EQ (equals) and
    -- NE (not equals).
    SearchResourcesSimpleCriterion -> Maybe SearchResourcesComparator
comparator :: Prelude.Maybe SearchResourcesComparator,
    -- | The property to use in the condition.
    SearchResourcesSimpleCriterion
-> Maybe SearchResourcesSimpleCriterionKey
key :: Prelude.Maybe SearchResourcesSimpleCriterionKey,
    -- | 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]
  }
  deriving (SearchResourcesSimpleCriterion
-> SearchResourcesSimpleCriterion -> Bool
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]
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
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.
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:
--
-- 'comparator', 'searchResourcesSimpleCriterion_comparator' - The operator to use in the condition. Valid values are EQ (equals) and
-- NE (not equals).
--
-- 'key', 'searchResourcesSimpleCriterion_key' - The property to use in the condition.
--
-- '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.
newSearchResourcesSimpleCriterion ::
  SearchResourcesSimpleCriterion
newSearchResourcesSimpleCriterion :: SearchResourcesSimpleCriterion
newSearchResourcesSimpleCriterion =
  SearchResourcesSimpleCriterion'
    { $sel:comparator:SearchResourcesSimpleCriterion' :: Maybe SearchResourcesComparator
comparator =
        forall a. Maybe a
Prelude.Nothing,
      $sel:key:SearchResourcesSimpleCriterion' :: Maybe SearchResourcesSimpleCriterionKey
key = forall a. Maybe a
Prelude.Nothing,
      $sel:values:SearchResourcesSimpleCriterion' :: 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).
searchResourcesSimpleCriterion_comparator :: Lens.Lens' SearchResourcesSimpleCriterion (Prelude.Maybe SearchResourcesComparator)
searchResourcesSimpleCriterion_comparator :: Lens'
  SearchResourcesSimpleCriterion (Maybe SearchResourcesComparator)
searchResourcesSimpleCriterion_comparator = 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)

-- | The property to use in the condition.
searchResourcesSimpleCriterion_key :: Lens.Lens' SearchResourcesSimpleCriterion (Prelude.Maybe SearchResourcesSimpleCriterionKey)
searchResourcesSimpleCriterion_key :: Lens'
  SearchResourcesSimpleCriterion
  (Maybe SearchResourcesSimpleCriterionKey)
searchResourcesSimpleCriterion_key = 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)

-- | 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 :: Lens' SearchResourcesSimpleCriterion (Maybe [Text])
searchResourcesSimpleCriterion_values = 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) 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
  Prelude.Hashable
    SearchResourcesSimpleCriterion
  where
  hashWithSalt :: Int -> SearchResourcesSimpleCriterion -> Int
hashWithSalt
    Int
_salt
    SearchResourcesSimpleCriterion' {Maybe [Text]
Maybe SearchResourcesComparator
Maybe SearchResourcesSimpleCriterionKey
values :: Maybe [Text]
key :: Maybe SearchResourcesSimpleCriterionKey
comparator :: Maybe SearchResourcesComparator
$sel:values:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion -> Maybe [Text]
$sel:key:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion
-> Maybe SearchResourcesSimpleCriterionKey
$sel:comparator:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion -> Maybe SearchResourcesComparator
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SearchResourcesComparator
comparator
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SearchResourcesSimpleCriterionKey
key
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

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

instance Data.ToJSON SearchResourcesSimpleCriterion where
  toJSON :: SearchResourcesSimpleCriterion -> Value
toJSON SearchResourcesSimpleCriterion' {Maybe [Text]
Maybe SearchResourcesComparator
Maybe SearchResourcesSimpleCriterionKey
values :: Maybe [Text]
key :: Maybe SearchResourcesSimpleCriterionKey
comparator :: Maybe SearchResourcesComparator
$sel:values:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion -> Maybe [Text]
$sel:key:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion
-> Maybe SearchResourcesSimpleCriterionKey
$sel:comparator:SearchResourcesSimpleCriterion' :: SearchResourcesSimpleCriterion -> Maybe SearchResourcesComparator
..} =
    [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 SearchResourcesComparator
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 SearchResourcesSimpleCriterionKey
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
          ]
      )