| Copyright | Soostone Inc Chris Allen |
|---|---|
| License | BSD3 |
| Maintainer | Ozgun Ataman <ozgun.ataman@soostone.com> |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Aws.DynamoDb.Core
Contents
Description
Shared types and utilities for DyanmoDb functionality.
Synopsis
- data Region = Region {
- rUri :: ByteString
- rName :: ByteString
- ddbLocal :: Region
- ddbUsEast1 :: Region
- ddbUsWest1 :: Region
- ddbUsWest2 :: Region
- ddbEuWest1 :: Region
- ddbEuWest2 :: Region
- ddbEuCentral1 :: Region
- ddbApNe1 :: Region
- ddbApSe1 :: Region
- ddbApSe2 :: Region
- ddbSaEast1 :: Region
- data DdbConfiguration qt = DdbConfiguration {
- ddbcRegion :: Region
- ddbcProtocol :: Protocol
- ddbcPort :: Maybe Int
- data DValue
- class DynData (DynRep a) => DynVal a where
- type DynRep a
- toValue :: DynVal a => a -> DValue
- fromValue :: DynVal a => DValue -> Maybe a
- newtype Bin a = Bin {
- getBin :: a
- newtype OldBool = OldBool Bool
- class Ord a => DynData a where
- newtype DynBinary = DynBinary {}
- newtype DynNumber = DynNumber {}
- newtype DynString = DynString {
- unDynString :: Text
- newtype DynBool = DynBool {}
- data Attribute = Attribute {}
- parseAttributeJson :: Value -> Parser [Attribute]
- attributeJson :: Attribute -> Pair
- attributesJson :: [Attribute] -> Value
- attrTuple :: Attribute -> (Text, DValue)
- attr :: DynVal a => Text -> a -> Attribute
- attrAs :: DynVal a => Proxy a -> Text -> a -> Attribute
- text :: Proxy Text
- int :: Proxy Integer
- double :: Proxy Double
- data PrimaryKey = PrimaryKey {}
- hk :: Text -> DValue -> PrimaryKey
- hrk :: Text -> DValue -> Text -> DValue -> PrimaryKey
- type Item = Map Text DValue
- item :: [Attribute] -> Item
- attributes :: Map Text DValue -> [Attribute]
- class ToDynItem a where
- class FromDynItem a where
- fromItem :: FromDynItem a => Item -> Either String a
- newtype Parser a = Parser {
- runParser :: forall f r. Failure f r -> Success a f r -> f r
- getAttr :: forall a. (Typeable a, DynVal a) => Text -> Item -> Parser a
- getAttr' :: forall a. DynVal a => Text -> Item -> Parser (Maybe a)
- parseAttr :: FromDynItem a => Text -> Item -> Parser a
- data Conditions = Conditions CondMerge [Condition]
- conditionsJson :: Text -> Conditions -> [Pair]
- expectsJson :: Conditions -> [Pair]
- data Condition = Condition {}
- conditionJson :: Condition -> Pair
- data CondOp
- data CondMerge
- data ConsumedCapacity = ConsumedCapacity {
- capacityUnits :: Int64
- capacityGlobalIndex :: [(Text, Int64)]
- capacityLocalIndex :: [(Text, Int64)]
- capacityTableUnits :: Maybe Int64
- capacityTable :: Text
- data ReturnConsumption
- data ItemCollectionMetrics = ItemCollectionMetrics {
- icmKey :: (Text, DValue)
- icmEstimate :: [Double]
- data ReturnItemCollectionMetrics
- data UpdateReturn
- data QuerySelect
- querySelectJson :: KeyValue t => QuerySelect -> [t]
- class DynSize a where
- nullAttr :: Attribute -> Bool
- data DdbResponse = DdbResponse {}
- data DdbErrCode
- = AccessDeniedException
- | ConditionalCheckFailedException
- | IncompleteSignatureException
- | InvalidSignatureException
- | LimitExceededException
- | MissingAuthenticationTokenException
- | ProvisionedThroughputExceededException
- | ResourceInUseException
- | ResourceNotFoundException
- | ThrottlingException
- | ValidationException
- | RequestTooLarge
- | InternalFailure
- | InternalServerError
- | ServiceUnavailableException
- | SerializationException
- shouldRetry :: DdbErrCode -> Bool
- data DdbError = DdbError {}
- ddbSignQuery :: ToJSON a => ByteString -> a -> DdbConfiguration qt -> SignatureData -> SignedQuery
- data AmazonError = AmazonError {}
- ddbResponseConsumer :: FromJSON a => IORef DdbResponse -> HTTPResponseConsumer a
- ddbHttp :: Region -> DdbConfiguration NormalQuery
- ddbHttps :: Region -> DdbConfiguration NormalQuery
Configuration and Regions
Constructors
| Region | |
Fields
| |
ddbUsEast1 :: Region #
ddbUsWest1 :: Region #
ddbUsWest2 :: Region #
ddbEuWest1 :: Region #
ddbEuWest2 :: Region #
ddbEuCentral1 :: Region #
ddbSaEast1 :: Region #
data DdbConfiguration qt #
Constructors
| DdbConfiguration | |
Fields
| |
Instances
| Show (DdbConfiguration qt) # | |
Defined in Aws.DynamoDb.Core Methods showsPrec :: Int -> DdbConfiguration qt -> ShowS # show :: DdbConfiguration qt -> String # showList :: [DdbConfiguration qt] -> ShowS # | |
| Default (DdbConfiguration NormalQuery) # | |
Defined in Aws.DynamoDb.Core Methods | |
| DefaultServiceConfiguration (DdbConfiguration NormalQuery) # | |
Defined in Aws.DynamoDb.Core | |
DynamoDB values
Value types natively recognized by DynamoDb. We pretty much exactly reflect the AWS API onto Haskell types.
Constructors
| DNull | |
| DNum Scientific | |
| DString Text | |
| DBinary ByteString | Binary data will automatically be base64 marshalled. |
| DNumSet (Set Scientific) | |
| DStringSet (Set Text) | |
| DBinSet (Set ByteString) | Binary data will automatically be base64 marshalled. |
| DBool Bool | |
| DBoolSet (Set Bool) | Composite data |
| DList (Vector DValue) | |
| DMap (Map Text DValue) |
Instances
| Eq DValue # | |
| Ord DValue # | |
| Read DValue # | |
| Show DValue # | |
| IsString DValue # | |
Defined in Aws.DynamoDb.Core Methods fromString :: String -> DValue # | |
| ToJSON DValue # | |
Defined in Aws.DynamoDb.Core | |
| FromJSON DValue # | |
| FromDynItem Item # | |
| ToDynItem Item # | |
Defined in Aws.DynamoDb.Core | |
| DynSize Item # | |
Defined in Aws.DynamoDb.Core | |
| DynSize DValue # | |
Defined in Aws.DynamoDb.Core | |
| DynVal DValue # | |
| DynData DValue # | |
| ListResponse ScanResponse Item # | |
Defined in Aws.DynamoDb.Commands.Scan Methods listResponse :: ScanResponse -> [Item] # | |
| ListResponse QueryResponse Item # | |
Defined in Aws.DynamoDb.Commands.Query Methods listResponse :: QueryResponse -> [Item] # | |
| type DynRep DValue # | |
Defined in Aws.DynamoDb.Core | |
Converting to/from DValue
class DynData (DynRep a) => DynVal a where #
Class of Haskell types that can be represented as DynamoDb values.
This is the conversion layer; instantiate this class for your own
types and then use the toValue and fromValue combinators to
convert in application code.
Each Haskell type instantiated with this class will map to a DynamoDb-supported type that most naturally represents it.
Instances
| DynVal Bool # | |
| DynVal Double # | |
| DynVal Int # | |
| DynVal Int8 # | |
| DynVal Int16 # | |
| DynVal Int32 # | |
| DynVal Int64 # | |
| DynVal Integer # | |
| DynVal Word8 # | |
| DynVal Word16 # | |
| DynVal Word32 # | |
| DynVal Word64 # | |
| DynVal ByteString # | |
Defined in Aws.DynamoDb.Core Associated Types type DynRep ByteString :: * # | |
| DynVal Text # | |
| DynVal UTCTime # | Losslessly encoded via |
| DynVal Day # | Encoded as number of days |
| DynVal DValue # | |
| DynVal OldBool # | |
| (DynData (DynRep [a]), DynVal a) => DynVal [a] # | Any singular |
| (DynData (DynRep (Set a)), DynVal a, Ord a) => DynVal (Set a) # | Any singular |
| Serialize a => DynVal (Bin a) # | |
Type wrapper for binary data to be written to DynamoDB. Wrap any
Serialize instance in there and DynVal will know how to
automatically handle conversions in binary form.
Defining new DynVal instances
class Ord a => DynData a where #
An internally used closed typeclass for values that have direct DynamoDb representations. Based on AWS API, this is basically numbers, strings and binary blobs.
This is here so that any DynVal haskell value can automatically
be lifted to a list or a Set without any instance code
duplication.
Do not try to create your own instances.
Binary values stored in DynamoDb. Only used in defining new
DynVal instances.
Constructors
| DynBinary | |
Fields | |
Instances
| Eq DynBinary # | |
| Ord DynBinary # | |
| Read DynBinary # | |
| Show DynBinary # | |
| DynData DynBinary # | |
| DynData (Set DynBinary) # | |
Numeric values stored in DynamoDb. Only used in defining new
DynVal instances.
Constructors
| DynNumber | |
Fields | |
Instances
| Eq DynNumber # | |
| Ord DynNumber # | |
| Read DynNumber # | |
| Show DynNumber # | |
| DynData DynNumber # | |
| DynData (Set DynNumber) # | |
String values stored in DynamoDb. Only used in defining new
DynVal instances.
Constructors
| DynString | |
Fields
| |
Instances
| Eq DynString # | |
| Ord DynString # | |
| Read DynString # | |
| Show DynString # | |
| DynData DynString # | |
| DynData (Set DynString) # | |
Boolean values stored in DynamoDb. Only used in defining new
DynVal instances.
Working with key/value pairs
A key-value pair
Instances
| Eq Attribute # | |
| Ord Attribute # | |
| Read Attribute # | |
| Show Attribute # | |
| ToJSON Attribute # | |
Defined in Aws.DynamoDb.Core | |
| DynSize Attribute # | |
Defined in Aws.DynamoDb.Core | |
parseAttributeJson :: Value -> Parser [Attribute] #
Parse a JSON object that contains attributes
attributeJson :: Attribute -> Pair #
Convert into JSON pair
attributesJson :: [Attribute] -> Value #
Convert into JSON object for AWS.
attrAs :: DynVal a => Proxy a -> Text -> a -> Attribute #
attr with type witness to help with cases where you're manually
supplying values in code.
> item [ attrAs text "name" "john" ]
data PrimaryKey #
Primary keys consist of either just a Hash key (mandatory) or a hash key and a range key (optional).
Instances
hk :: Text -> DValue -> PrimaryKey #
Construct a hash-only primary key.
>>>hk "user-id" "ABCD"
>>>hk "user-id" (mkVal 23)
Arguments
| :: Text | Hash key name |
| -> DValue | Hash key value |
| -> Text | Range key name |
| -> DValue | Range key value |
| -> PrimaryKey |
Construct a hash-and-range primary key.
Working with objects (attribute collections)
Types convertible to DynamoDb Item collections.
Use attr and attrAs combinators to conveniently define instances.
Minimal complete definition
class FromDynItem a where #
Types parseable from DynamoDb Item collections.
User getAttr family of functions to applicatively or monadically
parse into your custom types.
Minimal complete definition
Instances
| FromDynItem Item # | |
| (Typeable a, DynVal a) => FromDynItem [(Text, a)] # | |
| (Typeable a, DynVal a) => FromDynItem (Map Text a) # | |
fromItem :: FromDynItem a => Item -> Either String a #
Parse an Item into target type using the FromDynItem
instance.
A continuation-based parser type.
Convenience combinator for parsing fields from an Item returned
by DynamoDb.
Parse attribute if it's present in the Item. Fail if attribute
is present but conversion fails.
Arguments
| :: FromDynItem a | |
| => Text | Attribute name |
| -> Item | Item from DynamoDb |
| -> Parser a |
Combinator for parsing an attribute into a FromDynItem.
Common types used by operations
data Conditions #
Conditions used by mutation operations (PutItem, UpdateItem,
etc.). The default def instance is empty (no condition).
Constructors
| Conditions CondMerge [Condition] |
Instances
| Eq Conditions # | |
Defined in Aws.DynamoDb.Core | |
| Ord Conditions # | |
Defined in Aws.DynamoDb.Core Methods compare :: Conditions -> Conditions -> Ordering # (<) :: Conditions -> Conditions -> Bool # (<=) :: Conditions -> Conditions -> Bool # (>) :: Conditions -> Conditions -> Bool # (>=) :: Conditions -> Conditions -> Bool # max :: Conditions -> Conditions -> Conditions # min :: Conditions -> Conditions -> Conditions # | |
| Read Conditions # | |
Defined in Aws.DynamoDb.Core Methods readsPrec :: Int -> ReadS Conditions # readList :: ReadS [Conditions] # readPrec :: ReadPrec Conditions # readListPrec :: ReadPrec [Conditions] # | |
| Show Conditions # | |
Defined in Aws.DynamoDb.Core Methods showsPrec :: Int -> Conditions -> ShowS # show :: Conditions -> String # showList :: [Conditions] -> ShowS # | |
| Default Conditions # | |
Defined in Aws.DynamoDb.Core Methods def :: Conditions # | |
conditionsJson :: Text -> Conditions -> [Pair] #
JSON encoding of conditions parameter in various contexts.
expectsJson :: Conditions -> [Pair] #
A condition used by mutation operations (PutItem, UpdateItem, etc.).
Constructors
| Condition | |
Instances
| Eq Condition # | |
| Ord Condition # | |
| Read Condition # | |
| Show Condition # | |
conditionJson :: Condition -> Pair #
Conditional operation to perform on a field.
Constructors
| DEq DValue | |
| NotEq DValue | |
| DLE DValue | |
| DLT DValue | |
| DGE DValue | |
| DGT DValue | |
| NotNull | |
| IsNull | |
| Contains DValue | |
| NotContains DValue | |
| Begins DValue | |
| In [DValue] | |
| Between DValue DValue |
How to merge multiple conditions.
Instances
| Eq CondMerge # | |
| Ord CondMerge # | |
| Read CondMerge # | |
| Show CondMerge # | |
data ConsumedCapacity #
The standard response metrics on capacity consumption.
Constructors
| ConsumedCapacity | |
Fields
| |
Instances
data ReturnConsumption #
Instances
data ItemCollectionMetrics #
Constructors
| ItemCollectionMetrics | |
Fields
| |
Instances
data ReturnItemCollectionMetrics #
Instances
data UpdateReturn #
What to return from the current update operation
Constructors
| URNone | Return nothing |
| URAllOld | Return old values |
| URUpdatedOld | Return old values with a newer replacement |
| URAllNew | Return new values |
| URUpdatedNew | Return new values that were replacements |
Instances
data QuerySelect #
What to return from a Query or Scan query.
Constructors
| SelectSpecific [Text] | Only return selected attributes |
| SelectCount | Return counts instead of attributes |
| SelectProjected | Return index-projected attributes |
| SelectAll | Default. Return everything. |
Instances
| Eq QuerySelect # | |
Defined in Aws.DynamoDb.Core | |
| Ord QuerySelect # | |
Defined in Aws.DynamoDb.Core Methods compare :: QuerySelect -> QuerySelect -> Ordering # (<) :: QuerySelect -> QuerySelect -> Bool # (<=) :: QuerySelect -> QuerySelect -> Bool # (>) :: QuerySelect -> QuerySelect -> Bool # (>=) :: QuerySelect -> QuerySelect -> Bool # max :: QuerySelect -> QuerySelect -> QuerySelect # min :: QuerySelect -> QuerySelect -> QuerySelect # | |
| Read QuerySelect # | |
Defined in Aws.DynamoDb.Core Methods readsPrec :: Int -> ReadS QuerySelect # readList :: ReadS [QuerySelect] # readPrec :: ReadPrec QuerySelect # readListPrec :: ReadPrec [QuerySelect] # | |
| Show QuerySelect # | |
Defined in Aws.DynamoDb.Core Methods showsPrec :: Int -> QuerySelect -> ShowS # show :: QuerySelect -> String # showList :: [QuerySelect] -> ShowS # | |
| Default QuerySelect # | |
Defined in Aws.DynamoDb.Core Methods def :: QuerySelect # | |
querySelectJson :: KeyValue t => QuerySelect -> [t] #
Size estimation
A class to help predict DynamoDb size of values, attributes and entire items. The result is given in number of bytes.
Minimal complete definition
Instances
| DynSize Item # | |
Defined in Aws.DynamoDb.Core | |
| DynSize Attribute # | |
Defined in Aws.DynamoDb.Core | |
| DynSize DValue # | |
Defined in Aws.DynamoDb.Core | |
| DynSize AttributeUpdate # | |
Defined in Aws.DynamoDb.Commands.UpdateItem Methods dynSize :: AttributeUpdate -> Int # | |
| DynSize a => DynSize [a] # | |
Defined in Aws.DynamoDb.Core | |
| DynSize a => DynSize (Maybe a) # | |
Defined in Aws.DynamoDb.Core | |
| (DynSize a, DynSize b) => DynSize (Either a b) # | |
Defined in Aws.DynamoDb.Core | |
nullAttr :: Attribute -> Bool #
Will an attribute be considered empty by DynamoDb?
A PutItem (or similar) with empty attributes will be rejected
with a ValidationException.
Responses & Errors
data DdbResponse #
Response metadata that is present in every DynamoDB response.
Instances
| Semigroup DdbResponse # | |
Defined in Aws.DynamoDb.Core Methods (<>) :: DdbResponse -> DdbResponse -> DdbResponse # sconcat :: NonEmpty DdbResponse -> DdbResponse # stimes :: Integral b => b -> DdbResponse -> DdbResponse # | |
| Monoid DdbResponse # | |
Defined in Aws.DynamoDb.Core Methods mempty :: DdbResponse # mappend :: DdbResponse -> DdbResponse -> DdbResponse # mconcat :: [DdbResponse] -> DdbResponse # | |
| Loggable DdbResponse # | |
Defined in Aws.DynamoDb.Core Methods toLogText :: DdbResponse -> Text # | |
data DdbErrCode #
Errors defined by AWS.
Constructors
Instances
| Eq DdbErrCode # | |
Defined in Aws.DynamoDb.Core | |
| Read DdbErrCode # | |
Defined in Aws.DynamoDb.Core Methods readsPrec :: Int -> ReadS DdbErrCode # readList :: ReadS [DdbErrCode] # readPrec :: ReadPrec DdbErrCode # readListPrec :: ReadPrec [DdbErrCode] # | |
| Show DdbErrCode # | |
Defined in Aws.DynamoDb.Core Methods showsPrec :: Int -> DdbErrCode -> ShowS # show :: DdbErrCode -> String # showList :: [DdbErrCode] -> ShowS # | |
shouldRetry :: DdbErrCode -> Bool #
Whether the action should be retried based on the received error.
Potential errors raised by DynamoDB
Constructors
| DdbError | |
Fields
| |
Instances
| Eq DdbError # | |
| Show DdbError # | |
| Exception DdbError # | |
Defined in Aws.DynamoDb.Core Methods toException :: DdbError -> SomeException # fromException :: SomeException -> Maybe DdbError # displayException :: DdbError -> String # | |
Internal Helpers
ddbSignQuery :: ToJSON a => ByteString -> a -> DdbConfiguration qt -> SignatureData -> SignedQuery #
data AmazonError #
Instances
| FromJSON AmazonError # | |
Defined in Aws.DynamoDb.Core | |
ddbResponseConsumer :: FromJSON a => IORef DdbResponse -> HTTPResponseConsumer a #