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

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

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

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

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

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

instance Prelude.Hashable AnalysisSearchFilter where
  hashWithSalt :: Int -> AnalysisSearchFilter -> Int
hashWithSalt Int
_salt AnalysisSearchFilter' {Maybe Text
Maybe AnalysisFilterAttribute
Maybe FilterOperator
value :: Maybe Text
operator :: Maybe FilterOperator
name :: Maybe AnalysisFilterAttribute
$sel:value:AnalysisSearchFilter' :: AnalysisSearchFilter -> Maybe Text
$sel:operator:AnalysisSearchFilter' :: AnalysisSearchFilter -> Maybe FilterOperator
$sel:name:AnalysisSearchFilter' :: AnalysisSearchFilter -> Maybe AnalysisFilterAttribute
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AnalysisFilterAttribute
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 AnalysisSearchFilter where
  rnf :: AnalysisSearchFilter -> ()
rnf AnalysisSearchFilter' {Maybe Text
Maybe AnalysisFilterAttribute
Maybe FilterOperator
value :: Maybe Text
operator :: Maybe FilterOperator
name :: Maybe AnalysisFilterAttribute
$sel:value:AnalysisSearchFilter' :: AnalysisSearchFilter -> Maybe Text
$sel:operator:AnalysisSearchFilter' :: AnalysisSearchFilter -> Maybe FilterOperator
$sel:name:AnalysisSearchFilter' :: AnalysisSearchFilter -> Maybe AnalysisFilterAttribute
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AnalysisFilterAttribute
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 AnalysisSearchFilter where
  toJSON :: AnalysisSearchFilter -> Value
toJSON AnalysisSearchFilter' {Maybe Text
Maybe AnalysisFilterAttribute
Maybe FilterOperator
value :: Maybe Text
operator :: Maybe FilterOperator
name :: Maybe AnalysisFilterAttribute
$sel:value:AnalysisSearchFilter' :: AnalysisSearchFilter -> Maybe Text
$sel:operator:AnalysisSearchFilter' :: AnalysisSearchFilter -> Maybe FilterOperator
$sel:name:AnalysisSearchFilter' :: AnalysisSearchFilter -> Maybe AnalysisFilterAttribute
..} =
    [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 AnalysisFilterAttribute
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
          ]
      )