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

-- | Specifies a single column in a Glue schema definition.
--
-- /See:/ 'newGlueStudioSchemaColumn' smart constructor.
data GlueStudioSchemaColumn = GlueStudioSchemaColumn'
  { -- | The hive type for this column in the Glue Studio schema.
    GlueStudioSchemaColumn -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | The name of the column in the Glue Studio schema.
    GlueStudioSchemaColumn -> Text
name :: Prelude.Text
  }
  deriving (GlueStudioSchemaColumn -> GlueStudioSchemaColumn -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlueStudioSchemaColumn -> GlueStudioSchemaColumn -> Bool
$c/= :: GlueStudioSchemaColumn -> GlueStudioSchemaColumn -> Bool
== :: GlueStudioSchemaColumn -> GlueStudioSchemaColumn -> Bool
$c== :: GlueStudioSchemaColumn -> GlueStudioSchemaColumn -> Bool
Prelude.Eq, ReadPrec [GlueStudioSchemaColumn]
ReadPrec GlueStudioSchemaColumn
Int -> ReadS GlueStudioSchemaColumn
ReadS [GlueStudioSchemaColumn]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlueStudioSchemaColumn]
$creadListPrec :: ReadPrec [GlueStudioSchemaColumn]
readPrec :: ReadPrec GlueStudioSchemaColumn
$creadPrec :: ReadPrec GlueStudioSchemaColumn
readList :: ReadS [GlueStudioSchemaColumn]
$creadList :: ReadS [GlueStudioSchemaColumn]
readsPrec :: Int -> ReadS GlueStudioSchemaColumn
$creadsPrec :: Int -> ReadS GlueStudioSchemaColumn
Prelude.Read, Int -> GlueStudioSchemaColumn -> ShowS
[GlueStudioSchemaColumn] -> ShowS
GlueStudioSchemaColumn -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlueStudioSchemaColumn] -> ShowS
$cshowList :: [GlueStudioSchemaColumn] -> ShowS
show :: GlueStudioSchemaColumn -> String
$cshow :: GlueStudioSchemaColumn -> String
showsPrec :: Int -> GlueStudioSchemaColumn -> ShowS
$cshowsPrec :: Int -> GlueStudioSchemaColumn -> ShowS
Prelude.Show, forall x. Rep GlueStudioSchemaColumn x -> GlueStudioSchemaColumn
forall x. GlueStudioSchemaColumn -> Rep GlueStudioSchemaColumn x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GlueStudioSchemaColumn x -> GlueStudioSchemaColumn
$cfrom :: forall x. GlueStudioSchemaColumn -> Rep GlueStudioSchemaColumn x
Prelude.Generic)

-- |
-- Create a value of 'GlueStudioSchemaColumn' 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:
--
-- 'type'', 'glueStudioSchemaColumn_type' - The hive type for this column in the Glue Studio schema.
--
-- 'name', 'glueStudioSchemaColumn_name' - The name of the column in the Glue Studio schema.
newGlueStudioSchemaColumn ::
  -- | 'name'
  Prelude.Text ->
  GlueStudioSchemaColumn
newGlueStudioSchemaColumn :: Text -> GlueStudioSchemaColumn
newGlueStudioSchemaColumn Text
pName_ =
  GlueStudioSchemaColumn'
    { $sel:type':GlueStudioSchemaColumn' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:name:GlueStudioSchemaColumn' :: Text
name = Text
pName_
    }

-- | The hive type for this column in the Glue Studio schema.
glueStudioSchemaColumn_type :: Lens.Lens' GlueStudioSchemaColumn (Prelude.Maybe Prelude.Text)
glueStudioSchemaColumn_type :: Lens' GlueStudioSchemaColumn (Maybe Text)
glueStudioSchemaColumn_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueStudioSchemaColumn' {Maybe Text
type' :: Maybe Text
$sel:type':GlueStudioSchemaColumn' :: GlueStudioSchemaColumn -> Maybe Text
type'} -> Maybe Text
type') (\s :: GlueStudioSchemaColumn
s@GlueStudioSchemaColumn' {} Maybe Text
a -> GlueStudioSchemaColumn
s {$sel:type':GlueStudioSchemaColumn' :: Maybe Text
type' = Maybe Text
a} :: GlueStudioSchemaColumn)

-- | The name of the column in the Glue Studio schema.
glueStudioSchemaColumn_name :: Lens.Lens' GlueStudioSchemaColumn Prelude.Text
glueStudioSchemaColumn_name :: Lens' GlueStudioSchemaColumn Text
glueStudioSchemaColumn_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueStudioSchemaColumn' {Text
name :: Text
$sel:name:GlueStudioSchemaColumn' :: GlueStudioSchemaColumn -> Text
name} -> Text
name) (\s :: GlueStudioSchemaColumn
s@GlueStudioSchemaColumn' {} Text
a -> GlueStudioSchemaColumn
s {$sel:name:GlueStudioSchemaColumn' :: Text
name = Text
a} :: GlueStudioSchemaColumn)

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

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

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

instance Data.ToJSON GlueStudioSchemaColumn where
  toJSON :: GlueStudioSchemaColumn -> Value
toJSON GlueStudioSchemaColumn' {Maybe Text
Text
name :: Text
type' :: Maybe Text
$sel:name:GlueStudioSchemaColumn' :: GlueStudioSchemaColumn -> Text
$sel:type':GlueStudioSchemaColumn' :: GlueStudioSchemaColumn -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Type" 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
type',
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )