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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.SearchResourcesSimpleCriterion
import Amazonka.MacieV2.Types.SearchResourcesTagCriterion
import qualified Amazonka.Prelude as Prelude

-- | Specifies a property- or tag-based filter condition for including or
-- excluding Amazon Web Services resources from the query results.
--
-- /See:/ 'newSearchResourcesCriteria' smart constructor.
data SearchResourcesCriteria = SearchResourcesCriteria'
  { -- | A tag-based condition that defines an operator and tag keys, tag values,
    -- or tag key and value pairs for including or excluding resources from the
    -- results.
    SearchResourcesCriteria -> Maybe SearchResourcesTagCriterion
tagCriterion :: Prelude.Maybe SearchResourcesTagCriterion,
    -- | A property-based condition that defines a property, operator, and one or
    -- more values for including or excluding resources from the results.
    SearchResourcesCriteria -> Maybe SearchResourcesSimpleCriterion
simpleCriterion :: Prelude.Maybe SearchResourcesSimpleCriterion
  }
  deriving (SearchResourcesCriteria -> SearchResourcesCriteria -> Bool
(SearchResourcesCriteria -> SearchResourcesCriteria -> Bool)
-> (SearchResourcesCriteria -> SearchResourcesCriteria -> Bool)
-> Eq SearchResourcesCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchResourcesCriteria -> SearchResourcesCriteria -> Bool
$c/= :: SearchResourcesCriteria -> SearchResourcesCriteria -> Bool
== :: SearchResourcesCriteria -> SearchResourcesCriteria -> Bool
$c== :: SearchResourcesCriteria -> SearchResourcesCriteria -> Bool
Prelude.Eq, ReadPrec [SearchResourcesCriteria]
ReadPrec SearchResourcesCriteria
Int -> ReadS SearchResourcesCriteria
ReadS [SearchResourcesCriteria]
(Int -> ReadS SearchResourcesCriteria)
-> ReadS [SearchResourcesCriteria]
-> ReadPrec SearchResourcesCriteria
-> ReadPrec [SearchResourcesCriteria]
-> Read SearchResourcesCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchResourcesCriteria]
$creadListPrec :: ReadPrec [SearchResourcesCriteria]
readPrec :: ReadPrec SearchResourcesCriteria
$creadPrec :: ReadPrec SearchResourcesCriteria
readList :: ReadS [SearchResourcesCriteria]
$creadList :: ReadS [SearchResourcesCriteria]
readsPrec :: Int -> ReadS SearchResourcesCriteria
$creadsPrec :: Int -> ReadS SearchResourcesCriteria
Prelude.Read, Int -> SearchResourcesCriteria -> ShowS
[SearchResourcesCriteria] -> ShowS
SearchResourcesCriteria -> String
(Int -> SearchResourcesCriteria -> ShowS)
-> (SearchResourcesCriteria -> String)
-> ([SearchResourcesCriteria] -> ShowS)
-> Show SearchResourcesCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchResourcesCriteria] -> ShowS
$cshowList :: [SearchResourcesCriteria] -> ShowS
show :: SearchResourcesCriteria -> String
$cshow :: SearchResourcesCriteria -> String
showsPrec :: Int -> SearchResourcesCriteria -> ShowS
$cshowsPrec :: Int -> SearchResourcesCriteria -> ShowS
Prelude.Show, (forall x.
 SearchResourcesCriteria -> Rep SearchResourcesCriteria x)
-> (forall x.
    Rep SearchResourcesCriteria x -> SearchResourcesCriteria)
-> Generic SearchResourcesCriteria
forall x. Rep SearchResourcesCriteria x -> SearchResourcesCriteria
forall x. SearchResourcesCriteria -> Rep SearchResourcesCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchResourcesCriteria x -> SearchResourcesCriteria
$cfrom :: forall x. SearchResourcesCriteria -> Rep SearchResourcesCriteria x
Prelude.Generic)

-- |
-- Create a value of 'SearchResourcesCriteria' 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:
--
-- 'tagCriterion', 'searchResourcesCriteria_tagCriterion' - A tag-based condition that defines an operator and tag keys, tag values,
-- or tag key and value pairs for including or excluding resources from the
-- results.
--
-- 'simpleCriterion', 'searchResourcesCriteria_simpleCriterion' - A property-based condition that defines a property, operator, and one or
-- more values for including or excluding resources from the results.
newSearchResourcesCriteria ::
  SearchResourcesCriteria
newSearchResourcesCriteria :: SearchResourcesCriteria
newSearchResourcesCriteria =
  SearchResourcesCriteria' :: Maybe SearchResourcesTagCriterion
-> Maybe SearchResourcesSimpleCriterion -> SearchResourcesCriteria
SearchResourcesCriteria'
    { $sel:tagCriterion:SearchResourcesCriteria' :: Maybe SearchResourcesTagCriterion
tagCriterion =
        Maybe SearchResourcesTagCriterion
forall a. Maybe a
Prelude.Nothing,
      $sel:simpleCriterion:SearchResourcesCriteria' :: Maybe SearchResourcesSimpleCriterion
simpleCriterion = Maybe SearchResourcesSimpleCriterion
forall a. Maybe a
Prelude.Nothing
    }

-- | A tag-based condition that defines an operator and tag keys, tag values,
-- or tag key and value pairs for including or excluding resources from the
-- results.
searchResourcesCriteria_tagCriterion :: Lens.Lens' SearchResourcesCriteria (Prelude.Maybe SearchResourcesTagCriterion)
searchResourcesCriteria_tagCriterion :: (Maybe SearchResourcesTagCriterion
 -> f (Maybe SearchResourcesTagCriterion))
-> SearchResourcesCriteria -> f SearchResourcesCriteria
searchResourcesCriteria_tagCriterion = (SearchResourcesCriteria -> Maybe SearchResourcesTagCriterion)
-> (SearchResourcesCriteria
    -> Maybe SearchResourcesTagCriterion -> SearchResourcesCriteria)
-> Lens
     SearchResourcesCriteria
     SearchResourcesCriteria
     (Maybe SearchResourcesTagCriterion)
     (Maybe SearchResourcesTagCriterion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResourcesCriteria' {Maybe SearchResourcesTagCriterion
tagCriterion :: Maybe SearchResourcesTagCriterion
$sel:tagCriterion:SearchResourcesCriteria' :: SearchResourcesCriteria -> Maybe SearchResourcesTagCriterion
tagCriterion} -> Maybe SearchResourcesTagCriterion
tagCriterion) (\s :: SearchResourcesCriteria
s@SearchResourcesCriteria' {} Maybe SearchResourcesTagCriterion
a -> SearchResourcesCriteria
s {$sel:tagCriterion:SearchResourcesCriteria' :: Maybe SearchResourcesTagCriterion
tagCriterion = Maybe SearchResourcesTagCriterion
a} :: SearchResourcesCriteria)

-- | A property-based condition that defines a property, operator, and one or
-- more values for including or excluding resources from the results.
searchResourcesCriteria_simpleCriterion :: Lens.Lens' SearchResourcesCriteria (Prelude.Maybe SearchResourcesSimpleCriterion)
searchResourcesCriteria_simpleCriterion :: (Maybe SearchResourcesSimpleCriterion
 -> f (Maybe SearchResourcesSimpleCriterion))
-> SearchResourcesCriteria -> f SearchResourcesCriteria
searchResourcesCriteria_simpleCriterion = (SearchResourcesCriteria -> Maybe SearchResourcesSimpleCriterion)
-> (SearchResourcesCriteria
    -> Maybe SearchResourcesSimpleCriterion -> SearchResourcesCriteria)
-> Lens
     SearchResourcesCriteria
     SearchResourcesCriteria
     (Maybe SearchResourcesSimpleCriterion)
     (Maybe SearchResourcesSimpleCriterion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResourcesCriteria' {Maybe SearchResourcesSimpleCriterion
simpleCriterion :: Maybe SearchResourcesSimpleCriterion
$sel:simpleCriterion:SearchResourcesCriteria' :: SearchResourcesCriteria -> Maybe SearchResourcesSimpleCriterion
simpleCriterion} -> Maybe SearchResourcesSimpleCriterion
simpleCriterion) (\s :: SearchResourcesCriteria
s@SearchResourcesCriteria' {} Maybe SearchResourcesSimpleCriterion
a -> SearchResourcesCriteria
s {$sel:simpleCriterion:SearchResourcesCriteria' :: Maybe SearchResourcesSimpleCriterion
simpleCriterion = Maybe SearchResourcesSimpleCriterion
a} :: SearchResourcesCriteria)

instance Prelude.Hashable SearchResourcesCriteria

instance Prelude.NFData SearchResourcesCriteria

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