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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.SearchResourcesCriteria
import qualified Amazonka.Prelude as Prelude

-- | Specifies property- and tag-based conditions that define filter criteria
-- for including or excluding Amazon Web Services resources from the query
-- results.
--
-- /See:/ 'newSearchResourcesCriteriaBlock' smart constructor.
data SearchResourcesCriteriaBlock = SearchResourcesCriteriaBlock'
  { -- | An array of objects, one for each property- or tag-based condition that
    -- includes or excludes resources from the query results. If you specify
    -- more than one condition, Amazon Macie uses AND logic to join the
    -- conditions.
    SearchResourcesCriteriaBlock -> Maybe [SearchResourcesCriteria]
and :: Prelude.Maybe [SearchResourcesCriteria]
  }
  deriving (SearchResourcesCriteriaBlock
-> SearchResourcesCriteriaBlock -> Bool
(SearchResourcesCriteriaBlock
 -> SearchResourcesCriteriaBlock -> Bool)
-> (SearchResourcesCriteriaBlock
    -> SearchResourcesCriteriaBlock -> Bool)
-> Eq SearchResourcesCriteriaBlock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchResourcesCriteriaBlock
-> SearchResourcesCriteriaBlock -> Bool
$c/= :: SearchResourcesCriteriaBlock
-> SearchResourcesCriteriaBlock -> Bool
== :: SearchResourcesCriteriaBlock
-> SearchResourcesCriteriaBlock -> Bool
$c== :: SearchResourcesCriteriaBlock
-> SearchResourcesCriteriaBlock -> Bool
Prelude.Eq, ReadPrec [SearchResourcesCriteriaBlock]
ReadPrec SearchResourcesCriteriaBlock
Int -> ReadS SearchResourcesCriteriaBlock
ReadS [SearchResourcesCriteriaBlock]
(Int -> ReadS SearchResourcesCriteriaBlock)
-> ReadS [SearchResourcesCriteriaBlock]
-> ReadPrec SearchResourcesCriteriaBlock
-> ReadPrec [SearchResourcesCriteriaBlock]
-> Read SearchResourcesCriteriaBlock
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchResourcesCriteriaBlock]
$creadListPrec :: ReadPrec [SearchResourcesCriteriaBlock]
readPrec :: ReadPrec SearchResourcesCriteriaBlock
$creadPrec :: ReadPrec SearchResourcesCriteriaBlock
readList :: ReadS [SearchResourcesCriteriaBlock]
$creadList :: ReadS [SearchResourcesCriteriaBlock]
readsPrec :: Int -> ReadS SearchResourcesCriteriaBlock
$creadsPrec :: Int -> ReadS SearchResourcesCriteriaBlock
Prelude.Read, Int -> SearchResourcesCriteriaBlock -> ShowS
[SearchResourcesCriteriaBlock] -> ShowS
SearchResourcesCriteriaBlock -> String
(Int -> SearchResourcesCriteriaBlock -> ShowS)
-> (SearchResourcesCriteriaBlock -> String)
-> ([SearchResourcesCriteriaBlock] -> ShowS)
-> Show SearchResourcesCriteriaBlock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchResourcesCriteriaBlock] -> ShowS
$cshowList :: [SearchResourcesCriteriaBlock] -> ShowS
show :: SearchResourcesCriteriaBlock -> String
$cshow :: SearchResourcesCriteriaBlock -> String
showsPrec :: Int -> SearchResourcesCriteriaBlock -> ShowS
$cshowsPrec :: Int -> SearchResourcesCriteriaBlock -> ShowS
Prelude.Show, (forall x.
 SearchResourcesCriteriaBlock -> Rep SearchResourcesCriteriaBlock x)
-> (forall x.
    Rep SearchResourcesCriteriaBlock x -> SearchResourcesCriteriaBlock)
-> Generic SearchResourcesCriteriaBlock
forall x.
Rep SearchResourcesCriteriaBlock x -> SearchResourcesCriteriaBlock
forall x.
SearchResourcesCriteriaBlock -> Rep SearchResourcesCriteriaBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SearchResourcesCriteriaBlock x -> SearchResourcesCriteriaBlock
$cfrom :: forall x.
SearchResourcesCriteriaBlock -> Rep SearchResourcesCriteriaBlock x
Prelude.Generic)

-- |
-- Create a value of 'SearchResourcesCriteriaBlock' 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:
--
-- 'and', 'searchResourcesCriteriaBlock_and' - An array of objects, one for each property- or tag-based condition that
-- includes or excludes resources from the query results. If you specify
-- more than one condition, Amazon Macie uses AND logic to join the
-- conditions.
newSearchResourcesCriteriaBlock ::
  SearchResourcesCriteriaBlock
newSearchResourcesCriteriaBlock :: SearchResourcesCriteriaBlock
newSearchResourcesCriteriaBlock =
  SearchResourcesCriteriaBlock' :: Maybe [SearchResourcesCriteria] -> SearchResourcesCriteriaBlock
SearchResourcesCriteriaBlock'
    { $sel:and:SearchResourcesCriteriaBlock' :: Maybe [SearchResourcesCriteria]
and =
        Maybe [SearchResourcesCriteria]
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of objects, one for each property- or tag-based condition that
-- includes or excludes resources from the query results. If you specify
-- more than one condition, Amazon Macie uses AND logic to join the
-- conditions.
searchResourcesCriteriaBlock_and :: Lens.Lens' SearchResourcesCriteriaBlock (Prelude.Maybe [SearchResourcesCriteria])
searchResourcesCriteriaBlock_and :: (Maybe [SearchResourcesCriteria]
 -> f (Maybe [SearchResourcesCriteria]))
-> SearchResourcesCriteriaBlock -> f SearchResourcesCriteriaBlock
searchResourcesCriteriaBlock_and = (SearchResourcesCriteriaBlock -> Maybe [SearchResourcesCriteria])
-> (SearchResourcesCriteriaBlock
    -> Maybe [SearchResourcesCriteria] -> SearchResourcesCriteriaBlock)
-> Lens
     SearchResourcesCriteriaBlock
     SearchResourcesCriteriaBlock
     (Maybe [SearchResourcesCriteria])
     (Maybe [SearchResourcesCriteria])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResourcesCriteriaBlock' {Maybe [SearchResourcesCriteria]
and :: Maybe [SearchResourcesCriteria]
$sel:and:SearchResourcesCriteriaBlock' :: SearchResourcesCriteriaBlock -> Maybe [SearchResourcesCriteria]
and} -> Maybe [SearchResourcesCriteria]
and) (\s :: SearchResourcesCriteriaBlock
s@SearchResourcesCriteriaBlock' {} Maybe [SearchResourcesCriteria]
a -> SearchResourcesCriteriaBlock
s {$sel:and:SearchResourcesCriteriaBlock' :: Maybe [SearchResourcesCriteria]
and = Maybe [SearchResourcesCriteria]
a} :: SearchResourcesCriteriaBlock) ((Maybe [SearchResourcesCriteria]
  -> f (Maybe [SearchResourcesCriteria]))
 -> SearchResourcesCriteriaBlock -> f SearchResourcesCriteriaBlock)
-> ((Maybe [SearchResourcesCriteria]
     -> f (Maybe [SearchResourcesCriteria]))
    -> Maybe [SearchResourcesCriteria]
    -> f (Maybe [SearchResourcesCriteria]))
-> (Maybe [SearchResourcesCriteria]
    -> f (Maybe [SearchResourcesCriteria]))
-> SearchResourcesCriteriaBlock
-> f SearchResourcesCriteriaBlock
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SearchResourcesCriteria]
  [SearchResourcesCriteria]
  [SearchResourcesCriteria]
  [SearchResourcesCriteria]
-> Iso
     (Maybe [SearchResourcesCriteria])
     (Maybe [SearchResourcesCriteria])
     (Maybe [SearchResourcesCriteria])
     (Maybe [SearchResourcesCriteria])
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
  [SearchResourcesCriteria]
  [SearchResourcesCriteria]
  [SearchResourcesCriteria]
  [SearchResourcesCriteria]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.Hashable
    SearchResourcesCriteriaBlock

instance Prelude.NFData SearchResourcesCriteriaBlock

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