{-# 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.ResourceExplorer2.Types.SearchFilter
-- 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.ResourceExplorer2.Types.SearchFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A search filter defines which resources can be part of a search query
-- result set.
--
-- /See:/ 'newSearchFilter' smart constructor.
data SearchFilter = SearchFilter'
  { -- | The string that contains the search keywords, prefixes, and operators to
    -- control the results that can be returned by a Search operation. For more
    -- details, see
    -- <https://docs.aws.amazon.com/resource-explorer/latest/APIReference/about-query-syntax.html Search query syntax>.
    SearchFilter -> Text
filterString :: Prelude.Text
  }
  deriving (SearchFilter -> SearchFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchFilter -> SearchFilter -> Bool
$c/= :: SearchFilter -> SearchFilter -> Bool
== :: SearchFilter -> SearchFilter -> Bool
$c== :: SearchFilter -> SearchFilter -> Bool
Prelude.Eq, Int -> SearchFilter -> ShowS
[SearchFilter] -> ShowS
SearchFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchFilter] -> ShowS
$cshowList :: [SearchFilter] -> ShowS
show :: SearchFilter -> String
$cshow :: SearchFilter -> String
showsPrec :: Int -> SearchFilter -> ShowS
$cshowsPrec :: Int -> SearchFilter -> ShowS
Prelude.Show, forall x. Rep SearchFilter x -> SearchFilter
forall x. SearchFilter -> Rep SearchFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchFilter x -> SearchFilter
$cfrom :: forall x. SearchFilter -> Rep SearchFilter x
Prelude.Generic)

-- |
-- Create a value of 'SearchFilter' 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:
--
-- 'filterString', 'searchFilter_filterString' - The string that contains the search keywords, prefixes, and operators to
-- control the results that can be returned by a Search operation. For more
-- details, see
-- <https://docs.aws.amazon.com/resource-explorer/latest/APIReference/about-query-syntax.html Search query syntax>.
newSearchFilter ::
  -- | 'filterString'
  Prelude.Text ->
  SearchFilter
newSearchFilter :: Text -> SearchFilter
newSearchFilter Text
pFilterString_ =
  SearchFilter' {$sel:filterString:SearchFilter' :: Text
filterString = Text
pFilterString_}

-- | The string that contains the search keywords, prefixes, and operators to
-- control the results that can be returned by a Search operation. For more
-- details, see
-- <https://docs.aws.amazon.com/resource-explorer/latest/APIReference/about-query-syntax.html Search query syntax>.
searchFilter_filterString :: Lens.Lens' SearchFilter Prelude.Text
searchFilter_filterString :: Lens' SearchFilter Text
searchFilter_filterString = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFilter' {Text
filterString :: Text
$sel:filterString:SearchFilter' :: SearchFilter -> Text
filterString} -> Text
filterString) (\s :: SearchFilter
s@SearchFilter' {} Text
a -> SearchFilter
s {$sel:filterString:SearchFilter' :: Text
filterString = Text
a} :: SearchFilter)

instance Data.FromJSON SearchFilter where
  parseJSON :: Value -> Parser SearchFilter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SearchFilter"
      ( \Object
x ->
          Text -> SearchFilter
SearchFilter' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FilterString")
      )

instance Prelude.Hashable SearchFilter where
  hashWithSalt :: Int -> SearchFilter -> Int
hashWithSalt Int
_salt SearchFilter' {Text
filterString :: Text
$sel:filterString:SearchFilter' :: SearchFilter -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
filterString

instance Prelude.NFData SearchFilter where
  rnf :: SearchFilter -> ()
rnf SearchFilter' {Text
filterString :: Text
$sel:filterString:SearchFilter' :: SearchFilter -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
filterString

instance Data.ToJSON SearchFilter where
  toJSON :: SearchFilter -> Value
toJSON SearchFilter' {Text
filterString :: Text
$sel:filterString:SearchFilter' :: SearchFilter -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"FilterString" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
filterString)]
      )