{-# 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.SelectedSheetsFilterScopeConfiguration
-- 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.SelectedSheetsFilterScopeConfiguration 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.SheetVisualScopingConfiguration

-- | The configuration for applying a filter to specific sheets or visuals.
-- You can apply this filter to multiple visuals that are on one sheet or
-- to all visuals on a sheet.
--
-- This is a union type structure. For this structure to be valid, only one
-- of the attributes can be defined.
--
-- /See:/ 'newSelectedSheetsFilterScopeConfiguration' smart constructor.
data SelectedSheetsFilterScopeConfiguration = SelectedSheetsFilterScopeConfiguration'
  { -- | The sheet ID and visual IDs of the sheet and visuals that the filter is
    -- applied to.
    SelectedSheetsFilterScopeConfiguration
-> Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations :: Prelude.Maybe (Prelude.NonEmpty SheetVisualScopingConfiguration)
  }
  deriving (SelectedSheetsFilterScopeConfiguration
-> SelectedSheetsFilterScopeConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SelectedSheetsFilterScopeConfiguration
-> SelectedSheetsFilterScopeConfiguration -> Bool
$c/= :: SelectedSheetsFilterScopeConfiguration
-> SelectedSheetsFilterScopeConfiguration -> Bool
== :: SelectedSheetsFilterScopeConfiguration
-> SelectedSheetsFilterScopeConfiguration -> Bool
$c== :: SelectedSheetsFilterScopeConfiguration
-> SelectedSheetsFilterScopeConfiguration -> Bool
Prelude.Eq, ReadPrec [SelectedSheetsFilterScopeConfiguration]
ReadPrec SelectedSheetsFilterScopeConfiguration
Int -> ReadS SelectedSheetsFilterScopeConfiguration
ReadS [SelectedSheetsFilterScopeConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SelectedSheetsFilterScopeConfiguration]
$creadListPrec :: ReadPrec [SelectedSheetsFilterScopeConfiguration]
readPrec :: ReadPrec SelectedSheetsFilterScopeConfiguration
$creadPrec :: ReadPrec SelectedSheetsFilterScopeConfiguration
readList :: ReadS [SelectedSheetsFilterScopeConfiguration]
$creadList :: ReadS [SelectedSheetsFilterScopeConfiguration]
readsPrec :: Int -> ReadS SelectedSheetsFilterScopeConfiguration
$creadsPrec :: Int -> ReadS SelectedSheetsFilterScopeConfiguration
Prelude.Read, Int -> SelectedSheetsFilterScopeConfiguration -> ShowS
[SelectedSheetsFilterScopeConfiguration] -> ShowS
SelectedSheetsFilterScopeConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SelectedSheetsFilterScopeConfiguration] -> ShowS
$cshowList :: [SelectedSheetsFilterScopeConfiguration] -> ShowS
show :: SelectedSheetsFilterScopeConfiguration -> String
$cshow :: SelectedSheetsFilterScopeConfiguration -> String
showsPrec :: Int -> SelectedSheetsFilterScopeConfiguration -> ShowS
$cshowsPrec :: Int -> SelectedSheetsFilterScopeConfiguration -> ShowS
Prelude.Show, forall x.
Rep SelectedSheetsFilterScopeConfiguration x
-> SelectedSheetsFilterScopeConfiguration
forall x.
SelectedSheetsFilterScopeConfiguration
-> Rep SelectedSheetsFilterScopeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SelectedSheetsFilterScopeConfiguration x
-> SelectedSheetsFilterScopeConfiguration
$cfrom :: forall x.
SelectedSheetsFilterScopeConfiguration
-> Rep SelectedSheetsFilterScopeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SelectedSheetsFilterScopeConfiguration' 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:
--
-- 'sheetVisualScopingConfigurations', 'selectedSheetsFilterScopeConfiguration_sheetVisualScopingConfigurations' - The sheet ID and visual IDs of the sheet and visuals that the filter is
-- applied to.
newSelectedSheetsFilterScopeConfiguration ::
  SelectedSheetsFilterScopeConfiguration
newSelectedSheetsFilterScopeConfiguration :: SelectedSheetsFilterScopeConfiguration
newSelectedSheetsFilterScopeConfiguration =
  SelectedSheetsFilterScopeConfiguration'
    { $sel:sheetVisualScopingConfigurations:SelectedSheetsFilterScopeConfiguration' :: Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The sheet ID and visual IDs of the sheet and visuals that the filter is
-- applied to.
selectedSheetsFilterScopeConfiguration_sheetVisualScopingConfigurations :: Lens.Lens' SelectedSheetsFilterScopeConfiguration (Prelude.Maybe (Prelude.NonEmpty SheetVisualScopingConfiguration))
selectedSheetsFilterScopeConfiguration_sheetVisualScopingConfigurations :: Lens'
  SelectedSheetsFilterScopeConfiguration
  (Maybe (NonEmpty SheetVisualScopingConfiguration))
selectedSheetsFilterScopeConfiguration_sheetVisualScopingConfigurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectedSheetsFilterScopeConfiguration' {Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations :: Maybe (NonEmpty SheetVisualScopingConfiguration)
$sel:sheetVisualScopingConfigurations:SelectedSheetsFilterScopeConfiguration' :: SelectedSheetsFilterScopeConfiguration
-> Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations} -> Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations) (\s :: SelectedSheetsFilterScopeConfiguration
s@SelectedSheetsFilterScopeConfiguration' {} Maybe (NonEmpty SheetVisualScopingConfiguration)
a -> SelectedSheetsFilterScopeConfiguration
s {$sel:sheetVisualScopingConfigurations:SelectedSheetsFilterScopeConfiguration' :: Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations = Maybe (NonEmpty SheetVisualScopingConfiguration)
a} :: SelectedSheetsFilterScopeConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Data.FromJSON
    SelectedSheetsFilterScopeConfiguration
  where
  parseJSON :: Value -> Parser SelectedSheetsFilterScopeConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SelectedSheetsFilterScopeConfiguration"
      ( \Object
x ->
          Maybe (NonEmpty SheetVisualScopingConfiguration)
-> SelectedSheetsFilterScopeConfiguration
SelectedSheetsFilterScopeConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SheetVisualScopingConfigurations")
      )

instance
  Prelude.Hashable
    SelectedSheetsFilterScopeConfiguration
  where
  hashWithSalt :: Int -> SelectedSheetsFilterScopeConfiguration -> Int
hashWithSalt
    Int
_salt
    SelectedSheetsFilterScopeConfiguration' {Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations :: Maybe (NonEmpty SheetVisualScopingConfiguration)
$sel:sheetVisualScopingConfigurations:SelectedSheetsFilterScopeConfiguration' :: SelectedSheetsFilterScopeConfiguration
-> Maybe (NonEmpty SheetVisualScopingConfiguration)
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations

instance
  Prelude.NFData
    SelectedSheetsFilterScopeConfiguration
  where
  rnf :: SelectedSheetsFilterScopeConfiguration -> ()
rnf SelectedSheetsFilterScopeConfiguration' {Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations :: Maybe (NonEmpty SheetVisualScopingConfiguration)
$sel:sheetVisualScopingConfigurations:SelectedSheetsFilterScopeConfiguration' :: SelectedSheetsFilterScopeConfiguration
-> Maybe (NonEmpty SheetVisualScopingConfiguration)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations

instance
  Data.ToJSON
    SelectedSheetsFilterScopeConfiguration
  where
  toJSON :: SelectedSheetsFilterScopeConfiguration -> Value
toJSON SelectedSheetsFilterScopeConfiguration' {Maybe (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations :: Maybe (NonEmpty SheetVisualScopingConfiguration)
$sel:sheetVisualScopingConfigurations:SelectedSheetsFilterScopeConfiguration' :: SelectedSheetsFilterScopeConfiguration
-> Maybe (NonEmpty SheetVisualScopingConfiguration)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SheetVisualScopingConfigurations" 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 (NonEmpty SheetVisualScopingConfiguration)
sheetVisualScopingConfigurations
          ]
      )