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

-- | The column schema.
--
-- /See:/ 'newColumnSchema' smart constructor.
data ColumnSchema = ColumnSchema'
  { -- | The data type of the column schema.
    ColumnSchema -> Maybe Text
dataType :: Prelude.Maybe Prelude.Text,
    -- | The geographic role of the column schema.
    ColumnSchema -> Maybe Text
geographicRole :: Prelude.Maybe Prelude.Text,
    -- | The name of the column schema.
    ColumnSchema -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ColumnSchema -> ColumnSchema -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnSchema -> ColumnSchema -> Bool
$c/= :: ColumnSchema -> ColumnSchema -> Bool
== :: ColumnSchema -> ColumnSchema -> Bool
$c== :: ColumnSchema -> ColumnSchema -> Bool
Prelude.Eq, ReadPrec [ColumnSchema]
ReadPrec ColumnSchema
Int -> ReadS ColumnSchema
ReadS [ColumnSchema]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnSchema]
$creadListPrec :: ReadPrec [ColumnSchema]
readPrec :: ReadPrec ColumnSchema
$creadPrec :: ReadPrec ColumnSchema
readList :: ReadS [ColumnSchema]
$creadList :: ReadS [ColumnSchema]
readsPrec :: Int -> ReadS ColumnSchema
$creadsPrec :: Int -> ReadS ColumnSchema
Prelude.Read, Int -> ColumnSchema -> ShowS
[ColumnSchema] -> ShowS
ColumnSchema -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnSchema] -> ShowS
$cshowList :: [ColumnSchema] -> ShowS
show :: ColumnSchema -> String
$cshow :: ColumnSchema -> String
showsPrec :: Int -> ColumnSchema -> ShowS
$cshowsPrec :: Int -> ColumnSchema -> ShowS
Prelude.Show, forall x. Rep ColumnSchema x -> ColumnSchema
forall x. ColumnSchema -> Rep ColumnSchema x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnSchema x -> ColumnSchema
$cfrom :: forall x. ColumnSchema -> Rep ColumnSchema x
Prelude.Generic)

-- |
-- Create a value of 'ColumnSchema' 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:
--
-- 'dataType', 'columnSchema_dataType' - The data type of the column schema.
--
-- 'geographicRole', 'columnSchema_geographicRole' - The geographic role of the column schema.
--
-- 'name', 'columnSchema_name' - The name of the column schema.
newColumnSchema ::
  ColumnSchema
newColumnSchema :: ColumnSchema
newColumnSchema =
  ColumnSchema'
    { $sel:dataType:ColumnSchema' :: Maybe Text
dataType = forall a. Maybe a
Prelude.Nothing,
      $sel:geographicRole:ColumnSchema' :: Maybe Text
geographicRole = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ColumnSchema' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | The data type of the column schema.
columnSchema_dataType :: Lens.Lens' ColumnSchema (Prelude.Maybe Prelude.Text)
columnSchema_dataType :: Lens' ColumnSchema (Maybe Text)
columnSchema_dataType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnSchema' {Maybe Text
dataType :: Maybe Text
$sel:dataType:ColumnSchema' :: ColumnSchema -> Maybe Text
dataType} -> Maybe Text
dataType) (\s :: ColumnSchema
s@ColumnSchema' {} Maybe Text
a -> ColumnSchema
s {$sel:dataType:ColumnSchema' :: Maybe Text
dataType = Maybe Text
a} :: ColumnSchema)

-- | The geographic role of the column schema.
columnSchema_geographicRole :: Lens.Lens' ColumnSchema (Prelude.Maybe Prelude.Text)
columnSchema_geographicRole :: Lens' ColumnSchema (Maybe Text)
columnSchema_geographicRole = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnSchema' {Maybe Text
geographicRole :: Maybe Text
$sel:geographicRole:ColumnSchema' :: ColumnSchema -> Maybe Text
geographicRole} -> Maybe Text
geographicRole) (\s :: ColumnSchema
s@ColumnSchema' {} Maybe Text
a -> ColumnSchema
s {$sel:geographicRole:ColumnSchema' :: Maybe Text
geographicRole = Maybe Text
a} :: ColumnSchema)

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

instance Data.FromJSON ColumnSchema where
  parseJSON :: Value -> Parser ColumnSchema
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnSchema"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> ColumnSchema
ColumnSchema'
            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
"DataType")
            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
"GeographicRole")
            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
"Name")
      )

instance Prelude.Hashable ColumnSchema where
  hashWithSalt :: Int -> ColumnSchema -> Int
hashWithSalt Int
_salt ColumnSchema' {Maybe Text
name :: Maybe Text
geographicRole :: Maybe Text
dataType :: Maybe Text
$sel:name:ColumnSchema' :: ColumnSchema -> Maybe Text
$sel:geographicRole:ColumnSchema' :: ColumnSchema -> Maybe Text
$sel:dataType:ColumnSchema' :: ColumnSchema -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dataType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
geographicRole
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData ColumnSchema where
  rnf :: ColumnSchema -> ()
rnf ColumnSchema' {Maybe Text
name :: Maybe Text
geographicRole :: Maybe Text
dataType :: Maybe Text
$sel:name:ColumnSchema' :: ColumnSchema -> Maybe Text
$sel:geographicRole:ColumnSchema' :: ColumnSchema -> Maybe Text
$sel:dataType:ColumnSchema' :: ColumnSchema -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dataType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
geographicRole
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name

instance Data.ToJSON ColumnSchema where
  toJSON :: ColumnSchema -> Value
toJSON ColumnSchema' {Maybe Text
name :: Maybe Text
geographicRole :: Maybe Text
dataType :: Maybe Text
$sel:name:ColumnSchema' :: ColumnSchema -> Maybe Text
$sel:geographicRole:ColumnSchema' :: ColumnSchema -> Maybe Text
$sel:dataType:ColumnSchema' :: ColumnSchema -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DataType" 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
dataType,
            (Key
"GeographicRole" 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
geographicRole,
            (Key
"Name" 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
name
          ]
      )