{-# 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.ColumnDescription
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.ColumnDescription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Metadata that contains a description for a column.
--
-- /See:/ 'newColumnDescription' smart constructor.
data ColumnDescription = ColumnDescription'
  { -- | The text of a description for a column.
    ColumnDescription -> Maybe Text
text :: Prelude.Maybe Prelude.Text
  }
  deriving (ColumnDescription -> ColumnDescription -> Bool
(ColumnDescription -> ColumnDescription -> Bool)
-> (ColumnDescription -> ColumnDescription -> Bool)
-> Eq ColumnDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnDescription -> ColumnDescription -> Bool
$c/= :: ColumnDescription -> ColumnDescription -> Bool
== :: ColumnDescription -> ColumnDescription -> Bool
$c== :: ColumnDescription -> ColumnDescription -> Bool
Prelude.Eq, ReadPrec [ColumnDescription]
ReadPrec ColumnDescription
Int -> ReadS ColumnDescription
ReadS [ColumnDescription]
(Int -> ReadS ColumnDescription)
-> ReadS [ColumnDescription]
-> ReadPrec ColumnDescription
-> ReadPrec [ColumnDescription]
-> Read ColumnDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnDescription]
$creadListPrec :: ReadPrec [ColumnDescription]
readPrec :: ReadPrec ColumnDescription
$creadPrec :: ReadPrec ColumnDescription
readList :: ReadS [ColumnDescription]
$creadList :: ReadS [ColumnDescription]
readsPrec :: Int -> ReadS ColumnDescription
$creadsPrec :: Int -> ReadS ColumnDescription
Prelude.Read, Int -> ColumnDescription -> ShowS
[ColumnDescription] -> ShowS
ColumnDescription -> String
(Int -> ColumnDescription -> ShowS)
-> (ColumnDescription -> String)
-> ([ColumnDescription] -> ShowS)
-> Show ColumnDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnDescription] -> ShowS
$cshowList :: [ColumnDescription] -> ShowS
show :: ColumnDescription -> String
$cshow :: ColumnDescription -> String
showsPrec :: Int -> ColumnDescription -> ShowS
$cshowsPrec :: Int -> ColumnDescription -> ShowS
Prelude.Show, (forall x. ColumnDescription -> Rep ColumnDescription x)
-> (forall x. Rep ColumnDescription x -> ColumnDescription)
-> Generic ColumnDescription
forall x. Rep ColumnDescription x -> ColumnDescription
forall x. ColumnDescription -> Rep ColumnDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnDescription x -> ColumnDescription
$cfrom :: forall x. ColumnDescription -> Rep ColumnDescription x
Prelude.Generic)

-- |
-- Create a value of 'ColumnDescription' 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:
--
-- 'text', 'columnDescription_text' - The text of a description for a column.
newColumnDescription ::
  ColumnDescription
newColumnDescription :: ColumnDescription
newColumnDescription =
  ColumnDescription' :: Maybe Text -> ColumnDescription
ColumnDescription' {$sel:text:ColumnDescription' :: Maybe Text
text = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The text of a description for a column.
columnDescription_text :: Lens.Lens' ColumnDescription (Prelude.Maybe Prelude.Text)
columnDescription_text :: (Maybe Text -> f (Maybe Text))
-> ColumnDescription -> f ColumnDescription
columnDescription_text = (ColumnDescription -> Maybe Text)
-> (ColumnDescription -> Maybe Text -> ColumnDescription)
-> Lens
     ColumnDescription ColumnDescription (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnDescription' {Maybe Text
text :: Maybe Text
$sel:text:ColumnDescription' :: ColumnDescription -> Maybe Text
text} -> Maybe Text
text) (\s :: ColumnDescription
s@ColumnDescription' {} Maybe Text
a -> ColumnDescription
s {$sel:text:ColumnDescription' :: Maybe Text
text = Maybe Text
a} :: ColumnDescription)

instance Core.FromJSON ColumnDescription where
  parseJSON :: Value -> Parser ColumnDescription
parseJSON =
    String
-> (Object -> Parser ColumnDescription)
-> Value
-> Parser ColumnDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ColumnDescription"
      ( \Object
x ->
          Maybe Text -> ColumnDescription
ColumnDescription' (Maybe Text -> ColumnDescription)
-> Parser (Maybe Text) -> Parser ColumnDescription
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Text")
      )

instance Prelude.Hashable ColumnDescription

instance Prelude.NFData ColumnDescription

instance Core.ToJSON ColumnDescription where
  toJSON :: ColumnDescription -> Value
toJSON ColumnDescription' {Maybe Text
text :: Maybe Text
$sel:text:ColumnDescription' :: ColumnDescription -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Text" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
text]
      )