module Network.AWS.DynamoDB.Types
(
DynamoDB
, JSONError
, WriteRequest
, writeRequest
, wDeleteRequest
, wPutRequest
, ProvisionedThroughputDescription
, provisionedThroughputDescription
, ptdLastDecreaseDateTime
, ptdLastIncreaseDateTime
, ptdNumberOfDecreasesToday
, ptdReadCapacityUnits
, ptdWriteCapacityUnits
, KeyType (..)
, AttributeValue
, attributeValue
, avB
, avBOOL
, avBS
, avL
, avM
, avN
, avNS
, avNULL
, avS
, avSS
, IndexStatus (..)
, ProvisionedThroughput
, provisionedThroughput
, ptReadCapacityUnits
, ptWriteCapacityUnits
, TableStatus (..)
, ProjectionType (..)
, TableDescription
, tableDescription
, tdAttributeDefinitions
, tdCreationDateTime
, tdGlobalSecondaryIndexes
, tdItemCount
, tdKeySchema
, tdLocalSecondaryIndexes
, tdProvisionedThroughput
, tdTableName
, tdTableSizeBytes
, tdTableStatus
, KeysAndAttributes
, keysAndAttributes
, kaaAttributesToGet
, kaaConsistentRead
, kaaExpressionAttributeNames
, kaaKeys
, kaaProjectionExpression
, ReturnConsumedCapacity (..)
, ReturnItemCollectionMetrics (..)
, AttributeValueUpdate
, attributeValueUpdate
, avuAction
, avuValue
, ExpectedAttributeValue
, expectedAttributeValue
, eavAttributeValueList
, eavComparisonOperator
, eavExists
, eavValue
, AttributeDefinition
, attributeDefinition
, adAttributeName
, adAttributeType
, ComparisonOperator (..)
, ReturnValue (..)
, LocalSecondaryIndex
, localSecondaryIndex
, lsiIndexName
, lsiKeySchema
, lsiProjection
, GlobalSecondaryIndexDescription
, globalSecondaryIndexDescription
, gsidIndexName
, gsidIndexSizeBytes
, gsidIndexStatus
, gsidItemCount
, gsidKeySchema
, gsidProjection
, gsidProvisionedThroughput
, ItemCollectionMetrics
, itemCollectionMetrics
, icmItemCollectionKey
, icmSizeEstimateRangeGB
, Capacity
, capacity
, cCapacityUnits
, ConsumedCapacity
, consumedCapacity
, ccCapacityUnits
, ccGlobalSecondaryIndexes
, ccLocalSecondaryIndexes
, ccTable
, ccTableName
, GlobalSecondaryIndex
, globalSecondaryIndex
, gsiIndexName
, gsiKeySchema
, gsiProjection
, gsiProvisionedThroughput
, LocalSecondaryIndexDescription
, localSecondaryIndexDescription
, lsidIndexName
, lsidIndexSizeBytes
, lsidItemCount
, lsidKeySchema
, lsidProjection
, AttributeAction (..)
, ScalarAttributeType (..)
, Projection
, projection
, pNonKeyAttributes
, pProjectionType
, Select (..)
, KeySchemaElement
, keySchemaElement
, kseAttributeName
, kseKeyType
, DeleteRequest
, deleteRequest
, dKey
, UpdateGlobalSecondaryIndexAction
, updateGlobalSecondaryIndexAction
, ugsiaIndexName
, ugsiaProvisionedThroughput
, PutRequest
, putRequest
, pItem
, Condition
, condition
, cAttributeValueList
, cComparisonOperator
, ConditionalOperator (..)
, GlobalSecondaryIndexUpdate
, globalSecondaryIndexUpdate
, gsiuUpdate
) where
import Data.Char (isUpper)
import Network.AWS.Error
import Network.AWS.Prelude
import Network.AWS.Signing.V4
import qualified GHC.Exts
data DynamoDB
instance AWSService DynamoDB where
type Sg DynamoDB = V4
type Er DynamoDB = JSONError
service = Service
{ _svcEndpoint = regional
, _svcAbbrev = "DynamoDB"
, _svcPrefix = "dynamodb"
, _svcVersion = "2012-08-10"
, _svcTargetPrefix = Just "DynamoDB_20120810"
, _svcJSONVersion = Just "1.0"
}
handle = jsonError statusSuccess
data WriteRequest = WriteRequest
{ _wDeleteRequest :: Maybe DeleteRequest
, _wPutRequest :: Maybe PutRequest
} deriving (Eq, Show)
writeRequest :: WriteRequest
writeRequest = WriteRequest
{ _wPutRequest = Nothing
, _wDeleteRequest = Nothing
}
wDeleteRequest :: Lens' WriteRequest (Maybe DeleteRequest)
wDeleteRequest = lens _wDeleteRequest (\s a -> s { _wDeleteRequest = a })
wPutRequest :: Lens' WriteRequest (Maybe PutRequest)
wPutRequest = lens _wPutRequest (\s a -> s { _wPutRequest = a })
instance FromJSON WriteRequest where
parseJSON = withObject "WriteRequest" $ \o -> WriteRequest
<$> o .:? "DeleteRequest"
<*> o .:? "PutRequest"
instance ToJSON WriteRequest where
toJSON WriteRequest{..} = object
[ "PutRequest" .= _wPutRequest
, "DeleteRequest" .= _wDeleteRequest
]
data ProvisionedThroughputDescription = ProvisionedThroughputDescription
{ _ptdLastDecreaseDateTime :: Maybe RFC822
, _ptdLastIncreaseDateTime :: Maybe RFC822
, _ptdNumberOfDecreasesToday :: Maybe Nat
, _ptdReadCapacityUnits :: Maybe Nat
, _ptdWriteCapacityUnits :: Maybe Nat
} deriving (Eq, Ord, Show)
provisionedThroughputDescription :: ProvisionedThroughputDescription
provisionedThroughputDescription = ProvisionedThroughputDescription
{ _ptdLastIncreaseDateTime = Nothing
, _ptdLastDecreaseDateTime = Nothing
, _ptdNumberOfDecreasesToday = Nothing
, _ptdReadCapacityUnits = Nothing
, _ptdWriteCapacityUnits = Nothing
}
ptdLastDecreaseDateTime :: Lens' ProvisionedThroughputDescription (Maybe UTCTime)
ptdLastDecreaseDateTime =
lens _ptdLastDecreaseDateTime (\s a -> s { _ptdLastDecreaseDateTime = a })
. mapping _Time
ptdLastIncreaseDateTime :: Lens' ProvisionedThroughputDescription (Maybe UTCTime)
ptdLastIncreaseDateTime =
lens _ptdLastIncreaseDateTime (\s a -> s { _ptdLastIncreaseDateTime = a })
. mapping _Time
ptdNumberOfDecreasesToday :: Lens' ProvisionedThroughputDescription (Maybe Natural)
ptdNumberOfDecreasesToday =
lens _ptdNumberOfDecreasesToday
(\s a -> s { _ptdNumberOfDecreasesToday = a })
. mapping _Nat
ptdReadCapacityUnits :: Lens' ProvisionedThroughputDescription (Maybe Natural)
ptdReadCapacityUnits =
lens _ptdReadCapacityUnits (\s a -> s { _ptdReadCapacityUnits = a })
. mapping _Nat
ptdWriteCapacityUnits :: Lens' ProvisionedThroughputDescription (Maybe Natural)
ptdWriteCapacityUnits =
lens _ptdWriteCapacityUnits (\s a -> s { _ptdWriteCapacityUnits = a })
. mapping _Nat
instance FromJSON ProvisionedThroughputDescription where
parseJSON = withObject "ProvisionedThroughputDescription" $ \o -> ProvisionedThroughputDescription
<$> o .:? "LastDecreaseDateTime"
<*> o .:? "LastIncreaseDateTime"
<*> o .:? "NumberOfDecreasesToday"
<*> o .:? "ReadCapacityUnits"
<*> o .:? "WriteCapacityUnits"
instance ToJSON ProvisionedThroughputDescription where
toJSON ProvisionedThroughputDescription{..} = object
[ "LastIncreaseDateTime" .= _ptdLastIncreaseDateTime
, "LastDecreaseDateTime" .= _ptdLastDecreaseDateTime
, "NumberOfDecreasesToday" .= _ptdNumberOfDecreasesToday
, "ReadCapacityUnits" .= _ptdReadCapacityUnits
, "WriteCapacityUnits" .= _ptdWriteCapacityUnits
]
data KeyType
= Hash
| Range
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable KeyType
instance FromText KeyType where
parser = match "HASH" Hash
<|> match "RANGE" Range
instance ToText KeyType where
toText = \case
Hash -> "HASH"
Range -> "RANGE"
instance ToByteString KeyType
instance ToHeader KeyType
instance ToQuery KeyType
instance FromJSON KeyType where
parseJSON = parseJSONText "KeyType"
instance ToJSON KeyType where
toJSON = toJSONText
data AttributeValue = AttributeValue
{ _avB :: Maybe Base64
, _avBOOL :: Maybe Bool
, _avBS :: List "BS" Base64
, _avL :: List "L" AttributeValue
, _avM :: Map Text AttributeValue
, _avN :: Maybe Text
, _avNS :: List "NS" Text
, _avNULL :: Maybe Bool
, _avS :: Maybe Text
, _avSS :: List "SS" Text
} deriving (Eq, Show)
attributeValue :: AttributeValue
attributeValue = AttributeValue
{ _avS = Nothing
, _avN = Nothing
, _avB = Nothing
, _avSS = mempty
, _avNS = mempty
, _avBS = mempty
, _avM = mempty
, _avL = mempty
, _avNULL = Nothing
, _avBOOL = Nothing
}
avB :: Lens' AttributeValue (Maybe Base64)
avB = lens _avB (\s a -> s { _avB = a })
avBOOL :: Lens' AttributeValue (Maybe Bool)
avBOOL = lens _avBOOL (\s a -> s { _avBOOL = a })
avBS :: Lens' AttributeValue [Base64]
avBS = lens _avBS (\s a -> s { _avBS = a }) . _List
avL :: Lens' AttributeValue [AttributeValue]
avL = lens _avL (\s a -> s { _avL = a }) . _List
avM :: Lens' AttributeValue (HashMap Text AttributeValue)
avM = lens _avM (\s a -> s { _avM = a }) . _Map
avN :: Lens' AttributeValue (Maybe Text)
avN = lens _avN (\s a -> s { _avN = a })
avNS :: Lens' AttributeValue [Text]
avNS = lens _avNS (\s a -> s { _avNS = a }) . _List
avNULL :: Lens' AttributeValue (Maybe Bool)
avNULL = lens _avNULL (\s a -> s { _avNULL = a })
avS :: Lens' AttributeValue (Maybe Text)
avS = lens _avS (\s a -> s { _avS = a })
avSS :: Lens' AttributeValue [Text]
avSS = lens _avSS (\s a -> s { _avSS = a }) . _List
instance FromJSON AttributeValue where
parseJSON = withObject "AttributeValue" $ \o -> AttributeValue
<$> o .:? "B"
<*> o .:? "BOOL"
<*> o .: "BS"
<*> o .: "L"
<*> o .: "M"
<*> o .:? "N"
<*> o .: "NS"
<*> o .:? "NULL"
<*> o .:? "S"
<*> o .: "SS"
instance ToJSON AttributeValue where
toJSON AttributeValue{..} = object
[ "S" .= _avS
, "N" .= _avN
, "B" .= _avB
, "SS" .= _avSS
, "NS" .= _avNS
, "BS" .= _avBS
, "M" .= _avM
, "L" .= _avL
, "NULL" .= _avNULL
, "BOOL" .= _avBOOL
]
data IndexStatus
= Active
| Creating
| Deleting
| Updating
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable IndexStatus
instance FromText IndexStatus where
parser = match "ACTIVE" Active
<|> match "CREATING" Creating
<|> match "DELETING" Deleting
<|> match "UPDATING" Updating
instance ToText IndexStatus where
toText = \case
Active -> "ACTIVE"
Creating -> "CREATING"
Deleting -> "DELETING"
Updating -> "UPDATING"
instance ToByteString IndexStatus
instance ToHeader IndexStatus
instance ToQuery IndexStatus
instance FromJSON IndexStatus where
parseJSON = parseJSONText "IndexStatus"
instance ToJSON IndexStatus where
toJSON = toJSONText
data ProvisionedThroughput = ProvisionedThroughput
{ _ptReadCapacityUnits :: Nat
, _ptWriteCapacityUnits :: Nat
} deriving (Eq, Ord, Show)
provisionedThroughput :: Natural
-> Natural
-> ProvisionedThroughput
provisionedThroughput p1 p2 = ProvisionedThroughput
{ _ptReadCapacityUnits = withIso _Nat (const id) p1
, _ptWriteCapacityUnits = withIso _Nat (const id) p2
}
ptReadCapacityUnits :: Lens' ProvisionedThroughput Natural
ptReadCapacityUnits =
lens _ptReadCapacityUnits (\s a -> s { _ptReadCapacityUnits = a })
. _Nat
ptWriteCapacityUnits :: Lens' ProvisionedThroughput Natural
ptWriteCapacityUnits =
lens _ptWriteCapacityUnits (\s a -> s { _ptWriteCapacityUnits = a })
. _Nat
instance FromJSON ProvisionedThroughput where
parseJSON = withObject "ProvisionedThroughput" $ \o -> ProvisionedThroughput
<$> o .: "ReadCapacityUnits"
<*> o .: "WriteCapacityUnits"
instance ToJSON ProvisionedThroughput where
toJSON ProvisionedThroughput{..} = object
[ "ReadCapacityUnits" .= _ptReadCapacityUnits
, "WriteCapacityUnits" .= _ptWriteCapacityUnits
]
data TableStatus
= TSActive
| TSCreating
| TSDeleting
| TSUpdating
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable TableStatus
instance FromText TableStatus where
parser = match "ACTIVE" TSActive
<|> match "CREATING" TSCreating
<|> match "DELETING" TSDeleting
<|> match "UPDATING" TSUpdating
instance ToText TableStatus where
toText = \case
TSActive -> "ACTIVE"
TSCreating -> "CREATING"
TSDeleting -> "DELETING"
TSUpdating -> "UPDATING"
instance ToByteString TableStatus
instance ToHeader TableStatus
instance ToQuery TableStatus
instance FromJSON TableStatus where
parseJSON = parseJSONText "TableStatus"
instance ToJSON TableStatus where
toJSON = toJSONText
data ProjectionType
= All
| Include
| KeysOnly
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable ProjectionType
instance FromText ProjectionType where
parser = match "ALL" All
<|> match "INCLUDE" Include
<|> match "KEYS_ONLY" KeysOnly
instance ToText ProjectionType where
toText = \case
All -> "ALL"
Include -> "INCLUDE"
KeysOnly -> "KEYS_ONLY"
instance ToByteString ProjectionType
instance ToHeader ProjectionType
instance ToQuery ProjectionType
instance FromJSON ProjectionType where
parseJSON = parseJSONText "ProjectionType"
instance ToJSON ProjectionType where
toJSON = toJSONText
data TableDescription = TableDescription
{ _tdAttributeDefinitions :: List "AttributeDefinitions" AttributeDefinition
, _tdCreationDateTime :: Maybe RFC822
, _tdGlobalSecondaryIndexes :: List "GlobalSecondaryIndexes" GlobalSecondaryIndexDescription
, _tdItemCount :: Maybe Integer
, _tdKeySchema :: List1 "KeySchema" KeySchemaElement
, _tdLocalSecondaryIndexes :: List "LocalSecondaryIndexes" LocalSecondaryIndexDescription
, _tdProvisionedThroughput :: Maybe ProvisionedThroughputDescription
, _tdTableName :: Maybe Text
, _tdTableSizeBytes :: Maybe Integer
, _tdTableStatus :: Maybe TableStatus
} deriving (Eq, Show)
tableDescription :: NonEmpty KeySchemaElement
-> TableDescription
tableDescription p1 = TableDescription
{ _tdKeySchema = withIso _List1 (const id) p1
, _tdAttributeDefinitions = mempty
, _tdTableName = Nothing
, _tdTableStatus = Nothing
, _tdCreationDateTime = Nothing
, _tdProvisionedThroughput = Nothing
, _tdTableSizeBytes = Nothing
, _tdItemCount = Nothing
, _tdLocalSecondaryIndexes = mempty
, _tdGlobalSecondaryIndexes = mempty
}
tdAttributeDefinitions :: Lens' TableDescription [AttributeDefinition]
tdAttributeDefinitions =
lens _tdAttributeDefinitions (\s a -> s { _tdAttributeDefinitions = a })
. _List
tdCreationDateTime :: Lens' TableDescription (Maybe UTCTime)
tdCreationDateTime =
lens _tdCreationDateTime (\s a -> s { _tdCreationDateTime = a })
. mapping _Time
tdGlobalSecondaryIndexes :: Lens' TableDescription [GlobalSecondaryIndexDescription]
tdGlobalSecondaryIndexes =
lens _tdGlobalSecondaryIndexes
(\s a -> s { _tdGlobalSecondaryIndexes = a })
. _List
tdItemCount :: Lens' TableDescription (Maybe Integer)
tdItemCount = lens _tdItemCount (\s a -> s { _tdItemCount = a })
tdKeySchema :: Lens' TableDescription (NonEmpty KeySchemaElement)
tdKeySchema = lens _tdKeySchema (\s a -> s { _tdKeySchema = a }) . _List1
tdLocalSecondaryIndexes :: Lens' TableDescription [LocalSecondaryIndexDescription]
tdLocalSecondaryIndexes =
lens _tdLocalSecondaryIndexes (\s a -> s { _tdLocalSecondaryIndexes = a })
. _List
tdProvisionedThroughput :: Lens' TableDescription (Maybe ProvisionedThroughputDescription)
tdProvisionedThroughput =
lens _tdProvisionedThroughput (\s a -> s { _tdProvisionedThroughput = a })
tdTableName :: Lens' TableDescription (Maybe Text)
tdTableName = lens _tdTableName (\s a -> s { _tdTableName = a })
tdTableSizeBytes :: Lens' TableDescription (Maybe Integer)
tdTableSizeBytes = lens _tdTableSizeBytes (\s a -> s { _tdTableSizeBytes = a })
tdTableStatus :: Lens' TableDescription (Maybe TableStatus)
tdTableStatus = lens _tdTableStatus (\s a -> s { _tdTableStatus = a })
instance FromJSON TableDescription where
parseJSON = withObject "TableDescription" $ \o -> TableDescription
<$> o .: "AttributeDefinitions"
<*> o .:? "CreationDateTime"
<*> o .: "GlobalSecondaryIndexes"
<*> o .:? "ItemCount"
<*> o .: "KeySchema"
<*> o .: "LocalSecondaryIndexes"
<*> o .:? "ProvisionedThroughput"
<*> o .:? "TableName"
<*> o .:? "TableSizeBytes"
<*> o .:? "TableStatus"
instance ToJSON TableDescription where
toJSON TableDescription{..} = object
[ "AttributeDefinitions" .= _tdAttributeDefinitions
, "TableName" .= _tdTableName
, "KeySchema" .= _tdKeySchema
, "TableStatus" .= _tdTableStatus
, "CreationDateTime" .= _tdCreationDateTime
, "ProvisionedThroughput" .= _tdProvisionedThroughput
, "TableSizeBytes" .= _tdTableSizeBytes
, "ItemCount" .= _tdItemCount
, "LocalSecondaryIndexes" .= _tdLocalSecondaryIndexes
, "GlobalSecondaryIndexes" .= _tdGlobalSecondaryIndexes
]
data KeysAndAttributes = KeysAndAttributes
{ _kaaAttributesToGet :: List1 "AttributesToGet" Text
, _kaaConsistentRead :: Maybe Bool
, _kaaExpressionAttributeNames :: Map Text Text
, _kaaKeys :: List1 "Keys" (Map Text AttributeValue)
, _kaaProjectionExpression :: Maybe Text
} deriving (Eq, Show)
keysAndAttributes :: NonEmpty (HashMap Text AttributeValue)
-> NonEmpty Text
-> KeysAndAttributes
keysAndAttributes p1 p2 = KeysAndAttributes
{ _kaaKeys = withIso _List1 (const id) p1
, _kaaAttributesToGet = withIso _List1 (const id) p2
, _kaaConsistentRead = Nothing
, _kaaProjectionExpression = Nothing
, _kaaExpressionAttributeNames = mempty
}
kaaAttributesToGet :: Lens' KeysAndAttributes (NonEmpty Text)
kaaAttributesToGet =
lens _kaaAttributesToGet (\s a -> s { _kaaAttributesToGet = a })
. _List1
kaaConsistentRead :: Lens' KeysAndAttributes (Maybe Bool)
kaaConsistentRead =
lens _kaaConsistentRead (\s a -> s { _kaaConsistentRead = a })
kaaExpressionAttributeNames :: Lens' KeysAndAttributes (HashMap Text Text)
kaaExpressionAttributeNames =
lens _kaaExpressionAttributeNames
(\s a -> s { _kaaExpressionAttributeNames = a })
. _Map
kaaKeys :: Lens' KeysAndAttributes (NonEmpty (HashMap Text AttributeValue))
kaaKeys = lens _kaaKeys (\s a -> s { _kaaKeys = a }) . _List1
kaaProjectionExpression :: Lens' KeysAndAttributes (Maybe Text)
kaaProjectionExpression =
lens _kaaProjectionExpression (\s a -> s { _kaaProjectionExpression = a })
instance FromJSON KeysAndAttributes where
parseJSON = withObject "KeysAndAttributes" $ \o -> KeysAndAttributes
<$> o .: "AttributesToGet"
<*> o .:? "ConsistentRead"
<*> o .: "ExpressionAttributeNames"
<*> o .: "Keys"
<*> o .:? "ProjectionExpression"
instance ToJSON KeysAndAttributes where
toJSON KeysAndAttributes{..} = object
[ "Keys" .= _kaaKeys
, "AttributesToGet" .= _kaaAttributesToGet
, "ConsistentRead" .= _kaaConsistentRead
, "ProjectionExpression" .= _kaaProjectionExpression
, "ExpressionAttributeNames" .= _kaaExpressionAttributeNames
]
data ReturnConsumedCapacity
= Indexes
| None
| Total
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable ReturnConsumedCapacity
instance FromText ReturnConsumedCapacity where
parser = match "INDEXES" Indexes
<|> match "NONE" None
<|> match "TOTAL" Total
instance ToText ReturnConsumedCapacity where
toText = \case
Indexes -> "INDEXES"
None -> "NONE"
Total -> "TOTAL"
instance ToByteString ReturnConsumedCapacity
instance ToHeader ReturnConsumedCapacity
instance ToQuery ReturnConsumedCapacity
instance FromJSON ReturnConsumedCapacity where
parseJSON = parseJSONText "ReturnConsumedCapacity"
instance ToJSON ReturnConsumedCapacity where
toJSON = toJSONText
data ReturnItemCollectionMetrics
= RICMNone
| RICMSize
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable ReturnItemCollectionMetrics
instance FromText ReturnItemCollectionMetrics where
parser = match "NONE" RICMNone
<|> match "SIZE" RICMSize
instance ToText ReturnItemCollectionMetrics where
toText = \case
RICMNone -> "NONE"
RICMSize -> "SIZE"
instance ToByteString ReturnItemCollectionMetrics
instance ToHeader ReturnItemCollectionMetrics
instance ToQuery ReturnItemCollectionMetrics
instance FromJSON ReturnItemCollectionMetrics where
parseJSON = parseJSONText "ReturnItemCollectionMetrics"
instance ToJSON ReturnItemCollectionMetrics where
toJSON = toJSONText
data AttributeValueUpdate = AttributeValueUpdate
{ _avuAction :: Maybe AttributeAction
, _avuValue :: Maybe AttributeValue
} deriving (Eq, Show)
attributeValueUpdate :: AttributeValueUpdate
attributeValueUpdate = AttributeValueUpdate
{ _avuValue = Nothing
, _avuAction = Nothing
}
avuAction :: Lens' AttributeValueUpdate (Maybe AttributeAction)
avuAction = lens _avuAction (\s a -> s { _avuAction = a })
avuValue :: Lens' AttributeValueUpdate (Maybe AttributeValue)
avuValue = lens _avuValue (\s a -> s { _avuValue = a })
instance FromJSON AttributeValueUpdate where
parseJSON = withObject "AttributeValueUpdate" $ \o -> AttributeValueUpdate
<$> o .:? "Action"
<*> o .:? "Value"
instance ToJSON AttributeValueUpdate where
toJSON AttributeValueUpdate{..} = object
[ "Value" .= _avuValue
, "Action" .= _avuAction
]
data ExpectedAttributeValue = ExpectedAttributeValue
{ _eavAttributeValueList :: List "AttributeValueList" AttributeValue
, _eavComparisonOperator :: Maybe ComparisonOperator
, _eavExists :: Maybe Bool
, _eavValue :: Maybe AttributeValue
} deriving (Eq, Show)
expectedAttributeValue :: ExpectedAttributeValue
expectedAttributeValue = ExpectedAttributeValue
{ _eavValue = Nothing
, _eavExists = Nothing
, _eavComparisonOperator = Nothing
, _eavAttributeValueList = mempty
}
eavAttributeValueList :: Lens' ExpectedAttributeValue [AttributeValue]
eavAttributeValueList =
lens _eavAttributeValueList (\s a -> s { _eavAttributeValueList = a })
. _List
eavComparisonOperator :: Lens' ExpectedAttributeValue (Maybe ComparisonOperator)
eavComparisonOperator =
lens _eavComparisonOperator (\s a -> s { _eavComparisonOperator = a })
eavExists :: Lens' ExpectedAttributeValue (Maybe Bool)
eavExists = lens _eavExists (\s a -> s { _eavExists = a })
eavValue :: Lens' ExpectedAttributeValue (Maybe AttributeValue)
eavValue = lens _eavValue (\s a -> s { _eavValue = a })
instance FromJSON ExpectedAttributeValue where
parseJSON = withObject "ExpectedAttributeValue" $ \o -> ExpectedAttributeValue
<$> o .: "AttributeValueList"
<*> o .:? "ComparisonOperator"
<*> o .:? "Exists"
<*> o .:? "Value"
instance ToJSON ExpectedAttributeValue where
toJSON ExpectedAttributeValue{..} = object
[ "Value" .= _eavValue
, "Exists" .= _eavExists
, "ComparisonOperator" .= _eavComparisonOperator
, "AttributeValueList" .= _eavAttributeValueList
]
data AttributeDefinition = AttributeDefinition
{ _adAttributeName :: Text
, _adAttributeType :: ScalarAttributeType
} deriving (Eq, Show)
attributeDefinition :: Text
-> ScalarAttributeType
-> AttributeDefinition
attributeDefinition p1 p2 = AttributeDefinition
{ _adAttributeName = p1
, _adAttributeType = p2
}
adAttributeName :: Lens' AttributeDefinition Text
adAttributeName = lens _adAttributeName (\s a -> s { _adAttributeName = a })
adAttributeType :: Lens' AttributeDefinition ScalarAttributeType
adAttributeType = lens _adAttributeType (\s a -> s { _adAttributeType = a })
instance FromJSON AttributeDefinition where
parseJSON = withObject "AttributeDefinition" $ \o -> AttributeDefinition
<$> o .: "AttributeName"
<*> o .: "AttributeType"
instance ToJSON AttributeDefinition where
toJSON AttributeDefinition{..} = object
[ "AttributeName" .= _adAttributeName
, "AttributeType" .= _adAttributeType
]
data ComparisonOperator
= BeginsWith
| Between
| Contains
| Eq
| Ge
| Gt
| In'
| Le
| Lt
| Ne
| NotContains
| NotNull
| Null
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable ComparisonOperator
instance FromText ComparisonOperator where
parser = match "BEGINS_WITH" BeginsWith
<|> match "BETWEEN" Between
<|> match "CONTAINS" Contains
<|> match "EQ" Eq
<|> match "GE" Ge
<|> match "GT" Gt
<|> match "IN" In'
<|> match "LE" Le
<|> match "LT" Lt
<|> match "NE" Ne
<|> match "NOT_CONTAINS" NotContains
<|> match "NOT_NULL" NotNull
<|> match "NULL" Null
instance ToText ComparisonOperator where
toText = \case
BeginsWith -> "BEGINS_WITH"
Between -> "BETWEEN"
Contains -> "CONTAINS"
Eq -> "EQ"
Ge -> "GE"
Gt -> "GT"
In' -> "IN"
Le -> "LE"
Lt -> "LT"
Ne -> "NE"
NotContains -> "NOT_CONTAINS"
NotNull -> "NOT_NULL"
Null -> "NULL"
instance ToByteString ComparisonOperator
instance ToHeader ComparisonOperator
instance ToQuery ComparisonOperator
instance FromJSON ComparisonOperator where
parseJSON = parseJSONText "ComparisonOperator"
instance ToJSON ComparisonOperator where
toJSON = toJSONText
data ReturnValue
= RVAllNew
| RVAllOld
| RVNone
| RVUpdatedNew
| RVUpdatedOld
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable ReturnValue
instance FromText ReturnValue where
parser = match "ALL_NEW" RVAllNew
<|> match "ALL_OLD" RVAllOld
<|> match "NONE" RVNone
<|> match "UPDATED_NEW" RVUpdatedNew
<|> match "UPDATED_OLD" RVUpdatedOld
instance ToText ReturnValue where
toText = \case
RVAllNew -> "ALL_NEW"
RVAllOld -> "ALL_OLD"
RVNone -> "NONE"
RVUpdatedNew -> "UPDATED_NEW"
RVUpdatedOld -> "UPDATED_OLD"
instance ToByteString ReturnValue
instance ToHeader ReturnValue
instance ToQuery ReturnValue
instance FromJSON ReturnValue where
parseJSON = parseJSONText "ReturnValue"
instance ToJSON ReturnValue where
toJSON = toJSONText
data LocalSecondaryIndex = LocalSecondaryIndex
{ _lsiIndexName :: Text
, _lsiKeySchema :: List1 "KeySchema" KeySchemaElement
, _lsiProjection :: Projection
} deriving (Eq, Show)
localSecondaryIndex :: Text
-> NonEmpty KeySchemaElement
-> Projection
-> LocalSecondaryIndex
localSecondaryIndex p1 p2 p3 = LocalSecondaryIndex
{ _lsiIndexName = p1
, _lsiKeySchema = withIso _List1 (const id) p2
, _lsiProjection = p3
}
lsiIndexName :: Lens' LocalSecondaryIndex Text
lsiIndexName = lens _lsiIndexName (\s a -> s { _lsiIndexName = a })
lsiKeySchema :: Lens' LocalSecondaryIndex (NonEmpty KeySchemaElement)
lsiKeySchema = lens _lsiKeySchema (\s a -> s { _lsiKeySchema = a }) . _List1
lsiProjection :: Lens' LocalSecondaryIndex Projection
lsiProjection = lens _lsiProjection (\s a -> s { _lsiProjection = a })
instance FromJSON LocalSecondaryIndex where
parseJSON = withObject "LocalSecondaryIndex" $ \o -> LocalSecondaryIndex
<$> o .: "IndexName"
<*> o .: "KeySchema"
<*> o .: "Projection"
instance ToJSON LocalSecondaryIndex where
toJSON LocalSecondaryIndex{..} = object
[ "IndexName" .= _lsiIndexName
, "KeySchema" .= _lsiKeySchema
, "Projection" .= _lsiProjection
]
data GlobalSecondaryIndexDescription = GlobalSecondaryIndexDescription
{ _gsidIndexName :: Maybe Text
, _gsidIndexSizeBytes :: Maybe Integer
, _gsidIndexStatus :: Maybe IndexStatus
, _gsidItemCount :: Maybe Integer
, _gsidKeySchema :: List1 "KeySchema" KeySchemaElement
, _gsidProjection :: Maybe Projection
, _gsidProvisionedThroughput :: Maybe ProvisionedThroughputDescription
} deriving (Eq, Show)
globalSecondaryIndexDescription :: NonEmpty KeySchemaElement
-> GlobalSecondaryIndexDescription
globalSecondaryIndexDescription p1 = GlobalSecondaryIndexDescription
{ _gsidKeySchema = withIso _List1 (const id) p1
, _gsidIndexName = Nothing
, _gsidProjection = Nothing
, _gsidIndexStatus = Nothing
, _gsidProvisionedThroughput = Nothing
, _gsidIndexSizeBytes = Nothing
, _gsidItemCount = Nothing
}
gsidIndexName :: Lens' GlobalSecondaryIndexDescription (Maybe Text)
gsidIndexName = lens _gsidIndexName (\s a -> s { _gsidIndexName = a })
gsidIndexSizeBytes :: Lens' GlobalSecondaryIndexDescription (Maybe Integer)
gsidIndexSizeBytes =
lens _gsidIndexSizeBytes (\s a -> s { _gsidIndexSizeBytes = a })
gsidIndexStatus :: Lens' GlobalSecondaryIndexDescription (Maybe IndexStatus)
gsidIndexStatus = lens _gsidIndexStatus (\s a -> s { _gsidIndexStatus = a })
gsidItemCount :: Lens' GlobalSecondaryIndexDescription (Maybe Integer)
gsidItemCount = lens _gsidItemCount (\s a -> s { _gsidItemCount = a })
gsidKeySchema :: Lens' GlobalSecondaryIndexDescription (NonEmpty KeySchemaElement)
gsidKeySchema = lens _gsidKeySchema (\s a -> s { _gsidKeySchema = a }) . _List1
gsidProjection :: Lens' GlobalSecondaryIndexDescription (Maybe Projection)
gsidProjection = lens _gsidProjection (\s a -> s { _gsidProjection = a })
gsidProvisionedThroughput :: Lens' GlobalSecondaryIndexDescription (Maybe ProvisionedThroughputDescription)
gsidProvisionedThroughput =
lens _gsidProvisionedThroughput
(\s a -> s { _gsidProvisionedThroughput = a })
instance FromJSON GlobalSecondaryIndexDescription where
parseJSON = withObject "GlobalSecondaryIndexDescription" $ \o -> GlobalSecondaryIndexDescription
<$> o .:? "IndexName"
<*> o .:? "IndexSizeBytes"
<*> o .:? "IndexStatus"
<*> o .:? "ItemCount"
<*> o .: "KeySchema"
<*> o .:? "Projection"
<*> o .:? "ProvisionedThroughput"
instance ToJSON GlobalSecondaryIndexDescription where
toJSON GlobalSecondaryIndexDescription{..} = object
[ "IndexName" .= _gsidIndexName
, "KeySchema" .= _gsidKeySchema
, "Projection" .= _gsidProjection
, "IndexStatus" .= _gsidIndexStatus
, "ProvisionedThroughput" .= _gsidProvisionedThroughput
, "IndexSizeBytes" .= _gsidIndexSizeBytes
, "ItemCount" .= _gsidItemCount
]
data ItemCollectionMetrics = ItemCollectionMetrics
{ _icmItemCollectionKey :: Map Text AttributeValue
, _icmSizeEstimateRangeGB :: List "SizeEstimateRangeGB" Double
} deriving (Eq, Show)
itemCollectionMetrics :: ItemCollectionMetrics
itemCollectionMetrics = ItemCollectionMetrics
{ _icmItemCollectionKey = mempty
, _icmSizeEstimateRangeGB = mempty
}
icmItemCollectionKey :: Lens' ItemCollectionMetrics (HashMap Text AttributeValue)
icmItemCollectionKey =
lens _icmItemCollectionKey (\s a -> s { _icmItemCollectionKey = a })
. _Map
icmSizeEstimateRangeGB :: Lens' ItemCollectionMetrics [Double]
icmSizeEstimateRangeGB =
lens _icmSizeEstimateRangeGB (\s a -> s { _icmSizeEstimateRangeGB = a })
. _List
instance FromJSON ItemCollectionMetrics where
parseJSON = withObject "ItemCollectionMetrics" $ \o -> ItemCollectionMetrics
<$> o .: "ItemCollectionKey"
<*> o .: "SizeEstimateRangeGB"
instance ToJSON ItemCollectionMetrics where
toJSON ItemCollectionMetrics{..} = object
[ "ItemCollectionKey" .= _icmItemCollectionKey
, "SizeEstimateRangeGB" .= _icmSizeEstimateRangeGB
]
newtype Capacity = Capacity
{ _cCapacityUnits :: Maybe Double
} deriving (Eq, Ord, Show)
capacity :: Capacity
capacity = Capacity
{ _cCapacityUnits = Nothing
}
cCapacityUnits :: Lens' Capacity (Maybe Double)
cCapacityUnits = lens _cCapacityUnits (\s a -> s { _cCapacityUnits = a })
instance FromJSON Capacity where
parseJSON = withObject "Capacity" $ \o -> Capacity
<$> o .:? "CapacityUnits"
instance ToJSON Capacity where
toJSON Capacity{..} = object
[ "CapacityUnits" .= _cCapacityUnits
]
data ConsumedCapacity = ConsumedCapacity
{ _ccCapacityUnits :: Maybe Double
, _ccGlobalSecondaryIndexes :: Map Text Capacity
, _ccLocalSecondaryIndexes :: Map Text Capacity
, _ccTable :: Maybe Capacity
, _ccTableName :: Maybe Text
} deriving (Eq, Show)
consumedCapacity :: ConsumedCapacity
consumedCapacity = ConsumedCapacity
{ _ccTableName = Nothing
, _ccCapacityUnits = Nothing
, _ccTable = Nothing
, _ccLocalSecondaryIndexes = mempty
, _ccGlobalSecondaryIndexes = mempty
}
ccCapacityUnits :: Lens' ConsumedCapacity (Maybe Double)
ccCapacityUnits = lens _ccCapacityUnits (\s a -> s { _ccCapacityUnits = a })
ccGlobalSecondaryIndexes :: Lens' ConsumedCapacity (HashMap Text Capacity)
ccGlobalSecondaryIndexes =
lens _ccGlobalSecondaryIndexes
(\s a -> s { _ccGlobalSecondaryIndexes = a })
. _Map
ccLocalSecondaryIndexes :: Lens' ConsumedCapacity (HashMap Text Capacity)
ccLocalSecondaryIndexes =
lens _ccLocalSecondaryIndexes (\s a -> s { _ccLocalSecondaryIndexes = a })
. _Map
ccTable :: Lens' ConsumedCapacity (Maybe Capacity)
ccTable = lens _ccTable (\s a -> s { _ccTable = a })
ccTableName :: Lens' ConsumedCapacity (Maybe Text)
ccTableName = lens _ccTableName (\s a -> s { _ccTableName = a })
instance FromJSON ConsumedCapacity where
parseJSON = withObject "ConsumedCapacity" $ \o -> ConsumedCapacity
<$> o .:? "CapacityUnits"
<*> o .: "GlobalSecondaryIndexes"
<*> o .: "LocalSecondaryIndexes"
<*> o .:? "Table"
<*> o .:? "TableName"
instance ToJSON ConsumedCapacity where
toJSON ConsumedCapacity{..} = object
[ "TableName" .= _ccTableName
, "CapacityUnits" .= _ccCapacityUnits
, "Table" .= _ccTable
, "LocalSecondaryIndexes" .= _ccLocalSecondaryIndexes
, "GlobalSecondaryIndexes" .= _ccGlobalSecondaryIndexes
]
data GlobalSecondaryIndex = GlobalSecondaryIndex
{ _gsiIndexName :: Text
, _gsiKeySchema :: List1 "KeySchema" KeySchemaElement
, _gsiProjection :: Projection
, _gsiProvisionedThroughput :: ProvisionedThroughput
} deriving (Eq, Show)
globalSecondaryIndex :: Text
-> NonEmpty KeySchemaElement
-> Projection
-> ProvisionedThroughput
-> GlobalSecondaryIndex
globalSecondaryIndex p1 p2 p3 p4 = GlobalSecondaryIndex
{ _gsiIndexName = p1
, _gsiKeySchema = withIso _List1 (const id) p2
, _gsiProjection = p3
, _gsiProvisionedThroughput = p4
}
gsiIndexName :: Lens' GlobalSecondaryIndex Text
gsiIndexName = lens _gsiIndexName (\s a -> s { _gsiIndexName = a })
gsiKeySchema :: Lens' GlobalSecondaryIndex (NonEmpty KeySchemaElement)
gsiKeySchema = lens _gsiKeySchema (\s a -> s { _gsiKeySchema = a }) . _List1
gsiProjection :: Lens' GlobalSecondaryIndex Projection
gsiProjection = lens _gsiProjection (\s a -> s { _gsiProjection = a })
gsiProvisionedThroughput :: Lens' GlobalSecondaryIndex ProvisionedThroughput
gsiProvisionedThroughput =
lens _gsiProvisionedThroughput
(\s a -> s { _gsiProvisionedThroughput = a })
instance FromJSON GlobalSecondaryIndex where
parseJSON = withObject "GlobalSecondaryIndex" $ \o -> GlobalSecondaryIndex
<$> o .: "IndexName"
<*> o .: "KeySchema"
<*> o .: "Projection"
<*> o .: "ProvisionedThroughput"
instance ToJSON GlobalSecondaryIndex where
toJSON GlobalSecondaryIndex{..} = object
[ "IndexName" .= _gsiIndexName
, "KeySchema" .= _gsiKeySchema
, "Projection" .= _gsiProjection
, "ProvisionedThroughput" .= _gsiProvisionedThroughput
]
data LocalSecondaryIndexDescription = LocalSecondaryIndexDescription
{ _lsidIndexName :: Maybe Text
, _lsidIndexSizeBytes :: Maybe Integer
, _lsidItemCount :: Maybe Integer
, _lsidKeySchema :: List1 "KeySchema" KeySchemaElement
, _lsidProjection :: Maybe Projection
} deriving (Eq, Show)
localSecondaryIndexDescription :: NonEmpty KeySchemaElement
-> LocalSecondaryIndexDescription
localSecondaryIndexDescription p1 = LocalSecondaryIndexDescription
{ _lsidKeySchema = withIso _List1 (const id) p1
, _lsidIndexName = Nothing
, _lsidProjection = Nothing
, _lsidIndexSizeBytes = Nothing
, _lsidItemCount = Nothing
}
lsidIndexName :: Lens' LocalSecondaryIndexDescription (Maybe Text)
lsidIndexName = lens _lsidIndexName (\s a -> s { _lsidIndexName = a })
lsidIndexSizeBytes :: Lens' LocalSecondaryIndexDescription (Maybe Integer)
lsidIndexSizeBytes =
lens _lsidIndexSizeBytes (\s a -> s { _lsidIndexSizeBytes = a })
lsidItemCount :: Lens' LocalSecondaryIndexDescription (Maybe Integer)
lsidItemCount = lens _lsidItemCount (\s a -> s { _lsidItemCount = a })
lsidKeySchema :: Lens' LocalSecondaryIndexDescription (NonEmpty KeySchemaElement)
lsidKeySchema = lens _lsidKeySchema (\s a -> s { _lsidKeySchema = a }) . _List1
lsidProjection :: Lens' LocalSecondaryIndexDescription (Maybe Projection)
lsidProjection = lens _lsidProjection (\s a -> s { _lsidProjection = a })
instance FromJSON LocalSecondaryIndexDescription where
parseJSON = withObject "LocalSecondaryIndexDescription" $ \o -> LocalSecondaryIndexDescription
<$> o .:? "IndexName"
<*> o .:? "IndexSizeBytes"
<*> o .:? "ItemCount"
<*> o .: "KeySchema"
<*> o .:? "Projection"
instance ToJSON LocalSecondaryIndexDescription where
toJSON LocalSecondaryIndexDescription{..} = object
[ "IndexName" .= _lsidIndexName
, "KeySchema" .= _lsidKeySchema
, "Projection" .= _lsidProjection
, "IndexSizeBytes" .= _lsidIndexSizeBytes
, "ItemCount" .= _lsidItemCount
]
data AttributeAction
= Add
| Delete'
| Put
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable AttributeAction
instance FromText AttributeAction where
parser = match "ADD" Add
<|> match "DELETE" Delete'
<|> match "PUT" Put
instance ToText AttributeAction where
toText = \case
Add -> "ADD"
Delete' -> "DELETE"
Put -> "PUT"
instance ToByteString AttributeAction
instance ToHeader AttributeAction
instance ToQuery AttributeAction
instance FromJSON AttributeAction where
parseJSON = parseJSONText "AttributeAction"
instance ToJSON AttributeAction where
toJSON = toJSONText
data ScalarAttributeType
= B
| N
| S
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable ScalarAttributeType
instance FromText ScalarAttributeType where
parser = match "B" B
<|> match "N" N
<|> match "S" S
instance ToText ScalarAttributeType where
toText = \case
B -> "B"
N -> "N"
S -> "S"
instance ToByteString ScalarAttributeType
instance ToHeader ScalarAttributeType
instance ToQuery ScalarAttributeType
instance FromJSON ScalarAttributeType where
parseJSON = parseJSONText "ScalarAttributeType"
instance ToJSON ScalarAttributeType where
toJSON = toJSONText
data Projection = Projection
{ _pNonKeyAttributes :: List1 "NonKeyAttributes" Text
, _pProjectionType :: Maybe ProjectionType
} deriving (Eq, Show)
projection :: NonEmpty Text
-> Projection
projection p1 = Projection
{ _pNonKeyAttributes = withIso _List1 (const id) p1
, _pProjectionType = Nothing
}
pNonKeyAttributes :: Lens' Projection (NonEmpty Text)
pNonKeyAttributes =
lens _pNonKeyAttributes (\s a -> s { _pNonKeyAttributes = a })
. _List1
pProjectionType :: Lens' Projection (Maybe ProjectionType)
pProjectionType = lens _pProjectionType (\s a -> s { _pProjectionType = a })
instance FromJSON Projection where
parseJSON = withObject "Projection" $ \o -> Projection
<$> o .: "NonKeyAttributes"
<*> o .:? "ProjectionType"
instance ToJSON Projection where
toJSON Projection{..} = object
[ "ProjectionType" .= _pProjectionType
, "NonKeyAttributes" .= _pNonKeyAttributes
]
data Select
= AllAttributes
| AllProjectedAttributes
| Count
| SpecificAttributes
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable Select
instance FromText Select where
parser = match "ALL_ATTRIBUTES" AllAttributes
<|> match "ALL_PROJECTED_ATTRIBUTES" AllProjectedAttributes
<|> match "COUNT" Count
<|> match "SPECIFIC_ATTRIBUTES" SpecificAttributes
instance ToText Select where
toText = \case
AllAttributes -> "ALL_ATTRIBUTES"
AllProjectedAttributes -> "ALL_PROJECTED_ATTRIBUTES"
Count -> "COUNT"
SpecificAttributes -> "SPECIFIC_ATTRIBUTES"
instance ToByteString Select
instance ToHeader Select
instance ToQuery Select
instance FromJSON Select where
parseJSON = parseJSONText "Select"
instance ToJSON Select where
toJSON = toJSONText
data KeySchemaElement = KeySchemaElement
{ _kseAttributeName :: Text
, _kseKeyType :: KeyType
} deriving (Eq, Show)
keySchemaElement :: Text
-> KeyType
-> KeySchemaElement
keySchemaElement p1 p2 = KeySchemaElement
{ _kseAttributeName = p1
, _kseKeyType = p2
}
kseAttributeName :: Lens' KeySchemaElement Text
kseAttributeName = lens _kseAttributeName (\s a -> s { _kseAttributeName = a })
kseKeyType :: Lens' KeySchemaElement KeyType
kseKeyType = lens _kseKeyType (\s a -> s { _kseKeyType = a })
instance FromJSON KeySchemaElement where
parseJSON = withObject "KeySchemaElement" $ \o -> KeySchemaElement
<$> o .: "AttributeName"
<*> o .: "KeyType"
instance ToJSON KeySchemaElement where
toJSON KeySchemaElement{..} = object
[ "AttributeName" .= _kseAttributeName
, "KeyType" .= _kseKeyType
]
newtype DeleteRequest = DeleteRequest
{ _dKey :: Map Text AttributeValue
} deriving (Eq, Show, Monoid, Semigroup)
deleteRequest :: DeleteRequest
deleteRequest = DeleteRequest
{ _dKey = mempty
}
dKey :: Lens' DeleteRequest (HashMap Text AttributeValue)
dKey = lens _dKey (\s a -> s { _dKey = a }) . _Map
instance FromJSON DeleteRequest where
parseJSON = withObject "DeleteRequest" $ \o -> DeleteRequest
<$> o .: "Key"
instance ToJSON DeleteRequest where
toJSON DeleteRequest{..} = object
[ "Key" .= _dKey
]
data UpdateGlobalSecondaryIndexAction = UpdateGlobalSecondaryIndexAction
{ _ugsiaIndexName :: Text
, _ugsiaProvisionedThroughput :: ProvisionedThroughput
} deriving (Eq, Show)
updateGlobalSecondaryIndexAction :: Text
-> ProvisionedThroughput
-> UpdateGlobalSecondaryIndexAction
updateGlobalSecondaryIndexAction p1 p2 = UpdateGlobalSecondaryIndexAction
{ _ugsiaIndexName = p1
, _ugsiaProvisionedThroughput = p2
}
ugsiaIndexName :: Lens' UpdateGlobalSecondaryIndexAction Text
ugsiaIndexName = lens _ugsiaIndexName (\s a -> s { _ugsiaIndexName = a })
ugsiaProvisionedThroughput :: Lens' UpdateGlobalSecondaryIndexAction ProvisionedThroughput
ugsiaProvisionedThroughput =
lens _ugsiaProvisionedThroughput
(\s a -> s { _ugsiaProvisionedThroughput = a })
instance FromJSON UpdateGlobalSecondaryIndexAction where
parseJSON = withObject "UpdateGlobalSecondaryIndexAction" $ \o -> UpdateGlobalSecondaryIndexAction
<$> o .: "IndexName"
<*> o .: "ProvisionedThroughput"
instance ToJSON UpdateGlobalSecondaryIndexAction where
toJSON UpdateGlobalSecondaryIndexAction{..} = object
[ "IndexName" .= _ugsiaIndexName
, "ProvisionedThroughput" .= _ugsiaProvisionedThroughput
]
newtype PutRequest = PutRequest
{ _pItem :: Map Text AttributeValue
} deriving (Eq, Show, Monoid, Semigroup)
putRequest :: PutRequest
putRequest = PutRequest
{ _pItem = mempty
}
pItem :: Lens' PutRequest (HashMap Text AttributeValue)
pItem = lens _pItem (\s a -> s { _pItem = a }) . _Map
instance FromJSON PutRequest where
parseJSON = withObject "PutRequest" $ \o -> PutRequest
<$> o .: "Item"
instance ToJSON PutRequest where
toJSON PutRequest{..} = object
[ "Item" .= _pItem
]
data Condition = Condition
{ _cAttributeValueList :: List "AttributeValueList" AttributeValue
, _cComparisonOperator :: ComparisonOperator
} deriving (Eq, Show)
condition :: ComparisonOperator
-> Condition
condition p1 = Condition
{ _cComparisonOperator = p1
, _cAttributeValueList = mempty
}
cAttributeValueList :: Lens' Condition [AttributeValue]
cAttributeValueList =
lens _cAttributeValueList (\s a -> s { _cAttributeValueList = a })
. _List
cComparisonOperator :: Lens' Condition ComparisonOperator
cComparisonOperator =
lens _cComparisonOperator (\s a -> s { _cComparisonOperator = a })
instance FromJSON Condition where
parseJSON = withObject "Condition" $ \o -> Condition
<$> o .: "AttributeValueList"
<*> o .: "ComparisonOperator"
instance ToJSON Condition where
toJSON Condition{..} = object
[ "AttributeValueList" .= _cAttributeValueList
, "ComparisonOperator" .= _cComparisonOperator
]
data ConditionalOperator
= And
| Or
deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable ConditionalOperator
instance FromText ConditionalOperator where
parser = match "AND" And
<|> match "OR" Or
instance ToText ConditionalOperator where
toText = \case
And -> "AND"
Or -> "OR"
instance ToByteString ConditionalOperator
instance ToHeader ConditionalOperator
instance ToQuery ConditionalOperator
instance FromJSON ConditionalOperator where
parseJSON = parseJSONText "ConditionalOperator"
instance ToJSON ConditionalOperator where
toJSON = toJSONText
newtype GlobalSecondaryIndexUpdate = GlobalSecondaryIndexUpdate
{ _gsiuUpdate :: Maybe UpdateGlobalSecondaryIndexAction
} deriving (Eq, Show)
globalSecondaryIndexUpdate :: GlobalSecondaryIndexUpdate
globalSecondaryIndexUpdate = GlobalSecondaryIndexUpdate
{ _gsiuUpdate = Nothing
}
gsiuUpdate :: Lens' GlobalSecondaryIndexUpdate (Maybe UpdateGlobalSecondaryIndexAction)
gsiuUpdate = lens _gsiuUpdate (\s a -> s { _gsiuUpdate = a })
instance FromJSON GlobalSecondaryIndexUpdate where
parseJSON = withObject "GlobalSecondaryIndexUpdate" $ \o -> GlobalSecondaryIndexUpdate
<$> o .:? "Update"
instance ToJSON GlobalSecondaryIndexUpdate where
toJSON GlobalSecondaryIndexUpdate{..} = object
[ "Update" .= _gsiuUpdate
]