{-# 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.DataSetSearchFilter
-- 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.DataSetSearchFilter 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.DataSetFilterAttribute
import Amazonka.QuickSight.Types.FilterOperator

-- | A filter that you apply when searching for datasets.
--
-- /See:/ 'newDataSetSearchFilter' smart constructor.
data DataSetSearchFilter = DataSetSearchFilter'
  { -- | The comparison operator that you want to use as a filter, for example
    -- @\"Operator\": \"StringEquals\"@. Valid values are @\"StringEquals\"@
    -- and @\"StringLike\"@.
    --
    -- If you set the operator value to @\"StringEquals\"@, you need to provide
    -- an ownership related filter in the @\"NAME\"@ field and the arn of the
    -- user or group whose datasets you want to search in the @\"Value\"@
    -- field. For example,
    -- @\"Name\":\"QUICKSIGHT_OWNER\", \"Operator\": \"StringEquals\", \"Value\": \"arn:aws:quicksight:us-east- 1:1:user\/default\/UserName1\"@.
    --
    -- If you set the value to @\"StringLike\"@, you need to provide the name
    -- of the datasets you are searching for. For example,
    -- @\"Name\":\"DATASET_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
    -- The @\"StringLike\"@ operator only supports the @NAME@ value
    -- @DATASET_NAME@.
    DataSetSearchFilter -> FilterOperator
operator :: FilterOperator,
    -- | The name of the value that you want to use as a filter, for example,
    -- @\"Name\": \"QUICKSIGHT_OWNER\"@.
    --
    -- Valid values are defined as follows:
    --
    -- -   @QUICKSIGHT_VIEWER_OR_OWNER@: Provide an ARN of a user or group, and
    --     any datasets with that ARN listed as one of the dataset owners or
    --     viewers are returned. Implicit permissions from folders or groups
    --     are considered.
    --
    -- -   @QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and any
    --     datasets with that ARN listed as one of the owners of the dataset
    --     are returned. Implicit permissions from folders or groups are
    --     considered.
    --
    -- -   @DIRECT_QUICKSIGHT_SOLE_OWNER@: Provide an ARN of a user or group,
    --     and any datasets with that ARN listed as the only owner of the
    --     dataset are returned. Implicit permissions from folders or groups
    --     are not considered.
    --
    -- -   @DIRECT_QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and
    --     any datasets with that ARN listed as one of the owners if the
    --     dataset are returned. Implicit permissions from folders or groups
    --     are not considered.
    --
    -- -   @DIRECT_QUICKSIGHT_VIEWER_OR_OWNER@: Provide an ARN of a user or
    --     group, and any datasets with that ARN listed as one of the owners or
    --     viewers of the dataset are returned. Implicit permissions from
    --     folders or groups are not considered.
    --
    -- -   @DATASET_NAME@: Any datasets whose names have a substring match to
    --     this value will be returned.
    DataSetSearchFilter -> DataSetFilterAttribute
name :: DataSetFilterAttribute,
    -- | The value of the named item, in this case @QUICKSIGHT_OWNER@, that you
    -- want to use as a filter, for example,
    -- @\"Value\": \"arn:aws:quicksight:us-east-1:1:user\/default\/UserName1\"@.
    DataSetSearchFilter -> Text
value :: Prelude.Text
  }
  deriving (DataSetSearchFilter -> DataSetSearchFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataSetSearchFilter -> DataSetSearchFilter -> Bool
$c/= :: DataSetSearchFilter -> DataSetSearchFilter -> Bool
== :: DataSetSearchFilter -> DataSetSearchFilter -> Bool
$c== :: DataSetSearchFilter -> DataSetSearchFilter -> Bool
Prelude.Eq, ReadPrec [DataSetSearchFilter]
ReadPrec DataSetSearchFilter
Int -> ReadS DataSetSearchFilter
ReadS [DataSetSearchFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataSetSearchFilter]
$creadListPrec :: ReadPrec [DataSetSearchFilter]
readPrec :: ReadPrec DataSetSearchFilter
$creadPrec :: ReadPrec DataSetSearchFilter
readList :: ReadS [DataSetSearchFilter]
$creadList :: ReadS [DataSetSearchFilter]
readsPrec :: Int -> ReadS DataSetSearchFilter
$creadsPrec :: Int -> ReadS DataSetSearchFilter
Prelude.Read, Int -> DataSetSearchFilter -> ShowS
[DataSetSearchFilter] -> ShowS
DataSetSearchFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataSetSearchFilter] -> ShowS
$cshowList :: [DataSetSearchFilter] -> ShowS
show :: DataSetSearchFilter -> String
$cshow :: DataSetSearchFilter -> String
showsPrec :: Int -> DataSetSearchFilter -> ShowS
$cshowsPrec :: Int -> DataSetSearchFilter -> ShowS
Prelude.Show, forall x. Rep DataSetSearchFilter x -> DataSetSearchFilter
forall x. DataSetSearchFilter -> Rep DataSetSearchFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataSetSearchFilter x -> DataSetSearchFilter
$cfrom :: forall x. DataSetSearchFilter -> Rep DataSetSearchFilter x
Prelude.Generic)

-- |
-- Create a value of 'DataSetSearchFilter' 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', 'dataSetSearchFilter_operator' - The comparison operator that you want to use as a filter, for example
-- @\"Operator\": \"StringEquals\"@. Valid values are @\"StringEquals\"@
-- and @\"StringLike\"@.
--
-- If you set the operator value to @\"StringEquals\"@, you need to provide
-- an ownership related filter in the @\"NAME\"@ field and the arn of the
-- user or group whose datasets you want to search in the @\"Value\"@
-- field. For example,
-- @\"Name\":\"QUICKSIGHT_OWNER\", \"Operator\": \"StringEquals\", \"Value\": \"arn:aws:quicksight:us-east- 1:1:user\/default\/UserName1\"@.
--
-- If you set the value to @\"StringLike\"@, you need to provide the name
-- of the datasets you are searching for. For example,
-- @\"Name\":\"DATASET_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
-- The @\"StringLike\"@ operator only supports the @NAME@ value
-- @DATASET_NAME@.
--
-- 'name', 'dataSetSearchFilter_name' - The name of the value that you want to use as a filter, for example,
-- @\"Name\": \"QUICKSIGHT_OWNER\"@.
--
-- Valid values are defined as follows:
--
-- -   @QUICKSIGHT_VIEWER_OR_OWNER@: Provide an ARN of a user or group, and
--     any datasets with that ARN listed as one of the dataset owners or
--     viewers are returned. Implicit permissions from folders or groups
--     are considered.
--
-- -   @QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and any
--     datasets with that ARN listed as one of the owners of the dataset
--     are returned. Implicit permissions from folders or groups are
--     considered.
--
-- -   @DIRECT_QUICKSIGHT_SOLE_OWNER@: Provide an ARN of a user or group,
--     and any datasets with that ARN listed as the only owner of the
--     dataset are returned. Implicit permissions from folders or groups
--     are not considered.
--
-- -   @DIRECT_QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and
--     any datasets with that ARN listed as one of the owners if the
--     dataset are returned. Implicit permissions from folders or groups
--     are not considered.
--
-- -   @DIRECT_QUICKSIGHT_VIEWER_OR_OWNER@: Provide an ARN of a user or
--     group, and any datasets with that ARN listed as one of the owners or
--     viewers of the dataset are returned. Implicit permissions from
--     folders or groups are not considered.
--
-- -   @DATASET_NAME@: Any datasets whose names have a substring match to
--     this value will be returned.
--
-- 'value', 'dataSetSearchFilter_value' - The value of the named item, in this case @QUICKSIGHT_OWNER@, that you
-- want to use as a filter, for example,
-- @\"Value\": \"arn:aws:quicksight:us-east-1:1:user\/default\/UserName1\"@.
newDataSetSearchFilter ::
  -- | 'operator'
  FilterOperator ->
  -- | 'name'
  DataSetFilterAttribute ->
  -- | 'value'
  Prelude.Text ->
  DataSetSearchFilter
newDataSetSearchFilter :: FilterOperator
-> DataSetFilterAttribute -> Text -> DataSetSearchFilter
newDataSetSearchFilter FilterOperator
pOperator_ DataSetFilterAttribute
pName_ Text
pValue_ =
  DataSetSearchFilter'
    { $sel:operator:DataSetSearchFilter' :: FilterOperator
operator = FilterOperator
pOperator_,
      $sel:name:DataSetSearchFilter' :: DataSetFilterAttribute
name = DataSetFilterAttribute
pName_,
      $sel:value:DataSetSearchFilter' :: Text
value = Text
pValue_
    }

-- | The comparison operator that you want to use as a filter, for example
-- @\"Operator\": \"StringEquals\"@. Valid values are @\"StringEquals\"@
-- and @\"StringLike\"@.
--
-- If you set the operator value to @\"StringEquals\"@, you need to provide
-- an ownership related filter in the @\"NAME\"@ field and the arn of the
-- user or group whose datasets you want to search in the @\"Value\"@
-- field. For example,
-- @\"Name\":\"QUICKSIGHT_OWNER\", \"Operator\": \"StringEquals\", \"Value\": \"arn:aws:quicksight:us-east- 1:1:user\/default\/UserName1\"@.
--
-- If you set the value to @\"StringLike\"@, you need to provide the name
-- of the datasets you are searching for. For example,
-- @\"Name\":\"DATASET_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
-- The @\"StringLike\"@ operator only supports the @NAME@ value
-- @DATASET_NAME@.
dataSetSearchFilter_operator :: Lens.Lens' DataSetSearchFilter FilterOperator
dataSetSearchFilter_operator :: Lens' DataSetSearchFilter FilterOperator
dataSetSearchFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSetSearchFilter' {FilterOperator
operator :: FilterOperator
$sel:operator:DataSetSearchFilter' :: DataSetSearchFilter -> FilterOperator
operator} -> FilterOperator
operator) (\s :: DataSetSearchFilter
s@DataSetSearchFilter' {} FilterOperator
a -> DataSetSearchFilter
s {$sel:operator:DataSetSearchFilter' :: FilterOperator
operator = FilterOperator
a} :: DataSetSearchFilter)

-- | The name of the value that you want to use as a filter, for example,
-- @\"Name\": \"QUICKSIGHT_OWNER\"@.
--
-- Valid values are defined as follows:
--
-- -   @QUICKSIGHT_VIEWER_OR_OWNER@: Provide an ARN of a user or group, and
--     any datasets with that ARN listed as one of the dataset owners or
--     viewers are returned. Implicit permissions from folders or groups
--     are considered.
--
-- -   @QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and any
--     datasets with that ARN listed as one of the owners of the dataset
--     are returned. Implicit permissions from folders or groups are
--     considered.
--
-- -   @DIRECT_QUICKSIGHT_SOLE_OWNER@: Provide an ARN of a user or group,
--     and any datasets with that ARN listed as the only owner of the
--     dataset are returned. Implicit permissions from folders or groups
--     are not considered.
--
-- -   @DIRECT_QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and
--     any datasets with that ARN listed as one of the owners if the
--     dataset are returned. Implicit permissions from folders or groups
--     are not considered.
--
-- -   @DIRECT_QUICKSIGHT_VIEWER_OR_OWNER@: Provide an ARN of a user or
--     group, and any datasets with that ARN listed as one of the owners or
--     viewers of the dataset are returned. Implicit permissions from
--     folders or groups are not considered.
--
-- -   @DATASET_NAME@: Any datasets whose names have a substring match to
--     this value will be returned.
dataSetSearchFilter_name :: Lens.Lens' DataSetSearchFilter DataSetFilterAttribute
dataSetSearchFilter_name :: Lens' DataSetSearchFilter DataSetFilterAttribute
dataSetSearchFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSetSearchFilter' {DataSetFilterAttribute
name :: DataSetFilterAttribute
$sel:name:DataSetSearchFilter' :: DataSetSearchFilter -> DataSetFilterAttribute
name} -> DataSetFilterAttribute
name) (\s :: DataSetSearchFilter
s@DataSetSearchFilter' {} DataSetFilterAttribute
a -> DataSetSearchFilter
s {$sel:name:DataSetSearchFilter' :: DataSetFilterAttribute
name = DataSetFilterAttribute
a} :: DataSetSearchFilter)

-- | The value of the named item, in this case @QUICKSIGHT_OWNER@, that you
-- want to use as a filter, for example,
-- @\"Value\": \"arn:aws:quicksight:us-east-1:1:user\/default\/UserName1\"@.
dataSetSearchFilter_value :: Lens.Lens' DataSetSearchFilter Prelude.Text
dataSetSearchFilter_value :: Lens' DataSetSearchFilter Text
dataSetSearchFilter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSetSearchFilter' {Text
value :: Text
$sel:value:DataSetSearchFilter' :: DataSetSearchFilter -> Text
value} -> Text
value) (\s :: DataSetSearchFilter
s@DataSetSearchFilter' {} Text
a -> DataSetSearchFilter
s {$sel:value:DataSetSearchFilter' :: Text
value = Text
a} :: DataSetSearchFilter)

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

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

instance Data.ToJSON DataSetSearchFilter where
  toJSON :: DataSetSearchFilter -> Value
toJSON DataSetSearchFilter' {Text
DataSetFilterAttribute
FilterOperator
value :: Text
name :: DataSetFilterAttribute
operator :: FilterOperator
$sel:value:DataSetSearchFilter' :: DataSetSearchFilter -> Text
$sel:name:DataSetSearchFilter' :: DataSetSearchFilter -> DataSetFilterAttribute
$sel:operator:DataSetSearchFilter' :: DataSetSearchFilter -> FilterOperator
..} =
    [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..= FilterOperator
operator),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DataSetFilterAttribute
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )