{-# 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.InputColumn
-- 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.InputColumn where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.InputColumnDataType

-- | Metadata for a column that is used as the input of a transform
-- operation.
--
-- /See:/ 'newInputColumn' smart constructor.
data InputColumn = InputColumn'
  { -- | The name of this column in the underlying data source.
    InputColumn -> Text
name :: Prelude.Text,
    -- | The data type of the column.
    InputColumn -> InputColumnDataType
type' :: InputColumnDataType
  }
  deriving (InputColumn -> InputColumn -> Bool
(InputColumn -> InputColumn -> Bool)
-> (InputColumn -> InputColumn -> Bool) -> Eq InputColumn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputColumn -> InputColumn -> Bool
$c/= :: InputColumn -> InputColumn -> Bool
== :: InputColumn -> InputColumn -> Bool
$c== :: InputColumn -> InputColumn -> Bool
Prelude.Eq, ReadPrec [InputColumn]
ReadPrec InputColumn
Int -> ReadS InputColumn
ReadS [InputColumn]
(Int -> ReadS InputColumn)
-> ReadS [InputColumn]
-> ReadPrec InputColumn
-> ReadPrec [InputColumn]
-> Read InputColumn
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputColumn]
$creadListPrec :: ReadPrec [InputColumn]
readPrec :: ReadPrec InputColumn
$creadPrec :: ReadPrec InputColumn
readList :: ReadS [InputColumn]
$creadList :: ReadS [InputColumn]
readsPrec :: Int -> ReadS InputColumn
$creadsPrec :: Int -> ReadS InputColumn
Prelude.Read, Int -> InputColumn -> ShowS
[InputColumn] -> ShowS
InputColumn -> String
(Int -> InputColumn -> ShowS)
-> (InputColumn -> String)
-> ([InputColumn] -> ShowS)
-> Show InputColumn
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputColumn] -> ShowS
$cshowList :: [InputColumn] -> ShowS
show :: InputColumn -> String
$cshow :: InputColumn -> String
showsPrec :: Int -> InputColumn -> ShowS
$cshowsPrec :: Int -> InputColumn -> ShowS
Prelude.Show, (forall x. InputColumn -> Rep InputColumn x)
-> (forall x. Rep InputColumn x -> InputColumn)
-> Generic InputColumn
forall x. Rep InputColumn x -> InputColumn
forall x. InputColumn -> Rep InputColumn x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputColumn x -> InputColumn
$cfrom :: forall x. InputColumn -> Rep InputColumn x
Prelude.Generic)

-- |
-- Create a value of 'InputColumn' 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:
--
-- 'name', 'inputColumn_name' - The name of this column in the underlying data source.
--
-- 'type'', 'inputColumn_type' - The data type of the column.
newInputColumn ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  InputColumnDataType ->
  InputColumn
newInputColumn :: Text -> InputColumnDataType -> InputColumn
newInputColumn Text
pName_ InputColumnDataType
pType_ =
  InputColumn' :: Text -> InputColumnDataType -> InputColumn
InputColumn' {$sel:name:InputColumn' :: Text
name = Text
pName_, $sel:type':InputColumn' :: InputColumnDataType
type' = InputColumnDataType
pType_}

-- | The name of this column in the underlying data source.
inputColumn_name :: Lens.Lens' InputColumn Prelude.Text
inputColumn_name :: (Text -> f Text) -> InputColumn -> f InputColumn
inputColumn_name = (InputColumn -> Text)
-> (InputColumn -> Text -> InputColumn)
-> Lens InputColumn InputColumn Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputColumn' {Text
name :: Text
$sel:name:InputColumn' :: InputColumn -> Text
name} -> Text
name) (\s :: InputColumn
s@InputColumn' {} Text
a -> InputColumn
s {$sel:name:InputColumn' :: Text
name = Text
a} :: InputColumn)

-- | The data type of the column.
inputColumn_type :: Lens.Lens' InputColumn InputColumnDataType
inputColumn_type :: (InputColumnDataType -> f InputColumnDataType)
-> InputColumn -> f InputColumn
inputColumn_type = (InputColumn -> InputColumnDataType)
-> (InputColumn -> InputColumnDataType -> InputColumn)
-> Lens
     InputColumn InputColumn InputColumnDataType InputColumnDataType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputColumn' {InputColumnDataType
type' :: InputColumnDataType
$sel:type':InputColumn' :: InputColumn -> InputColumnDataType
type'} -> InputColumnDataType
type') (\s :: InputColumn
s@InputColumn' {} InputColumnDataType
a -> InputColumn
s {$sel:type':InputColumn' :: InputColumnDataType
type' = InputColumnDataType
a} :: InputColumn)

instance Core.FromJSON InputColumn where
  parseJSON :: Value -> Parser InputColumn
parseJSON =
    String
-> (Object -> Parser InputColumn) -> Value -> Parser InputColumn
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputColumn"
      ( \Object
x ->
          Text -> InputColumnDataType -> InputColumn
InputColumn'
            (Text -> InputColumnDataType -> InputColumn)
-> Parser Text -> Parser (InputColumnDataType -> InputColumn)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name") Parser (InputColumnDataType -> InputColumn)
-> Parser InputColumnDataType -> Parser InputColumn
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser InputColumnDataType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
      )

instance Prelude.Hashable InputColumn

instance Prelude.NFData InputColumn

instance Core.ToJSON InputColumn where
  toJSON :: InputColumn -> Value
toJSON InputColumn' {Text
InputColumnDataType
type' :: InputColumnDataType
name :: Text
$sel:type':InputColumn' :: InputColumn -> InputColumnDataType
$sel:name:InputColumn' :: InputColumn -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> InputColumnDataType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InputColumnDataType
type')
          ]
      )