{-# 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.FilterOperation
-- 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.FilterOperation 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 transform operation that filters rows based on a condition.
--
-- /See:/ 'newFilterOperation' smart constructor.
data FilterOperation = FilterOperation'
  { -- | An expression that must evaluate to a Boolean value. Rows for which the
    -- expression evaluates to true are kept in the dataset.
    FilterOperation -> Sensitive Text
conditionExpression :: Data.Sensitive Prelude.Text
  }
  deriving (FilterOperation -> FilterOperation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FilterOperation -> FilterOperation -> Bool
$c/= :: FilterOperation -> FilterOperation -> Bool
== :: FilterOperation -> FilterOperation -> Bool
$c== :: FilterOperation -> FilterOperation -> Bool
Prelude.Eq, Int -> FilterOperation -> ShowS
[FilterOperation] -> ShowS
FilterOperation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FilterOperation] -> ShowS
$cshowList :: [FilterOperation] -> ShowS
show :: FilterOperation -> String
$cshow :: FilterOperation -> String
showsPrec :: Int -> FilterOperation -> ShowS
$cshowsPrec :: Int -> FilterOperation -> ShowS
Prelude.Show, forall x. Rep FilterOperation x -> FilterOperation
forall x. FilterOperation -> Rep FilterOperation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FilterOperation x -> FilterOperation
$cfrom :: forall x. FilterOperation -> Rep FilterOperation x
Prelude.Generic)

-- |
-- Create a value of 'FilterOperation' 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:
--
-- 'conditionExpression', 'filterOperation_conditionExpression' - An expression that must evaluate to a Boolean value. Rows for which the
-- expression evaluates to true are kept in the dataset.
newFilterOperation ::
  -- | 'conditionExpression'
  Prelude.Text ->
  FilterOperation
newFilterOperation :: Text -> FilterOperation
newFilterOperation Text
pConditionExpression_ =
  FilterOperation'
    { $sel:conditionExpression:FilterOperation' :: Sensitive Text
conditionExpression =
        forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pConditionExpression_
    }

-- | An expression that must evaluate to a Boolean value. Rows for which the
-- expression evaluates to true are kept in the dataset.
filterOperation_conditionExpression :: Lens.Lens' FilterOperation Prelude.Text
filterOperation_conditionExpression :: Lens' FilterOperation Text
filterOperation_conditionExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterOperation' {Sensitive Text
conditionExpression :: Sensitive Text
$sel:conditionExpression:FilterOperation' :: FilterOperation -> Sensitive Text
conditionExpression} -> Sensitive Text
conditionExpression) (\s :: FilterOperation
s@FilterOperation' {} Sensitive Text
a -> FilterOperation
s {$sel:conditionExpression:FilterOperation' :: Sensitive Text
conditionExpression = Sensitive Text
a} :: FilterOperation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Data.FromJSON FilterOperation where
  parseJSON :: Value -> Parser FilterOperation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FilterOperation"
      ( \Object
x ->
          Sensitive Text -> FilterOperation
FilterOperation'
            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
"ConditionExpression")
      )

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

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

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