{-# 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 #-}
module Amazonka.DynamoDB.Types.AttributeDefinition where
import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.ScalarAttributeType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data AttributeDefinition = AttributeDefinition'
{
AttributeDefinition -> Text
attributeName :: Prelude.Text,
AttributeDefinition -> ScalarAttributeType
attributeType :: ScalarAttributeType
}
deriving (AttributeDefinition -> AttributeDefinition -> Bool
(AttributeDefinition -> AttributeDefinition -> Bool)
-> (AttributeDefinition -> AttributeDefinition -> Bool)
-> Eq AttributeDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttributeDefinition -> AttributeDefinition -> Bool
$c/= :: AttributeDefinition -> AttributeDefinition -> Bool
== :: AttributeDefinition -> AttributeDefinition -> Bool
$c== :: AttributeDefinition -> AttributeDefinition -> Bool
Prelude.Eq, ReadPrec [AttributeDefinition]
ReadPrec AttributeDefinition
Int -> ReadS AttributeDefinition
ReadS [AttributeDefinition]
(Int -> ReadS AttributeDefinition)
-> ReadS [AttributeDefinition]
-> ReadPrec AttributeDefinition
-> ReadPrec [AttributeDefinition]
-> Read AttributeDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttributeDefinition]
$creadListPrec :: ReadPrec [AttributeDefinition]
readPrec :: ReadPrec AttributeDefinition
$creadPrec :: ReadPrec AttributeDefinition
readList :: ReadS [AttributeDefinition]
$creadList :: ReadS [AttributeDefinition]
readsPrec :: Int -> ReadS AttributeDefinition
$creadsPrec :: Int -> ReadS AttributeDefinition
Prelude.Read, Int -> AttributeDefinition -> ShowS
[AttributeDefinition] -> ShowS
AttributeDefinition -> String
(Int -> AttributeDefinition -> ShowS)
-> (AttributeDefinition -> String)
-> ([AttributeDefinition] -> ShowS)
-> Show AttributeDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttributeDefinition] -> ShowS
$cshowList :: [AttributeDefinition] -> ShowS
show :: AttributeDefinition -> String
$cshow :: AttributeDefinition -> String
showsPrec :: Int -> AttributeDefinition -> ShowS
$cshowsPrec :: Int -> AttributeDefinition -> ShowS
Prelude.Show, (forall x. AttributeDefinition -> Rep AttributeDefinition x)
-> (forall x. Rep AttributeDefinition x -> AttributeDefinition)
-> Generic AttributeDefinition
forall x. Rep AttributeDefinition x -> AttributeDefinition
forall x. AttributeDefinition -> Rep AttributeDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttributeDefinition x -> AttributeDefinition
$cfrom :: forall x. AttributeDefinition -> Rep AttributeDefinition x
Prelude.Generic)
newAttributeDefinition ::
Prelude.Text ->
ScalarAttributeType ->
AttributeDefinition
newAttributeDefinition :: Text -> ScalarAttributeType -> AttributeDefinition
newAttributeDefinition
Text
pAttributeName_
ScalarAttributeType
pAttributeType_ =
AttributeDefinition' :: Text -> ScalarAttributeType -> AttributeDefinition
AttributeDefinition'
{ $sel:attributeName:AttributeDefinition' :: Text
attributeName =
Text
pAttributeName_,
$sel:attributeType:AttributeDefinition' :: ScalarAttributeType
attributeType = ScalarAttributeType
pAttributeType_
}
attributeDefinition_attributeName :: Lens.Lens' AttributeDefinition Prelude.Text
attributeDefinition_attributeName :: (Text -> f Text) -> AttributeDefinition -> f AttributeDefinition
attributeDefinition_attributeName = (AttributeDefinition -> Text)
-> (AttributeDefinition -> Text -> AttributeDefinition)
-> Lens AttributeDefinition AttributeDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeDefinition' {Text
attributeName :: Text
$sel:attributeName:AttributeDefinition' :: AttributeDefinition -> Text
attributeName} -> Text
attributeName) (\s :: AttributeDefinition
s@AttributeDefinition' {} Text
a -> AttributeDefinition
s {$sel:attributeName:AttributeDefinition' :: Text
attributeName = Text
a} :: AttributeDefinition)
attributeDefinition_attributeType :: Lens.Lens' AttributeDefinition ScalarAttributeType
attributeDefinition_attributeType :: (ScalarAttributeType -> f ScalarAttributeType)
-> AttributeDefinition -> f AttributeDefinition
attributeDefinition_attributeType = (AttributeDefinition -> ScalarAttributeType)
-> (AttributeDefinition
-> ScalarAttributeType -> AttributeDefinition)
-> Lens
AttributeDefinition
AttributeDefinition
ScalarAttributeType
ScalarAttributeType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeDefinition' {ScalarAttributeType
attributeType :: ScalarAttributeType
$sel:attributeType:AttributeDefinition' :: AttributeDefinition -> ScalarAttributeType
attributeType} -> ScalarAttributeType
attributeType) (\s :: AttributeDefinition
s@AttributeDefinition' {} ScalarAttributeType
a -> AttributeDefinition
s {$sel:attributeType:AttributeDefinition' :: ScalarAttributeType
attributeType = ScalarAttributeType
a} :: AttributeDefinition)
instance Core.FromJSON AttributeDefinition where
parseJSON :: Value -> Parser AttributeDefinition
parseJSON =
String
-> (Object -> Parser AttributeDefinition)
-> Value
-> Parser AttributeDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"AttributeDefinition"
( \Object
x ->
Text -> ScalarAttributeType -> AttributeDefinition
AttributeDefinition'
(Text -> ScalarAttributeType -> AttributeDefinition)
-> Parser Text
-> Parser (ScalarAttributeType -> AttributeDefinition)
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
"AttributeName")
Parser (ScalarAttributeType -> AttributeDefinition)
-> Parser ScalarAttributeType -> Parser AttributeDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ScalarAttributeType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AttributeType")
)
instance Prelude.Hashable AttributeDefinition
instance Prelude.NFData AttributeDefinition
instance Core.ToJSON AttributeDefinition where
toJSON :: AttributeDefinition -> Value
toJSON AttributeDefinition' {Text
ScalarAttributeType
attributeType :: ScalarAttributeType
attributeName :: Text
$sel:attributeType:AttributeDefinition' :: AttributeDefinition -> ScalarAttributeType
$sel:attributeName:AttributeDefinition' :: AttributeDefinition -> 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
"AttributeName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
attributeName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"AttributeType" Text -> ScalarAttributeType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ScalarAttributeType
attributeType)
]
)