{-# 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.Glue.Types.SchemaColumn
-- 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.Glue.Types.SchemaColumn 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

-- | A key-value pair representing a column and data type that this transform
-- can run against. The @Schema@ parameter of the @MLTransform@ may contain
-- up to 100 of these structures.
--
-- /See:/ 'newSchemaColumn' smart constructor.
data SchemaColumn = SchemaColumn'
  { -- | The type of data in the column.
    SchemaColumn -> Maybe Text
dataType :: Prelude.Maybe Prelude.Text,
    -- | The name of the column.
    SchemaColumn -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (SchemaColumn -> SchemaColumn -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaColumn -> SchemaColumn -> Bool
$c/= :: SchemaColumn -> SchemaColumn -> Bool
== :: SchemaColumn -> SchemaColumn -> Bool
$c== :: SchemaColumn -> SchemaColumn -> Bool
Prelude.Eq, ReadPrec [SchemaColumn]
ReadPrec SchemaColumn
Int -> ReadS SchemaColumn
ReadS [SchemaColumn]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchemaColumn]
$creadListPrec :: ReadPrec [SchemaColumn]
readPrec :: ReadPrec SchemaColumn
$creadPrec :: ReadPrec SchemaColumn
readList :: ReadS [SchemaColumn]
$creadList :: ReadS [SchemaColumn]
readsPrec :: Int -> ReadS SchemaColumn
$creadsPrec :: Int -> ReadS SchemaColumn
Prelude.Read, Int -> SchemaColumn -> ShowS
[SchemaColumn] -> ShowS
SchemaColumn -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaColumn] -> ShowS
$cshowList :: [SchemaColumn] -> ShowS
show :: SchemaColumn -> String
$cshow :: SchemaColumn -> String
showsPrec :: Int -> SchemaColumn -> ShowS
$cshowsPrec :: Int -> SchemaColumn -> ShowS
Prelude.Show, forall x. Rep SchemaColumn x -> SchemaColumn
forall x. SchemaColumn -> Rep SchemaColumn x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SchemaColumn x -> SchemaColumn
$cfrom :: forall x. SchemaColumn -> Rep SchemaColumn x
Prelude.Generic)

-- |
-- Create a value of 'SchemaColumn' 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', 'schemaColumn_dataType' - The type of data in the column.
--
-- 'name', 'schemaColumn_name' - The name of the column.
newSchemaColumn ::
  SchemaColumn
newSchemaColumn :: SchemaColumn
newSchemaColumn =
  SchemaColumn'
    { $sel:dataType:SchemaColumn' :: Maybe Text
dataType = forall a. Maybe a
Prelude.Nothing,
      $sel:name:SchemaColumn' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.Hashable SchemaColumn where
  hashWithSalt :: Int -> SchemaColumn -> Int
hashWithSalt Int
_salt SchemaColumn' {Maybe Text
name :: Maybe Text
dataType :: Maybe Text
$sel:name:SchemaColumn' :: SchemaColumn -> Maybe Text
$sel:dataType:SchemaColumn' :: SchemaColumn -> 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
name

instance Prelude.NFData SchemaColumn where
  rnf :: SchemaColumn -> ()
rnf SchemaColumn' {Maybe Text
name :: Maybe Text
dataType :: Maybe Text
$sel:name:SchemaColumn' :: SchemaColumn -> Maybe Text
$sel:dataType:SchemaColumn' :: SchemaColumn -> 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
name

instance Data.ToJSON SchemaColumn where
  toJSON :: SchemaColumn -> Value
toJSON SchemaColumn' {Maybe Text
name :: Maybe Text
dataType :: Maybe Text
$sel:name:SchemaColumn' :: SchemaColumn -> Maybe Text
$sel:dataType:SchemaColumn' :: SchemaColumn -> 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
"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
          ]
      )