{-# 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.QuickSight.Types.GroupSearchFilter
-- 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.QuickSight.Types.GroupSearchFilter 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
import Amazonka.QuickSight.Types.GroupFilterAttribute
import Amazonka.QuickSight.Types.GroupFilterOperator

-- | A @GroupSearchFilter@ object that you want to apply to your search.
--
-- /See:/ 'newGroupSearchFilter' smart constructor.
data GroupSearchFilter = GroupSearchFilter'
  { -- | The comparison operator that you want to use as a filter, for example
    -- @\"Operator\": \"StartsWith\"@. Currently, the only supported operator
    -- is @StartsWith@.
    GroupSearchFilter -> GroupFilterOperator
operator :: GroupFilterOperator,
    -- | The name of the value that you want to use as a filter, for example
    -- @\"Name\": \"GROUP_NAME\"@. Currently, the only supported name is
    -- @GROUP_NAME@.
    GroupSearchFilter -> GroupFilterAttribute
name :: GroupFilterAttribute,
    -- | The value of the named item, in this case @GROUP_NAME@, that you want to
    -- use as a filter.
    GroupSearchFilter -> Text
value :: Prelude.Text
  }
  deriving (GroupSearchFilter -> GroupSearchFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupSearchFilter -> GroupSearchFilter -> Bool
$c/= :: GroupSearchFilter -> GroupSearchFilter -> Bool
== :: GroupSearchFilter -> GroupSearchFilter -> Bool
$c== :: GroupSearchFilter -> GroupSearchFilter -> Bool
Prelude.Eq, ReadPrec [GroupSearchFilter]
ReadPrec GroupSearchFilter
Int -> ReadS GroupSearchFilter
ReadS [GroupSearchFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupSearchFilter]
$creadListPrec :: ReadPrec [GroupSearchFilter]
readPrec :: ReadPrec GroupSearchFilter
$creadPrec :: ReadPrec GroupSearchFilter
readList :: ReadS [GroupSearchFilter]
$creadList :: ReadS [GroupSearchFilter]
readsPrec :: Int -> ReadS GroupSearchFilter
$creadsPrec :: Int -> ReadS GroupSearchFilter
Prelude.Read, Int -> GroupSearchFilter -> ShowS
[GroupSearchFilter] -> ShowS
GroupSearchFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupSearchFilter] -> ShowS
$cshowList :: [GroupSearchFilter] -> ShowS
show :: GroupSearchFilter -> String
$cshow :: GroupSearchFilter -> String
showsPrec :: Int -> GroupSearchFilter -> ShowS
$cshowsPrec :: Int -> GroupSearchFilter -> ShowS
Prelude.Show, forall x. Rep GroupSearchFilter x -> GroupSearchFilter
forall x. GroupSearchFilter -> Rep GroupSearchFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GroupSearchFilter x -> GroupSearchFilter
$cfrom :: forall x. GroupSearchFilter -> Rep GroupSearchFilter x
Prelude.Generic)

-- |
-- Create a value of 'GroupSearchFilter' 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:
--
-- 'operator', 'groupSearchFilter_operator' - The comparison operator that you want to use as a filter, for example
-- @\"Operator\": \"StartsWith\"@. Currently, the only supported operator
-- is @StartsWith@.
--
-- 'name', 'groupSearchFilter_name' - The name of the value that you want to use as a filter, for example
-- @\"Name\": \"GROUP_NAME\"@. Currently, the only supported name is
-- @GROUP_NAME@.
--
-- 'value', 'groupSearchFilter_value' - The value of the named item, in this case @GROUP_NAME@, that you want to
-- use as a filter.
newGroupSearchFilter ::
  -- | 'operator'
  GroupFilterOperator ->
  -- | 'name'
  GroupFilterAttribute ->
  -- | 'value'
  Prelude.Text ->
  GroupSearchFilter
newGroupSearchFilter :: GroupFilterOperator
-> GroupFilterAttribute -> Text -> GroupSearchFilter
newGroupSearchFilter GroupFilterOperator
pOperator_ GroupFilterAttribute
pName_ Text
pValue_ =
  GroupSearchFilter'
    { $sel:operator:GroupSearchFilter' :: GroupFilterOperator
operator = GroupFilterOperator
pOperator_,
      $sel:name:GroupSearchFilter' :: GroupFilterAttribute
name = GroupFilterAttribute
pName_,
      $sel:value:GroupSearchFilter' :: Text
value = Text
pValue_
    }

-- | The comparison operator that you want to use as a filter, for example
-- @\"Operator\": \"StartsWith\"@. Currently, the only supported operator
-- is @StartsWith@.
groupSearchFilter_operator :: Lens.Lens' GroupSearchFilter GroupFilterOperator
groupSearchFilter_operator :: Lens' GroupSearchFilter GroupFilterOperator
groupSearchFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupSearchFilter' {GroupFilterOperator
operator :: GroupFilterOperator
$sel:operator:GroupSearchFilter' :: GroupSearchFilter -> GroupFilterOperator
operator} -> GroupFilterOperator
operator) (\s :: GroupSearchFilter
s@GroupSearchFilter' {} GroupFilterOperator
a -> GroupSearchFilter
s {$sel:operator:GroupSearchFilter' :: GroupFilterOperator
operator = GroupFilterOperator
a} :: GroupSearchFilter)

-- | The name of the value that you want to use as a filter, for example
-- @\"Name\": \"GROUP_NAME\"@. Currently, the only supported name is
-- @GROUP_NAME@.
groupSearchFilter_name :: Lens.Lens' GroupSearchFilter GroupFilterAttribute
groupSearchFilter_name :: Lens' GroupSearchFilter GroupFilterAttribute
groupSearchFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupSearchFilter' {GroupFilterAttribute
name :: GroupFilterAttribute
$sel:name:GroupSearchFilter' :: GroupSearchFilter -> GroupFilterAttribute
name} -> GroupFilterAttribute
name) (\s :: GroupSearchFilter
s@GroupSearchFilter' {} GroupFilterAttribute
a -> GroupSearchFilter
s {$sel:name:GroupSearchFilter' :: GroupFilterAttribute
name = GroupFilterAttribute
a} :: GroupSearchFilter)

-- | The value of the named item, in this case @GROUP_NAME@, that you want to
-- use as a filter.
groupSearchFilter_value :: Lens.Lens' GroupSearchFilter Prelude.Text
groupSearchFilter_value :: Lens' GroupSearchFilter Text
groupSearchFilter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupSearchFilter' {Text
value :: Text
$sel:value:GroupSearchFilter' :: GroupSearchFilter -> Text
value} -> Text
value) (\s :: GroupSearchFilter
s@GroupSearchFilter' {} Text
a -> GroupSearchFilter
s {$sel:value:GroupSearchFilter' :: Text
value = Text
a} :: GroupSearchFilter)

instance Prelude.Hashable GroupSearchFilter where
  hashWithSalt :: Int -> GroupSearchFilter -> Int
hashWithSalt Int
_salt GroupSearchFilter' {Text
GroupFilterAttribute
GroupFilterOperator
value :: Text
name :: GroupFilterAttribute
operator :: GroupFilterOperator
$sel:value:GroupSearchFilter' :: GroupSearchFilter -> Text
$sel:name:GroupSearchFilter' :: GroupSearchFilter -> GroupFilterAttribute
$sel:operator:GroupSearchFilter' :: GroupSearchFilter -> GroupFilterOperator
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GroupFilterOperator
operator
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GroupFilterAttribute
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData GroupSearchFilter where
  rnf :: GroupSearchFilter -> ()
rnf GroupSearchFilter' {Text
GroupFilterAttribute
GroupFilterOperator
value :: Text
name :: GroupFilterAttribute
operator :: GroupFilterOperator
$sel:value:GroupSearchFilter' :: GroupSearchFilter -> Text
$sel:name:GroupSearchFilter' :: GroupSearchFilter -> GroupFilterAttribute
$sel:operator:GroupSearchFilter' :: GroupSearchFilter -> GroupFilterOperator
..} =
    forall a. NFData a => a -> ()
Prelude.rnf GroupFilterOperator
operator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf GroupFilterAttribute
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON GroupSearchFilter where
  toJSON :: GroupSearchFilter -> Value
toJSON GroupSearchFilter' {Text
GroupFilterAttribute
GroupFilterOperator
value :: Text
name :: GroupFilterAttribute
operator :: GroupFilterOperator
$sel:value:GroupSearchFilter' :: GroupSearchFilter -> Text
$sel:name:GroupSearchFilter' :: GroupSearchFilter -> GroupFilterAttribute
$sel:operator:GroupSearchFilter' :: GroupSearchFilter -> GroupFilterOperator
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Operator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= GroupFilterOperator
operator),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= GroupFilterAttribute
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )