{-# 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types.AttributeValue
import Amazonka.DynamoDB.Types.ScalarAttributeType
import Amazonka.DynamoDB.Types.WriteRequest
import qualified Amazonka.Prelude as Prelude
data AttributeDefinition = AttributeDefinition'
{
AttributeDefinition -> Text
attributeName :: Prelude.Text,
AttributeDefinition -> ScalarAttributeType
attributeType :: ScalarAttributeType
}
deriving (AttributeDefinition -> AttributeDefinition -> Bool
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]
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
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. 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'
{ $sel:attributeName:AttributeDefinition' :: Text
attributeName =
Text
pAttributeName_,
$sel:attributeType:AttributeDefinition' :: ScalarAttributeType
attributeType = ScalarAttributeType
pAttributeType_
}
attributeDefinition_attributeName :: Lens.Lens' AttributeDefinition Prelude.Text
attributeDefinition_attributeName :: Lens' AttributeDefinition Text
attributeDefinition_attributeName = 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 :: Lens' AttributeDefinition ScalarAttributeType
attributeDefinition_attributeType = 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 Data.FromJSON AttributeDefinition where
parseJSON :: Value -> Parser AttributeDefinition
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"AttributeDefinition"
( \Object
x ->
Text -> ScalarAttributeType -> AttributeDefinition
AttributeDefinition'
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
"AttributeName")
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
"AttributeType")
)
instance Prelude.Hashable AttributeDefinition where
hashWithSalt :: Int -> AttributeDefinition -> Int
hashWithSalt Int
_salt AttributeDefinition' {Text
ScalarAttributeType
attributeType :: ScalarAttributeType
attributeName :: Text
$sel:attributeType:AttributeDefinition' :: AttributeDefinition -> ScalarAttributeType
$sel:attributeName:AttributeDefinition' :: AttributeDefinition -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
attributeName
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ScalarAttributeType
attributeType
instance Prelude.NFData AttributeDefinition where
rnf :: AttributeDefinition -> ()
rnf AttributeDefinition' {Text
ScalarAttributeType
attributeType :: ScalarAttributeType
attributeName :: Text
$sel:attributeType:AttributeDefinition' :: AttributeDefinition -> ScalarAttributeType
$sel:attributeName:AttributeDefinition' :: AttributeDefinition -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
attributeName
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ScalarAttributeType
attributeType
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just
(Key
"AttributeName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
attributeName),
forall a. a -> Maybe a
Prelude.Just
(Key
"AttributeType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ScalarAttributeType
attributeType)
]
)