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

-- | A column of a data set.
--
-- /See:/ 'newColumnIdentifier' smart constructor.
data ColumnIdentifier = ColumnIdentifier'
  { -- | The data set that the column belongs to.
    ColumnIdentifier -> Text
dataSetIdentifier :: Prelude.Text,
    -- | The name of the column.
    ColumnIdentifier -> Text
columnName :: Prelude.Text
  }
  deriving (ColumnIdentifier -> ColumnIdentifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnIdentifier -> ColumnIdentifier -> Bool
$c/= :: ColumnIdentifier -> ColumnIdentifier -> Bool
== :: ColumnIdentifier -> ColumnIdentifier -> Bool
$c== :: ColumnIdentifier -> ColumnIdentifier -> Bool
Prelude.Eq, ReadPrec [ColumnIdentifier]
ReadPrec ColumnIdentifier
Int -> ReadS ColumnIdentifier
ReadS [ColumnIdentifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnIdentifier]
$creadListPrec :: ReadPrec [ColumnIdentifier]
readPrec :: ReadPrec ColumnIdentifier
$creadPrec :: ReadPrec ColumnIdentifier
readList :: ReadS [ColumnIdentifier]
$creadList :: ReadS [ColumnIdentifier]
readsPrec :: Int -> ReadS ColumnIdentifier
$creadsPrec :: Int -> ReadS ColumnIdentifier
Prelude.Read, Int -> ColumnIdentifier -> ShowS
[ColumnIdentifier] -> ShowS
ColumnIdentifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnIdentifier] -> ShowS
$cshowList :: [ColumnIdentifier] -> ShowS
show :: ColumnIdentifier -> String
$cshow :: ColumnIdentifier -> String
showsPrec :: Int -> ColumnIdentifier -> ShowS
$cshowsPrec :: Int -> ColumnIdentifier -> ShowS
Prelude.Show, forall x. Rep ColumnIdentifier x -> ColumnIdentifier
forall x. ColumnIdentifier -> Rep ColumnIdentifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnIdentifier x -> ColumnIdentifier
$cfrom :: forall x. ColumnIdentifier -> Rep ColumnIdentifier x
Prelude.Generic)

-- |
-- Create a value of 'ColumnIdentifier' 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:
--
-- 'dataSetIdentifier', 'columnIdentifier_dataSetIdentifier' - The data set that the column belongs to.
--
-- 'columnName', 'columnIdentifier_columnName' - The name of the column.
newColumnIdentifier ::
  -- | 'dataSetIdentifier'
  Prelude.Text ->
  -- | 'columnName'
  Prelude.Text ->
  ColumnIdentifier
newColumnIdentifier :: Text -> Text -> ColumnIdentifier
newColumnIdentifier Text
pDataSetIdentifier_ Text
pColumnName_ =
  ColumnIdentifier'
    { $sel:dataSetIdentifier:ColumnIdentifier' :: Text
dataSetIdentifier =
        Text
pDataSetIdentifier_,
      $sel:columnName:ColumnIdentifier' :: Text
columnName = Text
pColumnName_
    }

-- | The data set that the column belongs to.
columnIdentifier_dataSetIdentifier :: Lens.Lens' ColumnIdentifier Prelude.Text
columnIdentifier_dataSetIdentifier :: Lens' ColumnIdentifier Text
columnIdentifier_dataSetIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnIdentifier' {Text
dataSetIdentifier :: Text
$sel:dataSetIdentifier:ColumnIdentifier' :: ColumnIdentifier -> Text
dataSetIdentifier} -> Text
dataSetIdentifier) (\s :: ColumnIdentifier
s@ColumnIdentifier' {} Text
a -> ColumnIdentifier
s {$sel:dataSetIdentifier:ColumnIdentifier' :: Text
dataSetIdentifier = Text
a} :: ColumnIdentifier)

-- | The name of the column.
columnIdentifier_columnName :: Lens.Lens' ColumnIdentifier Prelude.Text
columnIdentifier_columnName :: Lens' ColumnIdentifier Text
columnIdentifier_columnName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnIdentifier' {Text
columnName :: Text
$sel:columnName:ColumnIdentifier' :: ColumnIdentifier -> Text
columnName} -> Text
columnName) (\s :: ColumnIdentifier
s@ColumnIdentifier' {} Text
a -> ColumnIdentifier
s {$sel:columnName:ColumnIdentifier' :: Text
columnName = Text
a} :: ColumnIdentifier)

instance Data.FromJSON ColumnIdentifier where
  parseJSON :: Value -> Parser ColumnIdentifier
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnIdentifier"
      ( \Object
x ->
          Text -> Text -> ColumnIdentifier
ColumnIdentifier'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DataSetIdentifier")
            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
"ColumnName")
      )

instance Prelude.Hashable ColumnIdentifier where
  hashWithSalt :: Int -> ColumnIdentifier -> Int
hashWithSalt Int
_salt ColumnIdentifier' {Text
columnName :: Text
dataSetIdentifier :: Text
$sel:columnName:ColumnIdentifier' :: ColumnIdentifier -> Text
$sel:dataSetIdentifier:ColumnIdentifier' :: ColumnIdentifier -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dataSetIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
columnName

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

instance Data.ToJSON ColumnIdentifier where
  toJSON :: ColumnIdentifier -> Value
toJSON ColumnIdentifier' {Text
columnName :: Text
dataSetIdentifier :: Text
$sel:columnName:ColumnIdentifier' :: ColumnIdentifier -> Text
$sel:dataSetIdentifier:ColumnIdentifier' :: ColumnIdentifier -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"DataSetIdentifier" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
dataSetIdentifier),
            forall a. a -> Maybe a
Prelude.Just (Key
"ColumnName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
columnName)
          ]
      )