{-# 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.ColumnConfiguration
-- 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.ColumnConfiguration 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
import Amazonka.QuickSight.Types.ColumnRole
import Amazonka.QuickSight.Types.FormatConfiguration

-- | The general configuration of a column.
--
-- /See:/ 'newColumnConfiguration' smart constructor.
data ColumnConfiguration = ColumnConfiguration'
  { -- | The format configuration of a column.
    ColumnConfiguration -> Maybe FormatConfiguration
formatConfiguration :: Prelude.Maybe FormatConfiguration,
    -- | The role of the column.
    ColumnConfiguration -> Maybe ColumnRole
role' :: Prelude.Maybe ColumnRole,
    -- | The column.
    ColumnConfiguration -> ColumnIdentifier
column :: ColumnIdentifier
  }
  deriving (ColumnConfiguration -> ColumnConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnConfiguration -> ColumnConfiguration -> Bool
$c/= :: ColumnConfiguration -> ColumnConfiguration -> Bool
== :: ColumnConfiguration -> ColumnConfiguration -> Bool
$c== :: ColumnConfiguration -> ColumnConfiguration -> Bool
Prelude.Eq, Int -> ColumnConfiguration -> ShowS
[ColumnConfiguration] -> ShowS
ColumnConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnConfiguration] -> ShowS
$cshowList :: [ColumnConfiguration] -> ShowS
show :: ColumnConfiguration -> String
$cshow :: ColumnConfiguration -> String
showsPrec :: Int -> ColumnConfiguration -> ShowS
$cshowsPrec :: Int -> ColumnConfiguration -> ShowS
Prelude.Show, forall x. Rep ColumnConfiguration x -> ColumnConfiguration
forall x. ColumnConfiguration -> Rep ColumnConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnConfiguration x -> ColumnConfiguration
$cfrom :: forall x. ColumnConfiguration -> Rep ColumnConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ColumnConfiguration' 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:
--
-- 'formatConfiguration', 'columnConfiguration_formatConfiguration' - The format configuration of a column.
--
-- 'role'', 'columnConfiguration_role' - The role of the column.
--
-- 'column', 'columnConfiguration_column' - The column.
newColumnConfiguration ::
  -- | 'column'
  ColumnIdentifier ->
  ColumnConfiguration
newColumnConfiguration :: ColumnIdentifier -> ColumnConfiguration
newColumnConfiguration ColumnIdentifier
pColumn_ =
  ColumnConfiguration'
    { $sel:formatConfiguration:ColumnConfiguration' :: Maybe FormatConfiguration
formatConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:role':ColumnConfiguration' :: Maybe ColumnRole
role' = forall a. Maybe a
Prelude.Nothing,
      $sel:column:ColumnConfiguration' :: ColumnIdentifier
column = ColumnIdentifier
pColumn_
    }

-- | The format configuration of a column.
columnConfiguration_formatConfiguration :: Lens.Lens' ColumnConfiguration (Prelude.Maybe FormatConfiguration)
columnConfiguration_formatConfiguration :: Lens' ColumnConfiguration (Maybe FormatConfiguration)
columnConfiguration_formatConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnConfiguration' {Maybe FormatConfiguration
formatConfiguration :: Maybe FormatConfiguration
$sel:formatConfiguration:ColumnConfiguration' :: ColumnConfiguration -> Maybe FormatConfiguration
formatConfiguration} -> Maybe FormatConfiguration
formatConfiguration) (\s :: ColumnConfiguration
s@ColumnConfiguration' {} Maybe FormatConfiguration
a -> ColumnConfiguration
s {$sel:formatConfiguration:ColumnConfiguration' :: Maybe FormatConfiguration
formatConfiguration = Maybe FormatConfiguration
a} :: ColumnConfiguration)

-- | The role of the column.
columnConfiguration_role :: Lens.Lens' ColumnConfiguration (Prelude.Maybe ColumnRole)
columnConfiguration_role :: Lens' ColumnConfiguration (Maybe ColumnRole)
columnConfiguration_role = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnConfiguration' {Maybe ColumnRole
role' :: Maybe ColumnRole
$sel:role':ColumnConfiguration' :: ColumnConfiguration -> Maybe ColumnRole
role'} -> Maybe ColumnRole
role') (\s :: ColumnConfiguration
s@ColumnConfiguration' {} Maybe ColumnRole
a -> ColumnConfiguration
s {$sel:role':ColumnConfiguration' :: Maybe ColumnRole
role' = Maybe ColumnRole
a} :: ColumnConfiguration)

-- | The column.
columnConfiguration_column :: Lens.Lens' ColumnConfiguration ColumnIdentifier
columnConfiguration_column :: Lens' ColumnConfiguration ColumnIdentifier
columnConfiguration_column = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnConfiguration' {ColumnIdentifier
column :: ColumnIdentifier
$sel:column:ColumnConfiguration' :: ColumnConfiguration -> ColumnIdentifier
column} -> ColumnIdentifier
column) (\s :: ColumnConfiguration
s@ColumnConfiguration' {} ColumnIdentifier
a -> ColumnConfiguration
s {$sel:column:ColumnConfiguration' :: ColumnIdentifier
column = ColumnIdentifier
a} :: ColumnConfiguration)

instance Data.FromJSON ColumnConfiguration where
  parseJSON :: Value -> Parser ColumnConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnConfiguration"
      ( \Object
x ->
          Maybe FormatConfiguration
-> Maybe ColumnRole -> ColumnIdentifier -> ColumnConfiguration
ColumnConfiguration'
            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
"FormatConfiguration")
            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
"Role")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Column")
      )

instance Prelude.Hashable ColumnConfiguration where
  hashWithSalt :: Int -> ColumnConfiguration -> Int
hashWithSalt Int
_salt ColumnConfiguration' {Maybe ColumnRole
Maybe FormatConfiguration
ColumnIdentifier
column :: ColumnIdentifier
role' :: Maybe ColumnRole
formatConfiguration :: Maybe FormatConfiguration
$sel:column:ColumnConfiguration' :: ColumnConfiguration -> ColumnIdentifier
$sel:role':ColumnConfiguration' :: ColumnConfiguration -> Maybe ColumnRole
$sel:formatConfiguration:ColumnConfiguration' :: ColumnConfiguration -> Maybe FormatConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FormatConfiguration
formatConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ColumnRole
role'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ColumnIdentifier
column

instance Prelude.NFData ColumnConfiguration where
  rnf :: ColumnConfiguration -> ()
rnf ColumnConfiguration' {Maybe ColumnRole
Maybe FormatConfiguration
ColumnIdentifier
column :: ColumnIdentifier
role' :: Maybe ColumnRole
formatConfiguration :: Maybe FormatConfiguration
$sel:column:ColumnConfiguration' :: ColumnConfiguration -> ColumnIdentifier
$sel:role':ColumnConfiguration' :: ColumnConfiguration -> Maybe ColumnRole
$sel:formatConfiguration:ColumnConfiguration' :: ColumnConfiguration -> Maybe FormatConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FormatConfiguration
formatConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ColumnRole
role'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ColumnIdentifier
column

instance Data.ToJSON ColumnConfiguration where
  toJSON :: ColumnConfiguration -> Value
toJSON ColumnConfiguration' {Maybe ColumnRole
Maybe FormatConfiguration
ColumnIdentifier
column :: ColumnIdentifier
role' :: Maybe ColumnRole
formatConfiguration :: Maybe FormatConfiguration
$sel:column:ColumnConfiguration' :: ColumnConfiguration -> ColumnIdentifier
$sel:role':ColumnConfiguration' :: ColumnConfiguration -> Maybe ColumnRole
$sel:formatConfiguration:ColumnConfiguration' :: ColumnConfiguration -> Maybe FormatConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FormatConfiguration" 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 FormatConfiguration
formatConfiguration,
            (Key
"Role" 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 ColumnRole
role',
            forall a. a -> Maybe a
Prelude.Just (Key
"Column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ColumnIdentifier
column)
          ]
      )