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

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

-- |
-- Create a value of 'DashboardSearchFilter' 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:
--
-- 'name', 'dashboardSearchFilter_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 dashboards with that ARN listed as one of the dashboards\'s
--     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
--     dashboards with that ARN listed as one of the owners of the
--     dashboards are returned. Implicit permissions from folders or groups
--     are considered.
--
-- -   @DIRECT_QUICKSIGHT_SOLE_OWNER@: Provide an ARN of a user or group,
--     and any dashboards with that ARN listed as the only owner of the
--     dashboard are returned. Implicit permissions from folders or groups
--     are not considered.
--
-- -   @DIRECT_QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and
--     any dashboards with that ARN listed as one of the owners of the
--     dashboards 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 dashboards with that ARN listed as one of the owners
--     or viewers of the dashboards are returned. Implicit permissions from
--     folders or groups are not considered.
--
-- -   @DASHBOARD_NAME@: Any dashboards whose names have a substring match
--     to this value will be returned.
--
-- 'value', 'dashboardSearchFilter_value' - The value of the named item, in this case @QUICKSIGHT_USER@, that you
-- want to use as a filter, for example,
-- @\"Value\": \"arn:aws:quicksight:us-east-1:1:user\/default\/UserName1\"@.
--
-- 'operator', 'dashboardSearchFilter_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 folders 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 folders you are searching for. For example,
-- @\"Name\":\"DASHBOARD_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
-- The @\"StringLike\"@ operator only supports the @NAME@ value
-- @DASHBOARD_NAME@.
newDashboardSearchFilter ::
  -- | 'operator'
  FilterOperator ->
  DashboardSearchFilter
newDashboardSearchFilter :: FilterOperator -> DashboardSearchFilter
newDashboardSearchFilter FilterOperator
pOperator_ =
  DashboardSearchFilter'
    { $sel:name:DashboardSearchFilter' :: Maybe DashboardFilterAttribute
name = forall a. Maybe a
Prelude.Nothing,
      $sel:value:DashboardSearchFilter' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing,
      $sel:operator:DashboardSearchFilter' :: FilterOperator
operator = FilterOperator
pOperator_
    }

-- | 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 dashboards with that ARN listed as one of the dashboards\'s
--     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
--     dashboards with that ARN listed as one of the owners of the
--     dashboards are returned. Implicit permissions from folders or groups
--     are considered.
--
-- -   @DIRECT_QUICKSIGHT_SOLE_OWNER@: Provide an ARN of a user or group,
--     and any dashboards with that ARN listed as the only owner of the
--     dashboard are returned. Implicit permissions from folders or groups
--     are not considered.
--
-- -   @DIRECT_QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and
--     any dashboards with that ARN listed as one of the owners of the
--     dashboards 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 dashboards with that ARN listed as one of the owners
--     or viewers of the dashboards are returned. Implicit permissions from
--     folders or groups are not considered.
--
-- -   @DASHBOARD_NAME@: Any dashboards whose names have a substring match
--     to this value will be returned.
dashboardSearchFilter_name :: Lens.Lens' DashboardSearchFilter (Prelude.Maybe DashboardFilterAttribute)
dashboardSearchFilter_name :: Lens' DashboardSearchFilter (Maybe DashboardFilterAttribute)
dashboardSearchFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DashboardSearchFilter' {Maybe DashboardFilterAttribute
name :: Maybe DashboardFilterAttribute
$sel:name:DashboardSearchFilter' :: DashboardSearchFilter -> Maybe DashboardFilterAttribute
name} -> Maybe DashboardFilterAttribute
name) (\s :: DashboardSearchFilter
s@DashboardSearchFilter' {} Maybe DashboardFilterAttribute
a -> DashboardSearchFilter
s {$sel:name:DashboardSearchFilter' :: Maybe DashboardFilterAttribute
name = Maybe DashboardFilterAttribute
a} :: DashboardSearchFilter)

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

-- | 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 folders 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 folders you are searching for. For example,
-- @\"Name\":\"DASHBOARD_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
-- The @\"StringLike\"@ operator only supports the @NAME@ value
-- @DASHBOARD_NAME@.
dashboardSearchFilter_operator :: Lens.Lens' DashboardSearchFilter FilterOperator
dashboardSearchFilter_operator :: Lens' DashboardSearchFilter FilterOperator
dashboardSearchFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DashboardSearchFilter' {FilterOperator
operator :: FilterOperator
$sel:operator:DashboardSearchFilter' :: DashboardSearchFilter -> FilterOperator
operator} -> FilterOperator
operator) (\s :: DashboardSearchFilter
s@DashboardSearchFilter' {} FilterOperator
a -> DashboardSearchFilter
s {$sel:operator:DashboardSearchFilter' :: FilterOperator
operator = FilterOperator
a} :: DashboardSearchFilter)

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

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

instance Data.ToJSON DashboardSearchFilter where
  toJSON :: DashboardSearchFilter -> Value
toJSON DashboardSearchFilter' {Maybe Text
Maybe DashboardFilterAttribute
FilterOperator
operator :: FilterOperator
value :: Maybe Text
name :: Maybe DashboardFilterAttribute
$sel:operator:DashboardSearchFilter' :: DashboardSearchFilter -> FilterOperator
$sel:value:DashboardSearchFilter' :: DashboardSearchFilter -> Maybe Text
$sel:name:DashboardSearchFilter' :: DashboardSearchFilter -> Maybe DashboardFilterAttribute
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DashboardFilterAttribute
name,
            (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
value,
            forall a. a -> Maybe a
Prelude.Just (Key
"Operator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= FilterOperator
operator)
          ]
      )