| Copyright | Soostone Inc Chris Allen |
|---|---|
| License | BSD3 |
| Maintainer | Ozgun Ataman <ozgun.ataman@soostone.com> |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Aws.DynamoDb.Core
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
- 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 {
- unDynNumber :: Scientific
- 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 {}
- getAttr :: (Typeable a, DynVal a) => Text -> Item -> Parser a
- getAttr' :: 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 Value 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 Source #
ddbUsWest1 :: Region Source #
ddbUsWest2 :: Region Source #
ddbEuWest1 :: Region Source #
ddbEuWest2 :: Region Source #
ddbSaEast1 :: Region Source #
data DdbConfiguration qt Source #
Constructors
| DdbConfiguration | |
Fields
| |
Instances
| DefaultServiceConfiguration (DdbConfiguration NormalQuery) Source # | |
Defined in Aws.DynamoDb.Core | |
| Default (DdbConfiguration NormalQuery) Source # | |
Defined in Aws.DynamoDb.Core Methods | |
| Show (DdbConfiguration qt) Source # | |
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
| FromJSON DValue Source # | |
| ToJSON DValue Source # | |
| DynData DValue Source # | |
| DynSize DValue Source # | |
| DynSize Item Source # | |
| DynVal DValue Source # | |
| FromDynItem Item Source # | |
| ToDynItem Item Source # | |
| IsString DValue Source # | |
Defined in Aws.DynamoDb.Core Methods fromString :: String -> DValue Source # | |
| Read DValue Source # | |
| Show DValue Source # | |
| Eq DValue Source # | |
| Ord DValue Source # | |
| ListResponse QueryResponse Item Source # | |
Defined in Aws.DynamoDb.Commands.Query Methods listResponse :: QueryResponse -> [Item] Source # | |
| ListResponse ScanResponse Item Source # | |
Defined in Aws.DynamoDb.Commands.Scan Methods listResponse :: ScanResponse -> [Item] Source # | |
| type DynRep DValue Source # | |
Defined in Aws.DynamoDb.Core | |
Converting to/from DValue
class DynData (DynRep a) => DynVal a where Source #
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.
Associated Types
Which of the DynData instances does this data type directly
map to?
Methods
toRep :: a -> DynRep a Source #
Convert to representation
fromRep :: DynRep a -> Maybe a Source #
Convert from representation
Instances
| DynVal DValue Source # | |||||
| DynVal OldBool Source # | |||||
| DynVal ByteString Source # | |||||
Defined in Aws.DynamoDb.Core Associated Types
Methods toRep :: ByteString -> DynRep ByteString Source # fromRep :: DynRep ByteString -> Maybe ByteString Source # | |||||
| DynVal Int16 Source # | |||||
| DynVal Int32 Source # | |||||
| DynVal Int64 Source # | |||||
| DynVal Int8 Source # | |||||
| DynVal Word16 Source # | |||||
| DynVal Word32 Source # | |||||
| DynVal Word64 Source # | |||||
| DynVal Word8 Source # | |||||
| DynVal Text Source # | |||||
| DynVal Day Source # | Encoded as number of days | ||||
| DynVal UTCTime Source # | Losslessly encoded via | ||||
| DynVal Integer Source # | |||||
| DynVal Bool Source # | |||||
| DynVal Double Source # | |||||
| DynVal Int Source # | |||||
| Serialize a => DynVal (Bin a) Source # | |||||
| (DynData (DynRep (Set a)), DynVal a, Ord a) => DynVal (Set a) Source # | Any singular | ||||
| (DynData (DynRep [a]), DynVal a) => DynVal [a] Source # | Any singular | ||||
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.
Instances
| Serialize a => DynVal (Bin a) Source # | |
| Enum a => Enum (Bin a) Source # | |
Defined in Aws.DynamoDb.Core Methods succ :: Bin a -> Bin a Source # pred :: Bin a -> Bin a Source # toEnum :: Int -> Bin a Source # fromEnum :: Bin a -> Int Source # enumFrom :: Bin a -> [Bin a] Source # enumFromThen :: Bin a -> Bin a -> [Bin a] Source # enumFromTo :: Bin a -> Bin a -> [Bin a] Source # enumFromThenTo :: Bin a -> Bin a -> Bin a -> [Bin a] Source # | |
| Read a => Read (Bin a) Source # | |
| Show a => Show (Bin a) Source # | |
| Eq a => Eq (Bin a) Source # | |
| Ord a => Ord (Bin a) Source # | |
Defined in Aws.DynamoDb.Core | |
| type DynRep (Bin a) Source # | |
Defined in Aws.DynamoDb.Core | |
Defining new DynVal instances
class Ord a => DynData a where Source #
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
| DynData DynBinary Source # | |
| Read DynBinary Source # | |
| Show DynBinary Source # | |
| Eq DynBinary Source # | |
| Ord DynBinary Source # | |
Defined in Aws.DynamoDb.Core | |
| DynData (Set DynBinary) Source # | |
Numeric values stored in DynamoDb. Only used in defining new
DynVal instances.
Constructors
| DynNumber | |
Fields
| |
Instances
| DynData DynNumber Source # | |
| Read DynNumber Source # | |
| Show DynNumber Source # | |
| Eq DynNumber Source # | |
| Ord DynNumber Source # | |
Defined in Aws.DynamoDb.Core | |
| DynData (Set DynNumber) Source # | |
String values stored in DynamoDb. Only used in defining new
DynVal instances.
Constructors
| DynString | |
Fields
| |
Instances
| DynData DynString Source # | |
| Read DynString Source # | |
| Show DynString Source # | |
| Eq DynString Source # | |
| Ord DynString Source # | |
Defined in Aws.DynamoDb.Core | |
| DynData (Set DynString) Source # | |
Boolean values stored in DynamoDb. Only used in defining new
DynVal instances.
Instances
| DynData DynBool Source # | |
| Read DynBool Source # | |
| Show DynBool Source # | |
| Eq DynBool Source # | |
| Ord DynBool Source # | |
Defined in Aws.DynamoDb.Core | |
| DynData (Set DynBool) Source # | |
Working with key/value pairs
A key-value pair
Instances
| ToJSON Attribute Source # | |
| DynSize Attribute Source # | |
| Read Attribute Source # | |
| Show Attribute Source # | |
| Eq Attribute Source # | |
| Ord Attribute Source # | |
Defined in Aws.DynamoDb.Core | |
parseAttributeJson :: Value -> Parser [Attribute] Source #
Parse a JSON object that contains attributes
attributeJson :: Attribute -> Pair Source #
Convert into JSON pair
attributesJson :: [Attribute] -> Value Source #
Convert into JSON object for AWS.
attr :: DynVal a => Text -> a -> Attribute Source #
Convenience function for constructing key-value pairs
attrAs :: DynVal a => Proxy a -> Text -> a -> Attribute Source #
attr with type witness to help with cases where you're manually
supplying values in code.
> item [ attrAs text "name" "john" ]
data PrimaryKey Source #
Primary keys consist of either just a Hash key (mandatory) or a hash key and a range key (optional).
Instances
hk :: Text -> DValue -> PrimaryKey Source #
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)
class ToDynItem a where Source #
Types convertible to DynamoDb Item collections.
Use attr and attrAs combinators to conveniently define instances.
class FromDynItem a where Source #
Types parseable from DynamoDb Item collections.
User getAttr family of functions to applicatively or monadically
parse into your custom types.
fromItem :: FromDynItem a => Item -> Either String a Source #
Parse an Item into target type using the FromDynItem
instance.
A continuation-based parser type.
Constructors
| Parser | |
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 Source #
Conditions used by mutation operations (PutItem, UpdateItem,
etc.). The default def instance is empty (no condition).
Constructors
| Conditions CondMerge [Condition] |
Instances
| Default Conditions Source # | |
Defined in Aws.DynamoDb.Core Methods def :: Conditions # | |
| Read Conditions Source # | |
Defined in Aws.DynamoDb.Core | |
| Show Conditions Source # | |
Defined in Aws.DynamoDb.Core | |
| Eq Conditions Source # | |
Defined in Aws.DynamoDb.Core Methods (==) :: Conditions -> Conditions -> Bool Source # (/=) :: Conditions -> Conditions -> Bool Source # | |
| Ord Conditions Source # | |
Defined in Aws.DynamoDb.Core Methods compare :: Conditions -> Conditions -> Ordering Source # (<) :: Conditions -> Conditions -> Bool Source # (<=) :: Conditions -> Conditions -> Bool Source # (>) :: Conditions -> Conditions -> Bool Source # (>=) :: Conditions -> Conditions -> Bool Source # max :: Conditions -> Conditions -> Conditions Source # min :: Conditions -> Conditions -> Conditions Source # | |
conditionsJson :: Text -> Conditions -> [Pair] Source #
JSON encoding of conditions parameter in various contexts.
expectsJson :: Conditions -> [Pair] Source #
A condition used by mutation operations (PutItem, UpdateItem, etc.).
Constructors
| Condition | |
Instances
| Read Condition Source # | |
| Show Condition Source # | |
| Eq Condition Source # | |
| Ord Condition Source # | |
Defined in Aws.DynamoDb.Core | |
conditionJson :: Condition -> Pair Source #
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 |
Instances
| ToJSON CondOp Source # | |
| Read CondOp Source # | |
| Show CondOp Source # | |
| Eq CondOp Source # | |
| Ord CondOp Source # | |
How to merge multiple conditions.
Instances
| Read CondMerge Source # | |
| Show CondMerge Source # | |
| Eq CondMerge Source # | |
| Ord CondMerge Source # | |
Defined in Aws.DynamoDb.Core | |
data ConsumedCapacity Source #
The standard response metrics on capacity consumption.
Constructors
| ConsumedCapacity | |
Fields
| |
Instances
data ReturnConsumption Source #
Instances
data ItemCollectionMetrics Source #
Constructors
| ItemCollectionMetrics | |
Fields
| |
Instances
data ReturnItemCollectionMetrics Source #
Instances
data UpdateReturn Source #
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 Source #
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
| Default QuerySelect Source # | |
Defined in Aws.DynamoDb.Core Methods def :: QuerySelect # | |
| Read QuerySelect Source # | |
Defined in Aws.DynamoDb.Core | |
| Show QuerySelect Source # | |
Defined in Aws.DynamoDb.Core | |
| Eq QuerySelect Source # | |
Defined in Aws.DynamoDb.Core Methods (==) :: QuerySelect -> QuerySelect -> Bool Source # (/=) :: QuerySelect -> QuerySelect -> Bool Source # | |
| Ord QuerySelect Source # | |
Defined in Aws.DynamoDb.Core Methods compare :: QuerySelect -> QuerySelect -> Ordering Source # (<) :: QuerySelect -> QuerySelect -> Bool Source # (<=) :: QuerySelect -> QuerySelect -> Bool Source # (>) :: QuerySelect -> QuerySelect -> Bool Source # (>=) :: QuerySelect -> QuerySelect -> Bool Source # max :: QuerySelect -> QuerySelect -> QuerySelect Source # min :: QuerySelect -> QuerySelect -> QuerySelect Source # | |
querySelectJson :: KeyValue Value t => QuerySelect -> [t] Source #
Size estimation
class DynSize a where Source #
A class to help predict DynamoDb size of values, attributes and entire items. The result is given in number of bytes.
Instances
| DynSize AttributeUpdate Source # | |
Defined in Aws.DynamoDb.Commands.UpdateItem Methods dynSize :: AttributeUpdate -> Int Source # | |
| DynSize Attribute Source # | |
| DynSize DValue Source # | |
| DynSize Item Source # | |
| DynSize a => DynSize (Maybe a) Source # | |
| DynSize a => DynSize [a] Source # | |
Defined in Aws.DynamoDb.Core | |
| (DynSize a, DynSize b) => DynSize (Either a b) Source # | |
nullAttr :: Attribute -> Bool Source #
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 Source #
Response metadata that is present in every DynamoDB response.
Instances
| Loggable DdbResponse Source # | |
Defined in Aws.DynamoDb.Core Methods toLogText :: DdbResponse -> Text Source # | |
| Monoid DdbResponse Source # | |
Defined in Aws.DynamoDb.Core Methods mempty :: DdbResponse Source # mappend :: DdbResponse -> DdbResponse -> DdbResponse Source # mconcat :: [DdbResponse] -> DdbResponse Source # | |
| Semigroup DdbResponse Source # | |
Defined in Aws.DynamoDb.Core Methods (<>) :: DdbResponse -> DdbResponse -> DdbResponse Source # sconcat :: NonEmpty DdbResponse -> DdbResponse Source # stimes :: Integral b => b -> DdbResponse -> DdbResponse Source # | |
data DdbErrCode Source #
Errors defined by AWS.
Constructors
Instances
| Read DdbErrCode Source # | |
Defined in Aws.DynamoDb.Core | |
| Show DdbErrCode Source # | |
Defined in Aws.DynamoDb.Core | |
| Eq DdbErrCode Source # | |
Defined in Aws.DynamoDb.Core Methods (==) :: DdbErrCode -> DdbErrCode -> Bool Source # (/=) :: DdbErrCode -> DdbErrCode -> Bool Source # | |
shouldRetry :: DdbErrCode -> Bool Source #
Whether the action should be retried based on the received error.
Potential errors raised by DynamoDB
Constructors
| DdbError | |
Fields
| |
Instances
| Exception DdbError Source # | |
Defined in Aws.DynamoDb.Core Methods toException :: DdbError -> SomeException Source # fromException :: SomeException -> Maybe DdbError Source # displayException :: DdbError -> String Source # backtraceDesired :: DdbError -> Bool Source # | |
| Show DdbError Source # | |
| Eq DdbError Source # | |
Internal Helpers
ddbSignQuery :: ToJSON a => ByteString -> a -> DdbConfiguration qt -> SignatureData -> SignedQuery Source #
data AmazonError Source #
Instances
| FromJSON AmazonError Source # | |
Defined in Aws.DynamoDb.Core Methods parseJSON :: Value -> Parser AmazonError Source # parseJSONList :: Value -> Parser [AmazonError] Source # | |
ddbResponseConsumer :: FromJSON a => IORef DdbResponse -> HTTPResponseConsumer a Source #