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

-- | A filter to use to search an Amazon QuickSight folder.
--
-- /See:/ 'newFolderSearchFilter' smart constructor.
data FolderSearchFilter = FolderSearchFilter'
  { -- | The name of a value that you want to use in the 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 folders with that ARN listed as one of the folder\'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
    --     folders with that ARN listed as one of the owners of the folders are
    --     returned. Implicit permissions from folders or groups are
    --     considered.
    --
    -- -   @DIRECT_QUICKSIGHT_SOLE_OWNER@: Provide an ARN of a user or group,
    --     and any folders with that ARN listed as the only owner of the folder
    --     are returned. Implicit permissions from folders or groups are not
    --     considered.
    --
    -- -   @DIRECT_QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and
    --     any folders with that ARN listed as one of the owners of the folders
    --     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 folders with that ARN listed as one of the owners or
    --     viewers of the folders are returned. Implicit permissions from
    --     folders or groups are not considered.
    --
    -- -   @FOLDER_NAME@: Any folders whose names have a substring match to
    --     this value will be returned.
    --
    -- -   @PARENT_FOLDER_ARN@: Provide an ARN of a folder, and any folders
    --     that are directly under that parent folder are returned. If you
    --     choose to use this option and leave the value blank, all root-level
    --     folders in the account are returned.
    FolderSearchFilter -> Maybe FolderFilterAttribute
name :: Prelude.Maybe FolderFilterAttribute,
    -- | 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\":\"FOLDER_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
    -- The @\"StringLike\"@ operator only supports the @NAME@ value
    -- @FOLDER_NAME@.
    FolderSearchFilter -> Maybe FilterOperator
operator :: Prelude.Maybe FilterOperator,
    -- | The value of the named item (in this example, @PARENT_FOLDER_ARN@), that
    -- you want to use as a filter. For example,
    -- @\"Value\": \"arn:aws:quicksight:us-east-1:1:folder\/folderId\"@.
    FolderSearchFilter -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (FolderSearchFilter -> FolderSearchFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FolderSearchFilter -> FolderSearchFilter -> Bool
$c/= :: FolderSearchFilter -> FolderSearchFilter -> Bool
== :: FolderSearchFilter -> FolderSearchFilter -> Bool
$c== :: FolderSearchFilter -> FolderSearchFilter -> Bool
Prelude.Eq, ReadPrec [FolderSearchFilter]
ReadPrec FolderSearchFilter
Int -> ReadS FolderSearchFilter
ReadS [FolderSearchFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FolderSearchFilter]
$creadListPrec :: ReadPrec [FolderSearchFilter]
readPrec :: ReadPrec FolderSearchFilter
$creadPrec :: ReadPrec FolderSearchFilter
readList :: ReadS [FolderSearchFilter]
$creadList :: ReadS [FolderSearchFilter]
readsPrec :: Int -> ReadS FolderSearchFilter
$creadsPrec :: Int -> ReadS FolderSearchFilter
Prelude.Read, Int -> FolderSearchFilter -> ShowS
[FolderSearchFilter] -> ShowS
FolderSearchFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FolderSearchFilter] -> ShowS
$cshowList :: [FolderSearchFilter] -> ShowS
show :: FolderSearchFilter -> String
$cshow :: FolderSearchFilter -> String
showsPrec :: Int -> FolderSearchFilter -> ShowS
$cshowsPrec :: Int -> FolderSearchFilter -> ShowS
Prelude.Show, forall x. Rep FolderSearchFilter x -> FolderSearchFilter
forall x. FolderSearchFilter -> Rep FolderSearchFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FolderSearchFilter x -> FolderSearchFilter
$cfrom :: forall x. FolderSearchFilter -> Rep FolderSearchFilter x
Prelude.Generic)

-- |
-- Create a value of 'FolderSearchFilter' 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', 'folderSearchFilter_name' - The name of a value that you want to use in the 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 folders with that ARN listed as one of the folder\'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
--     folders with that ARN listed as one of the owners of the folders are
--     returned. Implicit permissions from folders or groups are
--     considered.
--
-- -   @DIRECT_QUICKSIGHT_SOLE_OWNER@: Provide an ARN of a user or group,
--     and any folders with that ARN listed as the only owner of the folder
--     are returned. Implicit permissions from folders or groups are not
--     considered.
--
-- -   @DIRECT_QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and
--     any folders with that ARN listed as one of the owners of the folders
--     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 folders with that ARN listed as one of the owners or
--     viewers of the folders are returned. Implicit permissions from
--     folders or groups are not considered.
--
-- -   @FOLDER_NAME@: Any folders whose names have a substring match to
--     this value will be returned.
--
-- -   @PARENT_FOLDER_ARN@: Provide an ARN of a folder, and any folders
--     that are directly under that parent folder are returned. If you
--     choose to use this option and leave the value blank, all root-level
--     folders in the account are returned.
--
-- 'operator', 'folderSearchFilter_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\":\"FOLDER_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
-- The @\"StringLike\"@ operator only supports the @NAME@ value
-- @FOLDER_NAME@.
--
-- 'value', 'folderSearchFilter_value' - The value of the named item (in this example, @PARENT_FOLDER_ARN@), that
-- you want to use as a filter. For example,
-- @\"Value\": \"arn:aws:quicksight:us-east-1:1:folder\/folderId\"@.
newFolderSearchFilter ::
  FolderSearchFilter
newFolderSearchFilter :: FolderSearchFilter
newFolderSearchFilter =
  FolderSearchFilter'
    { $sel:name:FolderSearchFilter' :: Maybe FolderFilterAttribute
name = forall a. Maybe a
Prelude.Nothing,
      $sel:operator:FolderSearchFilter' :: Maybe FilterOperator
operator = forall a. Maybe a
Prelude.Nothing,
      $sel:value:FolderSearchFilter' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of a value that you want to use in the 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 folders with that ARN listed as one of the folder\'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
--     folders with that ARN listed as one of the owners of the folders are
--     returned. Implicit permissions from folders or groups are
--     considered.
--
-- -   @DIRECT_QUICKSIGHT_SOLE_OWNER@: Provide an ARN of a user or group,
--     and any folders with that ARN listed as the only owner of the folder
--     are returned. Implicit permissions from folders or groups are not
--     considered.
--
-- -   @DIRECT_QUICKSIGHT_OWNER@: Provide an ARN of a user or group, and
--     any folders with that ARN listed as one of the owners of the folders
--     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 folders with that ARN listed as one of the owners or
--     viewers of the folders are returned. Implicit permissions from
--     folders or groups are not considered.
--
-- -   @FOLDER_NAME@: Any folders whose names have a substring match to
--     this value will be returned.
--
-- -   @PARENT_FOLDER_ARN@: Provide an ARN of a folder, and any folders
--     that are directly under that parent folder are returned. If you
--     choose to use this option and leave the value blank, all root-level
--     folders in the account are returned.
folderSearchFilter_name :: Lens.Lens' FolderSearchFilter (Prelude.Maybe FolderFilterAttribute)
folderSearchFilter_name :: Lens' FolderSearchFilter (Maybe FolderFilterAttribute)
folderSearchFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FolderSearchFilter' {Maybe FolderFilterAttribute
name :: Maybe FolderFilterAttribute
$sel:name:FolderSearchFilter' :: FolderSearchFilter -> Maybe FolderFilterAttribute
name} -> Maybe FolderFilterAttribute
name) (\s :: FolderSearchFilter
s@FolderSearchFilter' {} Maybe FolderFilterAttribute
a -> FolderSearchFilter
s {$sel:name:FolderSearchFilter' :: Maybe FolderFilterAttribute
name = Maybe FolderFilterAttribute
a} :: FolderSearchFilter)

-- | 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\":\"FOLDER_NAME\", \"Operator\": \"StringLike\", \"Value\": \"Test\"@.
-- The @\"StringLike\"@ operator only supports the @NAME@ value
-- @FOLDER_NAME@.
folderSearchFilter_operator :: Lens.Lens' FolderSearchFilter (Prelude.Maybe FilterOperator)
folderSearchFilter_operator :: Lens' FolderSearchFilter (Maybe FilterOperator)
folderSearchFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FolderSearchFilter' {Maybe FilterOperator
operator :: Maybe FilterOperator
$sel:operator:FolderSearchFilter' :: FolderSearchFilter -> Maybe FilterOperator
operator} -> Maybe FilterOperator
operator) (\s :: FolderSearchFilter
s@FolderSearchFilter' {} Maybe FilterOperator
a -> FolderSearchFilter
s {$sel:operator:FolderSearchFilter' :: Maybe FilterOperator
operator = Maybe FilterOperator
a} :: FolderSearchFilter)

-- | The value of the named item (in this example, @PARENT_FOLDER_ARN@), that
-- you want to use as a filter. For example,
-- @\"Value\": \"arn:aws:quicksight:us-east-1:1:folder\/folderId\"@.
folderSearchFilter_value :: Lens.Lens' FolderSearchFilter (Prelude.Maybe Prelude.Text)
folderSearchFilter_value :: Lens' FolderSearchFilter (Maybe Text)
folderSearchFilter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FolderSearchFilter' {Maybe Text
value :: Maybe Text
$sel:value:FolderSearchFilter' :: FolderSearchFilter -> Maybe Text
value} -> Maybe Text
value) (\s :: FolderSearchFilter
s@FolderSearchFilter' {} Maybe Text
a -> FolderSearchFilter
s {$sel:value:FolderSearchFilter' :: Maybe Text
value = Maybe Text
a} :: FolderSearchFilter)

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

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

instance Data.ToJSON FolderSearchFilter where
  toJSON :: FolderSearchFilter -> Value
toJSON FolderSearchFilter' {Maybe Text
Maybe FilterOperator
Maybe FolderFilterAttribute
value :: Maybe Text
operator :: Maybe FilterOperator
name :: Maybe FolderFilterAttribute
$sel:value:FolderSearchFilter' :: FolderSearchFilter -> Maybe Text
$sel:operator:FolderSearchFilter' :: FolderSearchFilter -> Maybe FilterOperator
$sel:name:FolderSearchFilter' :: FolderSearchFilter -> Maybe FolderFilterAttribute
..} =
    [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 FolderFilterAttribute
name,
            (Key
"Operator" 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 FilterOperator
operator,
            (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
          ]
      )