{-# 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.Datatype
-- 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.Datatype 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 structure representing the datatype of the value.
--
-- /See:/ 'newDatatype' smart constructor.
data Datatype = Datatype'
  { -- | The datatype of the value.
    Datatype -> Text
id :: Prelude.Text,
    -- | A label assigned to the datatype.
    Datatype -> Text
label :: Prelude.Text
  }
  deriving (Datatype -> Datatype -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Datatype -> Datatype -> Bool
$c/= :: Datatype -> Datatype -> Bool
== :: Datatype -> Datatype -> Bool
$c== :: Datatype -> Datatype -> Bool
Prelude.Eq, ReadPrec [Datatype]
ReadPrec Datatype
Int -> ReadS Datatype
ReadS [Datatype]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Datatype]
$creadListPrec :: ReadPrec [Datatype]
readPrec :: ReadPrec Datatype
$creadPrec :: ReadPrec Datatype
readList :: ReadS [Datatype]
$creadList :: ReadS [Datatype]
readsPrec :: Int -> ReadS Datatype
$creadsPrec :: Int -> ReadS Datatype
Prelude.Read, Int -> Datatype -> ShowS
[Datatype] -> ShowS
Datatype -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Datatype] -> ShowS
$cshowList :: [Datatype] -> ShowS
show :: Datatype -> String
$cshow :: Datatype -> String
showsPrec :: Int -> Datatype -> ShowS
$cshowsPrec :: Int -> Datatype -> ShowS
Prelude.Show, forall x. Rep Datatype x -> Datatype
forall x. Datatype -> Rep Datatype x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Datatype x -> Datatype
$cfrom :: forall x. Datatype -> Rep Datatype x
Prelude.Generic)

-- |
-- Create a value of 'Datatype' 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:
--
-- 'id', 'datatype_id' - The datatype of the value.
--
-- 'label', 'datatype_label' - A label assigned to the datatype.
newDatatype ::
  -- | 'id'
  Prelude.Text ->
  -- | 'label'
  Prelude.Text ->
  Datatype
newDatatype :: Text -> Text -> Datatype
newDatatype Text
pId_ Text
pLabel_ =
  Datatype' {$sel:id:Datatype' :: Text
id = Text
pId_, $sel:label:Datatype' :: Text
label = Text
pLabel_}

-- | The datatype of the value.
datatype_id :: Lens.Lens' Datatype Prelude.Text
datatype_id :: Lens' Datatype Text
datatype_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Datatype' {Text
id :: Text
$sel:id:Datatype' :: Datatype -> Text
id} -> Text
id) (\s :: Datatype
s@Datatype' {} Text
a -> Datatype
s {$sel:id:Datatype' :: Text
id = Text
a} :: Datatype)

-- | A label assigned to the datatype.
datatype_label :: Lens.Lens' Datatype Prelude.Text
datatype_label :: Lens' Datatype Text
datatype_label = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Datatype' {Text
label :: Text
$sel:label:Datatype' :: Datatype -> Text
label} -> Text
label) (\s :: Datatype
s@Datatype' {} Text
a -> Datatype
s {$sel:label:Datatype' :: Text
label = Text
a} :: Datatype)

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

instance Prelude.Hashable Datatype where
  hashWithSalt :: Int -> Datatype -> Int
hashWithSalt Int
_salt Datatype' {Text
label :: Text
id :: Text
$sel:label:Datatype' :: Datatype -> Text
$sel:id:Datatype' :: Datatype -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
label

instance Prelude.NFData Datatype where
  rnf :: Datatype -> ()
rnf Datatype' {Text
label :: Text
id :: Text
$sel:label:Datatype' :: Datatype -> Text
$sel:id:Datatype' :: Datatype -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
id seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
label

instance Data.ToJSON Datatype where
  toJSON :: Datatype -> Value
toJSON Datatype' {Text
label :: Text
id :: Text
$sel:label:Datatype' :: Datatype -> Text
$sel:id:Datatype' :: Datatype -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id),
            forall a. a -> Maybe a
Prelude.Just (Key
"Label" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
label)
          ]
      )