{-# 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.KeySchemaElement
-- 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.KeySchemaElement 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 partition key pair consisting of a name and a type.
--
-- /See:/ 'newKeySchemaElement' smart constructor.
data KeySchemaElement = KeySchemaElement'
  { -- | The name of a partition key.
    KeySchemaElement -> Text
name :: Prelude.Text,
    -- | The type of a partition key.
    KeySchemaElement -> Text
type' :: Prelude.Text
  }
  deriving (KeySchemaElement -> KeySchemaElement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeySchemaElement -> KeySchemaElement -> Bool
$c/= :: KeySchemaElement -> KeySchemaElement -> Bool
== :: KeySchemaElement -> KeySchemaElement -> Bool
$c== :: KeySchemaElement -> KeySchemaElement -> Bool
Prelude.Eq, ReadPrec [KeySchemaElement]
ReadPrec KeySchemaElement
Int -> ReadS KeySchemaElement
ReadS [KeySchemaElement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeySchemaElement]
$creadListPrec :: ReadPrec [KeySchemaElement]
readPrec :: ReadPrec KeySchemaElement
$creadPrec :: ReadPrec KeySchemaElement
readList :: ReadS [KeySchemaElement]
$creadList :: ReadS [KeySchemaElement]
readsPrec :: Int -> ReadS KeySchemaElement
$creadsPrec :: Int -> ReadS KeySchemaElement
Prelude.Read, Int -> KeySchemaElement -> ShowS
[KeySchemaElement] -> ShowS
KeySchemaElement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeySchemaElement] -> ShowS
$cshowList :: [KeySchemaElement] -> ShowS
show :: KeySchemaElement -> String
$cshow :: KeySchemaElement -> String
showsPrec :: Int -> KeySchemaElement -> ShowS
$cshowsPrec :: Int -> KeySchemaElement -> ShowS
Prelude.Show, forall x. Rep KeySchemaElement x -> KeySchemaElement
forall x. KeySchemaElement -> Rep KeySchemaElement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KeySchemaElement x -> KeySchemaElement
$cfrom :: forall x. KeySchemaElement -> Rep KeySchemaElement x
Prelude.Generic)

-- |
-- Create a value of 'KeySchemaElement' 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', 'keySchemaElement_name' - The name of a partition key.
--
-- 'type'', 'keySchemaElement_type' - The type of a partition key.
newKeySchemaElement ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  Prelude.Text ->
  KeySchemaElement
newKeySchemaElement :: Text -> Text -> KeySchemaElement
newKeySchemaElement Text
pName_ Text
pType_ =
  KeySchemaElement' {$sel:name:KeySchemaElement' :: Text
name = Text
pName_, $sel:type':KeySchemaElement' :: Text
type' = Text
pType_}

-- | The name of a partition key.
keySchemaElement_name :: Lens.Lens' KeySchemaElement Prelude.Text
keySchemaElement_name :: Lens' KeySchemaElement Text
keySchemaElement_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeySchemaElement' {Text
name :: Text
$sel:name:KeySchemaElement' :: KeySchemaElement -> Text
name} -> Text
name) (\s :: KeySchemaElement
s@KeySchemaElement' {} Text
a -> KeySchemaElement
s {$sel:name:KeySchemaElement' :: Text
name = Text
a} :: KeySchemaElement)

-- | The type of a partition key.
keySchemaElement_type :: Lens.Lens' KeySchemaElement Prelude.Text
keySchemaElement_type :: Lens' KeySchemaElement Text
keySchemaElement_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeySchemaElement' {Text
type' :: Text
$sel:type':KeySchemaElement' :: KeySchemaElement -> Text
type'} -> Text
type') (\s :: KeySchemaElement
s@KeySchemaElement' {} Text
a -> KeySchemaElement
s {$sel:type':KeySchemaElement' :: Text
type' = Text
a} :: KeySchemaElement)

instance Data.FromJSON KeySchemaElement where
  parseJSON :: Value -> Parser KeySchemaElement
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"KeySchemaElement"
      ( \Object
x ->
          Text -> Text -> KeySchemaElement
KeySchemaElement'
            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 KeySchemaElement where
  hashWithSalt :: Int -> KeySchemaElement -> Int
hashWithSalt Int
_salt KeySchemaElement' {Text
type' :: Text
name :: Text
$sel:type':KeySchemaElement' :: KeySchemaElement -> Text
$sel:name:KeySchemaElement' :: KeySchemaElement -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
type'

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