{-# 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-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.InputColumn 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.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
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]
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
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. 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' {$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 :: Lens' InputColumn Text
inputColumn_name = 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 :: Lens' InputColumn InputColumnDataType
inputColumn_type = 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 Data.FromJSON InputColumn where
  parseJSON :: Value -> Parser InputColumn
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InputColumn"
      ( \Object
x ->
          Text -> InputColumnDataType -> InputColumn
InputColumn'
            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
"Name")
            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
"Type")
      )

instance Prelude.Hashable InputColumn where
  hashWithSalt :: Int -> InputColumn -> Int
hashWithSalt Int
_salt InputColumn' {Text
InputColumnDataType
type' :: InputColumnDataType
name :: Text
$sel:type':InputColumn' :: InputColumn -> InputColumnDataType
$sel:name:InputColumn' :: InputColumn -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` InputColumnDataType
type'

instance Prelude.NFData InputColumn where
  rnf :: InputColumn -> ()
rnf InputColumn' {Text
InputColumnDataType
type' :: InputColumnDataType
name :: Text
$sel:type':InputColumn' :: InputColumn -> InputColumnDataType
$sel:name:InputColumn' :: InputColumn -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf InputColumnDataType
type'

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= InputColumnDataType
type')
          ]
      )