{-# 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.IoTAnalytics.Types.Column
-- 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.IoTAnalytics.Types.Column where

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

-- | Contains information about a column that stores your data.
--
-- /See:/ 'newColumn' smart constructor.
data Column = Column'
  { -- | The name of the column.
    Column -> Text
name :: Prelude.Text,
    -- | The type of data. For more information about the supported data types,
    -- see
    -- <https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-common.html Common data types>
    -- in the /Glue Developer Guide/.
    Column -> Text
type' :: Prelude.Text
  }
  deriving (Column -> Column -> Bool
(Column -> Column -> Bool)
-> (Column -> Column -> Bool) -> Eq Column
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Column -> Column -> Bool
$c/= :: Column -> Column -> Bool
== :: Column -> Column -> Bool
$c== :: Column -> Column -> Bool
Prelude.Eq, ReadPrec [Column]
ReadPrec Column
Int -> ReadS Column
ReadS [Column]
(Int -> ReadS Column)
-> ReadS [Column]
-> ReadPrec Column
-> ReadPrec [Column]
-> Read Column
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Column]
$creadListPrec :: ReadPrec [Column]
readPrec :: ReadPrec Column
$creadPrec :: ReadPrec Column
readList :: ReadS [Column]
$creadList :: ReadS [Column]
readsPrec :: Int -> ReadS Column
$creadsPrec :: Int -> ReadS Column
Prelude.Read, Int -> Column -> ShowS
[Column] -> ShowS
Column -> String
(Int -> Column -> ShowS)
-> (Column -> String) -> ([Column] -> ShowS) -> Show Column
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Column] -> ShowS
$cshowList :: [Column] -> ShowS
show :: Column -> String
$cshow :: Column -> String
showsPrec :: Int -> Column -> ShowS
$cshowsPrec :: Int -> Column -> ShowS
Prelude.Show, (forall x. Column -> Rep Column x)
-> (forall x. Rep Column x -> Column) -> Generic Column
forall x. Rep Column x -> Column
forall x. Column -> Rep Column x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Column x -> Column
$cfrom :: forall x. Column -> Rep Column x
Prelude.Generic)

-- |
-- Create a value of 'Column' 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', 'column_name' - The name of the column.
--
-- 'type'', 'column_type' - The type of data. For more information about the supported data types,
-- see
-- <https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-common.html Common data types>
-- in the /Glue Developer Guide/.
newColumn ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  Prelude.Text ->
  Column
newColumn :: Text -> Text -> Column
newColumn Text
pName_ Text
pType_ =
  Column' :: Text -> Text -> Column
Column' {$sel:name:Column' :: Text
name = Text
pName_, $sel:type':Column' :: Text
type' = Text
pType_}

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

-- | The type of data. For more information about the supported data types,
-- see
-- <https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-common.html Common data types>
-- in the /Glue Developer Guide/.
column_type :: Lens.Lens' Column Prelude.Text
column_type :: (Text -> f Text) -> Column -> f Column
column_type = (Column -> Text)
-> (Column -> Text -> Column) -> Lens Column Column Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Column' {Text
type' :: Text
$sel:type':Column' :: Column -> Text
type'} -> Text
type') (\s :: Column
s@Column' {} Text
a -> Column
s {$sel:type':Column' :: Text
type' = Text
a} :: Column)

instance Core.FromJSON Column where
  parseJSON :: Value -> Parser Column
parseJSON =
    String -> (Object -> Parser Column) -> Value -> Parser Column
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Column"
      ( \Object
x ->
          Text -> Text -> Column
Column'
            (Text -> Text -> Column) -> Parser Text -> Parser (Text -> Column)
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 (Text -> Column) -> Parser Text -> Parser Column
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
      )

instance Prelude.Hashable Column

instance Prelude.NFData Column

instance Core.ToJSON Column where
  toJSON :: Column -> Value
toJSON Column' {Text
type' :: Text
name :: Text
$sel:type':Column' :: Column -> Text
$sel:name:Column' :: Column -> 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 -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
type')
          ]
      )