{-# 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.SearchResourcesBucketCriteria
-- 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.SearchResourcesBucketCriteria 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.SearchResourcesCriteriaBlock
import qualified Amazonka.Prelude as Prelude

-- | Specifies property- and tag-based conditions that define filter criteria
-- for including or excluding S3 buckets from the query results. Exclude
-- conditions take precedence over include conditions.
--
-- /See:/ 'newSearchResourcesBucketCriteria' smart constructor.
data SearchResourcesBucketCriteria = SearchResourcesBucketCriteria'
  { -- | The property- and tag-based conditions that determine which buckets to
    -- exclude from the results.
    SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
excludes :: Prelude.Maybe SearchResourcesCriteriaBlock,
    -- | The property- and tag-based conditions that determine which buckets to
    -- include in the results.
    SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
includes :: Prelude.Maybe SearchResourcesCriteriaBlock
  }
  deriving (SearchResourcesBucketCriteria
-> SearchResourcesBucketCriteria -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchResourcesBucketCriteria
-> SearchResourcesBucketCriteria -> Bool
$c/= :: SearchResourcesBucketCriteria
-> SearchResourcesBucketCriteria -> Bool
== :: SearchResourcesBucketCriteria
-> SearchResourcesBucketCriteria -> Bool
$c== :: SearchResourcesBucketCriteria
-> SearchResourcesBucketCriteria -> Bool
Prelude.Eq, ReadPrec [SearchResourcesBucketCriteria]
ReadPrec SearchResourcesBucketCriteria
Int -> ReadS SearchResourcesBucketCriteria
ReadS [SearchResourcesBucketCriteria]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchResourcesBucketCriteria]
$creadListPrec :: ReadPrec [SearchResourcesBucketCriteria]
readPrec :: ReadPrec SearchResourcesBucketCriteria
$creadPrec :: ReadPrec SearchResourcesBucketCriteria
readList :: ReadS [SearchResourcesBucketCriteria]
$creadList :: ReadS [SearchResourcesBucketCriteria]
readsPrec :: Int -> ReadS SearchResourcesBucketCriteria
$creadsPrec :: Int -> ReadS SearchResourcesBucketCriteria
Prelude.Read, Int -> SearchResourcesBucketCriteria -> ShowS
[SearchResourcesBucketCriteria] -> ShowS
SearchResourcesBucketCriteria -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchResourcesBucketCriteria] -> ShowS
$cshowList :: [SearchResourcesBucketCriteria] -> ShowS
show :: SearchResourcesBucketCriteria -> String
$cshow :: SearchResourcesBucketCriteria -> String
showsPrec :: Int -> SearchResourcesBucketCriteria -> ShowS
$cshowsPrec :: Int -> SearchResourcesBucketCriteria -> ShowS
Prelude.Show, forall x.
Rep SearchResourcesBucketCriteria x
-> SearchResourcesBucketCriteria
forall x.
SearchResourcesBucketCriteria
-> Rep SearchResourcesBucketCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SearchResourcesBucketCriteria x
-> SearchResourcesBucketCriteria
$cfrom :: forall x.
SearchResourcesBucketCriteria
-> Rep SearchResourcesBucketCriteria x
Prelude.Generic)

-- |
-- Create a value of 'SearchResourcesBucketCriteria' 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:
--
-- 'excludes', 'searchResourcesBucketCriteria_excludes' - The property- and tag-based conditions that determine which buckets to
-- exclude from the results.
--
-- 'includes', 'searchResourcesBucketCriteria_includes' - The property- and tag-based conditions that determine which buckets to
-- include in the results.
newSearchResourcesBucketCriteria ::
  SearchResourcesBucketCriteria
newSearchResourcesBucketCriteria :: SearchResourcesBucketCriteria
newSearchResourcesBucketCriteria =
  SearchResourcesBucketCriteria'
    { $sel:excludes:SearchResourcesBucketCriteria' :: Maybe SearchResourcesCriteriaBlock
excludes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:includes:SearchResourcesBucketCriteria' :: Maybe SearchResourcesCriteriaBlock
includes = forall a. Maybe a
Prelude.Nothing
    }

-- | The property- and tag-based conditions that determine which buckets to
-- exclude from the results.
searchResourcesBucketCriteria_excludes :: Lens.Lens' SearchResourcesBucketCriteria (Prelude.Maybe SearchResourcesCriteriaBlock)
searchResourcesBucketCriteria_excludes :: Lens'
  SearchResourcesBucketCriteria (Maybe SearchResourcesCriteriaBlock)
searchResourcesBucketCriteria_excludes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResourcesBucketCriteria' {Maybe SearchResourcesCriteriaBlock
excludes :: Maybe SearchResourcesCriteriaBlock
$sel:excludes:SearchResourcesBucketCriteria' :: SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
excludes} -> Maybe SearchResourcesCriteriaBlock
excludes) (\s :: SearchResourcesBucketCriteria
s@SearchResourcesBucketCriteria' {} Maybe SearchResourcesCriteriaBlock
a -> SearchResourcesBucketCriteria
s {$sel:excludes:SearchResourcesBucketCriteria' :: Maybe SearchResourcesCriteriaBlock
excludes = Maybe SearchResourcesCriteriaBlock
a} :: SearchResourcesBucketCriteria)

-- | The property- and tag-based conditions that determine which buckets to
-- include in the results.
searchResourcesBucketCriteria_includes :: Lens.Lens' SearchResourcesBucketCriteria (Prelude.Maybe SearchResourcesCriteriaBlock)
searchResourcesBucketCriteria_includes :: Lens'
  SearchResourcesBucketCriteria (Maybe SearchResourcesCriteriaBlock)
searchResourcesBucketCriteria_includes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResourcesBucketCriteria' {Maybe SearchResourcesCriteriaBlock
includes :: Maybe SearchResourcesCriteriaBlock
$sel:includes:SearchResourcesBucketCriteria' :: SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
includes} -> Maybe SearchResourcesCriteriaBlock
includes) (\s :: SearchResourcesBucketCriteria
s@SearchResourcesBucketCriteria' {} Maybe SearchResourcesCriteriaBlock
a -> SearchResourcesBucketCriteria
s {$sel:includes:SearchResourcesBucketCriteria' :: Maybe SearchResourcesCriteriaBlock
includes = Maybe SearchResourcesCriteriaBlock
a} :: SearchResourcesBucketCriteria)

instance
  Prelude.Hashable
    SearchResourcesBucketCriteria
  where
  hashWithSalt :: Int -> SearchResourcesBucketCriteria -> Int
hashWithSalt Int
_salt SearchResourcesBucketCriteria' {Maybe SearchResourcesCriteriaBlock
includes :: Maybe SearchResourcesCriteriaBlock
excludes :: Maybe SearchResourcesCriteriaBlock
$sel:includes:SearchResourcesBucketCriteria' :: SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
$sel:excludes:SearchResourcesBucketCriteria' :: SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SearchResourcesCriteriaBlock
excludes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SearchResourcesCriteriaBlock
includes

instance Prelude.NFData SearchResourcesBucketCriteria where
  rnf :: SearchResourcesBucketCriteria -> ()
rnf SearchResourcesBucketCriteria' {Maybe SearchResourcesCriteriaBlock
includes :: Maybe SearchResourcesCriteriaBlock
excludes :: Maybe SearchResourcesCriteriaBlock
$sel:includes:SearchResourcesBucketCriteria' :: SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
$sel:excludes:SearchResourcesBucketCriteria' :: SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SearchResourcesCriteriaBlock
excludes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SearchResourcesCriteriaBlock
includes

instance Data.ToJSON SearchResourcesBucketCriteria where
  toJSON :: SearchResourcesBucketCriteria -> Value
toJSON SearchResourcesBucketCriteria' {Maybe SearchResourcesCriteriaBlock
includes :: Maybe SearchResourcesCriteriaBlock
excludes :: Maybe SearchResourcesCriteriaBlock
$sel:includes:SearchResourcesBucketCriteria' :: SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
$sel:excludes:SearchResourcesBucketCriteria' :: SearchResourcesBucketCriteria -> Maybe SearchResourcesCriteriaBlock
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"excludes" 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 SearchResourcesCriteriaBlock
excludes,
            (Key
"includes" 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 SearchResourcesCriteriaBlock
includes
          ]
      )