{-# 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.CascadingControlSource
-- 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.CascadingControlSource 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.ColumnIdentifier

-- | The source controls that are used in a @CascadingControlConfiguration@.
--
-- /See:/ 'newCascadingControlSource' smart constructor.
data CascadingControlSource = CascadingControlSource'
  { -- | The column identifier that determines which column to look up for the
    -- source sheet control.
    CascadingControlSource -> Maybe ColumnIdentifier
columnToMatch :: Prelude.Maybe ColumnIdentifier,
    -- | The source sheet control ID of a @CascadingControlSource@.
    CascadingControlSource -> Maybe Text
sourceSheetControlId :: Prelude.Maybe Prelude.Text
  }
  deriving (CascadingControlSource -> CascadingControlSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CascadingControlSource -> CascadingControlSource -> Bool
$c/= :: CascadingControlSource -> CascadingControlSource -> Bool
== :: CascadingControlSource -> CascadingControlSource -> Bool
$c== :: CascadingControlSource -> CascadingControlSource -> Bool
Prelude.Eq, ReadPrec [CascadingControlSource]
ReadPrec CascadingControlSource
Int -> ReadS CascadingControlSource
ReadS [CascadingControlSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CascadingControlSource]
$creadListPrec :: ReadPrec [CascadingControlSource]
readPrec :: ReadPrec CascadingControlSource
$creadPrec :: ReadPrec CascadingControlSource
readList :: ReadS [CascadingControlSource]
$creadList :: ReadS [CascadingControlSource]
readsPrec :: Int -> ReadS CascadingControlSource
$creadsPrec :: Int -> ReadS CascadingControlSource
Prelude.Read, Int -> CascadingControlSource -> ShowS
[CascadingControlSource] -> ShowS
CascadingControlSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CascadingControlSource] -> ShowS
$cshowList :: [CascadingControlSource] -> ShowS
show :: CascadingControlSource -> String
$cshow :: CascadingControlSource -> String
showsPrec :: Int -> CascadingControlSource -> ShowS
$cshowsPrec :: Int -> CascadingControlSource -> ShowS
Prelude.Show, forall x. Rep CascadingControlSource x -> CascadingControlSource
forall x. CascadingControlSource -> Rep CascadingControlSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CascadingControlSource x -> CascadingControlSource
$cfrom :: forall x. CascadingControlSource -> Rep CascadingControlSource x
Prelude.Generic)

-- |
-- Create a value of 'CascadingControlSource' 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:
--
-- 'columnToMatch', 'cascadingControlSource_columnToMatch' - The column identifier that determines which column to look up for the
-- source sheet control.
--
-- 'sourceSheetControlId', 'cascadingControlSource_sourceSheetControlId' - The source sheet control ID of a @CascadingControlSource@.
newCascadingControlSource ::
  CascadingControlSource
newCascadingControlSource :: CascadingControlSource
newCascadingControlSource =
  CascadingControlSource'
    { $sel:columnToMatch:CascadingControlSource' :: Maybe ColumnIdentifier
columnToMatch =
        forall a. Maybe a
Prelude.Nothing,
      $sel:sourceSheetControlId:CascadingControlSource' :: Maybe Text
sourceSheetControlId = forall a. Maybe a
Prelude.Nothing
    }

-- | The column identifier that determines which column to look up for the
-- source sheet control.
cascadingControlSource_columnToMatch :: Lens.Lens' CascadingControlSource (Prelude.Maybe ColumnIdentifier)
cascadingControlSource_columnToMatch :: Lens' CascadingControlSource (Maybe ColumnIdentifier)
cascadingControlSource_columnToMatch = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CascadingControlSource' {Maybe ColumnIdentifier
columnToMatch :: Maybe ColumnIdentifier
$sel:columnToMatch:CascadingControlSource' :: CascadingControlSource -> Maybe ColumnIdentifier
columnToMatch} -> Maybe ColumnIdentifier
columnToMatch) (\s :: CascadingControlSource
s@CascadingControlSource' {} Maybe ColumnIdentifier
a -> CascadingControlSource
s {$sel:columnToMatch:CascadingControlSource' :: Maybe ColumnIdentifier
columnToMatch = Maybe ColumnIdentifier
a} :: CascadingControlSource)

-- | The source sheet control ID of a @CascadingControlSource@.
cascadingControlSource_sourceSheetControlId :: Lens.Lens' CascadingControlSource (Prelude.Maybe Prelude.Text)
cascadingControlSource_sourceSheetControlId :: Lens' CascadingControlSource (Maybe Text)
cascadingControlSource_sourceSheetControlId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CascadingControlSource' {Maybe Text
sourceSheetControlId :: Maybe Text
$sel:sourceSheetControlId:CascadingControlSource' :: CascadingControlSource -> Maybe Text
sourceSheetControlId} -> Maybe Text
sourceSheetControlId) (\s :: CascadingControlSource
s@CascadingControlSource' {} Maybe Text
a -> CascadingControlSource
s {$sel:sourceSheetControlId:CascadingControlSource' :: Maybe Text
sourceSheetControlId = Maybe Text
a} :: CascadingControlSource)

instance Data.FromJSON CascadingControlSource where
  parseJSON :: Value -> Parser CascadingControlSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CascadingControlSource"
      ( \Object
x ->
          Maybe ColumnIdentifier -> Maybe Text -> CascadingControlSource
CascadingControlSource'
            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
"ColumnToMatch")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SourceSheetControlId")
      )

instance Prelude.Hashable CascadingControlSource where
  hashWithSalt :: Int -> CascadingControlSource -> Int
hashWithSalt Int
_salt CascadingControlSource' {Maybe Text
Maybe ColumnIdentifier
sourceSheetControlId :: Maybe Text
columnToMatch :: Maybe ColumnIdentifier
$sel:sourceSheetControlId:CascadingControlSource' :: CascadingControlSource -> Maybe Text
$sel:columnToMatch:CascadingControlSource' :: CascadingControlSource -> Maybe ColumnIdentifier
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ColumnIdentifier
columnToMatch
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceSheetControlId

instance Prelude.NFData CascadingControlSource where
  rnf :: CascadingControlSource -> ()
rnf CascadingControlSource' {Maybe Text
Maybe ColumnIdentifier
sourceSheetControlId :: Maybe Text
columnToMatch :: Maybe ColumnIdentifier
$sel:sourceSheetControlId:CascadingControlSource' :: CascadingControlSource -> Maybe Text
$sel:columnToMatch:CascadingControlSource' :: CascadingControlSource -> Maybe ColumnIdentifier
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ColumnIdentifier
columnToMatch
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceSheetControlId

instance Data.ToJSON CascadingControlSource where
  toJSON :: CascadingControlSource -> Value
toJSON CascadingControlSource' {Maybe Text
Maybe ColumnIdentifier
sourceSheetControlId :: Maybe Text
columnToMatch :: Maybe ColumnIdentifier
$sel:sourceSheetControlId:CascadingControlSource' :: CascadingControlSource -> Maybe Text
$sel:columnToMatch:CascadingControlSource' :: CascadingControlSource -> Maybe ColumnIdentifier
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ColumnToMatch" 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 ColumnIdentifier
columnToMatch,
            (Key
"SourceSheetControlId" 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
sourceSheetControlId
          ]
      )