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

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

-- |
-- Create a value of 'DataSourceSearchFilter' 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', 'dataSourceSearchFilter_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 data sources you want to search in the @\"Value\"@
-- field. For example,
-- @\"Name\":\"DIRECT_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 data sources you are searching for. For example,
-- @\"Name\":\"DATASOURCE_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
-- The @\"StringLike\"@ operator only supports the @NAME@ value
-- @DATASOURCE_NAME@.
--
-- 'name', 'dataSourceSearchFilter_name' - The name of the value that you want to use as a filter, for example,
-- @\"Name\": \"DIRECT_QUICKSIGHT_OWNER\"@.
--
-- Valid values are defined as follows:
--
-- -   @DIRECT_QUICKSIGHT_VIEWER_OR_OWNER@: Provide an ARN of a user or
--     group, and any data sources with that ARN listed as one of the
--     owners or viewers of the data sources are returned. Implicit
--     permissions from folders or groups are not considered.
--
-- -   @DIRECT_QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and
--     any data sources with that ARN listed as one of the owners if the
--     data source are returned. Implicit permissions from folders or
--     groups are not considered.
--
-- -   @DIRECT_QUICKSIGHT_SOLE_OWNER@: Provide an ARN of a user or group,
--     and any data sources with that ARN listed as the only owner of the
--     data source are returned. Implicit permissions from folders or
--     groups are not considered.
--
-- -   @DATASOURCE_NAME@: Any data sources whose names have a substring
--     match to the provided value are returned.
--
-- 'value', 'dataSourceSearchFilter_value' - The value of the named item, for example @DIRECT_QUICKSIGHT_OWNER@, that
-- you want to use as a filter, for example,
-- @\"Value\": \"arn:aws:quicksight:us-east-1:1:user\/default\/UserName1\"@.
newDataSourceSearchFilter ::
  -- | 'operator'
  FilterOperator ->
  -- | 'name'
  DataSourceFilterAttribute ->
  -- | 'value'
  Prelude.Text ->
  DataSourceSearchFilter
newDataSourceSearchFilter :: FilterOperator
-> DataSourceFilterAttribute -> Text -> DataSourceSearchFilter
newDataSourceSearchFilter FilterOperator
pOperator_ DataSourceFilterAttribute
pName_ Text
pValue_ =
  DataSourceSearchFilter'
    { $sel:operator:DataSourceSearchFilter' :: FilterOperator
operator = FilterOperator
pOperator_,
      $sel:name:DataSourceSearchFilter' :: DataSourceFilterAttribute
name = DataSourceFilterAttribute
pName_,
      $sel:value:DataSourceSearchFilter' :: 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 data sources you want to search in the @\"Value\"@
-- field. For example,
-- @\"Name\":\"DIRECT_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 data sources you are searching for. For example,
-- @\"Name\":\"DATASOURCE_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
-- The @\"StringLike\"@ operator only supports the @NAME@ value
-- @DATASOURCE_NAME@.
dataSourceSearchFilter_operator :: Lens.Lens' DataSourceSearchFilter FilterOperator
dataSourceSearchFilter_operator :: Lens' DataSourceSearchFilter FilterOperator
dataSourceSearchFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceSearchFilter' {FilterOperator
operator :: FilterOperator
$sel:operator:DataSourceSearchFilter' :: DataSourceSearchFilter -> FilterOperator
operator} -> FilterOperator
operator) (\s :: DataSourceSearchFilter
s@DataSourceSearchFilter' {} FilterOperator
a -> DataSourceSearchFilter
s {$sel:operator:DataSourceSearchFilter' :: FilterOperator
operator = FilterOperator
a} :: DataSourceSearchFilter)

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

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

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

instance Prelude.NFData DataSourceSearchFilter where
  rnf :: DataSourceSearchFilter -> ()
rnf DataSourceSearchFilter' {Text
DataSourceFilterAttribute
FilterOperator
value :: Text
name :: DataSourceFilterAttribute
operator :: FilterOperator
$sel:value:DataSourceSearchFilter' :: DataSourceSearchFilter -> Text
$sel:name:DataSourceSearchFilter' :: DataSourceSearchFilter -> DataSourceFilterAttribute
$sel:operator:DataSourceSearchFilter' :: DataSourceSearchFilter -> 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 DataSourceFilterAttribute
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

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