aws-0.20: Amazon Web Services (AWS) for Haskell

CopyrightSoostone Inc Chris Allen
LicenseBSD3
MaintainerOzgun Ataman <ozgun.ataman@soostone.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Aws.DynamoDb.Core

Contents

Description

Shared types and utilities for DyanmoDb functionality.

Synopsis

Configuration and Regions

data Region #

Constructors

Region 
Instances
Eq Region # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

(==) :: Region -> Region -> Bool #

(/=) :: Region -> Region -> Bool #

Read Region # 
Instance details

Defined in Aws.DynamoDb.Core

Show Region # 
Instance details

Defined in Aws.DynamoDb.Core

ddbLocal :: Region #

DynamoDb local connection (for development)

data DdbConfiguration qt #

Constructors

DdbConfiguration 

Fields

DynamoDB values

data DValue #

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 # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

(==) :: DValue -> DValue -> Bool #

(/=) :: DValue -> DValue -> Bool #

Ord DValue # 
Instance details

Defined in Aws.DynamoDb.Core

Read DValue # 
Instance details

Defined in Aws.DynamoDb.Core

Show DValue # 
Instance details

Defined in Aws.DynamoDb.Core

IsString DValue # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

fromString :: String -> DValue #

ToJSON DValue # 
Instance details

Defined in Aws.DynamoDb.Core

FromJSON DValue # 
Instance details

Defined in Aws.DynamoDb.Core

FromDynItem Item # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

parseItem :: Item -> Parser Item #

ToDynItem Item # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

toItem :: Item -> Item #

DynSize Item # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

dynSize :: Item -> Int #

DynSize DValue # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

dynSize :: DValue -> Int #

DynVal DValue # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep DValue :: * #

DynData DValue # 
Instance details

Defined in Aws.DynamoDb.Core

ListResponse ScanResponse Item # 
Instance details

Defined in Aws.DynamoDb.Commands.Scan

ListResponse QueryResponse Item # 
Instance details

Defined in Aws.DynamoDb.Commands.Query

type DynRep DValue # 
Instance details

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.

Minimal complete definition

toRep, fromRep

Associated Types

type DynRep a #

Which of the DynData instances does this data type directly map to?

Methods

toRep :: a -> DynRep a #

Convert to representation

fromRep :: DynRep a -> Maybe a #

Convert from representation

Instances
DynVal Bool # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Bool :: * #

DynVal Double # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Double :: * #

DynVal Int # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Int :: * #

DynVal Int8 # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Int8 :: * #

DynVal Int16 # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Int16 :: * #

DynVal Int32 # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Int32 :: * #

DynVal Int64 # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Int64 :: * #

DynVal Integer # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Integer :: * #

DynVal Word8 # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Word8 :: * #

DynVal Word16 # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Word16 :: * #

DynVal Word32 # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Word32 :: * #

DynVal Word64 # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Word64 :: * #

DynVal ByteString # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep ByteString :: * #

DynVal Text # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Text :: * #

DynVal UTCTime #

Losslessly encoded via Integer picoseconds

Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep UTCTime :: * #

DynVal Day #

Encoded as number of days

Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep Day :: * #

DynVal DValue # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep DValue :: * #

DynVal OldBool # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep OldBool :: * #

(DynData (DynRep [a]), DynVal a) => DynVal [a] #

Any singular DynVal can be upgraded to a list.

Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep [a] :: * #

Methods

toRep :: [a] -> DynRep [a] #

fromRep :: DynRep [a] -> Maybe [a] #

(DynData (DynRep (Set a)), DynVal a, Ord a) => DynVal (Set a) #

Any singular DynVal can be upgraded to a Set.

Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep (Set a) :: * #

Methods

toRep :: Set a -> DynRep (Set a) #

fromRep :: DynRep (Set a) -> Maybe (Set a) #

Serialize a => DynVal (Bin a) # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep (Bin a) :: * #

Methods

toRep :: Bin a -> DynRep (Bin a) #

fromRep :: DynRep (Bin a) -> Maybe (Bin a) #

toValue :: DynVal a => a -> DValue #

Encode a Haskell value.

fromValue :: DynVal a => DValue -> Maybe a #

Decode a Haskell value.

newtype 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.

Constructors

Bin 

Fields

Instances
Enum a => Enum (Bin a) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

succ :: Bin a -> Bin a #

pred :: Bin a -> Bin a #

toEnum :: Int -> Bin a #

fromEnum :: Bin a -> Int #

enumFrom :: Bin a -> [Bin a] #

enumFromThen :: Bin a -> Bin a -> [Bin a] #

enumFromTo :: Bin a -> Bin a -> [Bin a] #

enumFromThenTo :: Bin a -> Bin a -> Bin a -> [Bin a] #

Eq a => Eq (Bin a) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

(==) :: Bin a -> Bin a -> Bool #

(/=) :: Bin a -> Bin a -> Bool #

Ord a => Ord (Bin a) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

compare :: Bin a -> Bin a -> Ordering #

(<) :: Bin a -> Bin a -> Bool #

(<=) :: Bin a -> Bin a -> Bool #

(>) :: Bin a -> Bin a -> Bool #

(>=) :: Bin a -> Bin a -> Bool #

max :: Bin a -> Bin a -> Bin a #

min :: Bin a -> Bin a -> Bin a #

Read a => Read (Bin a) # 
Instance details

Defined in Aws.DynamoDb.Core

Show a => Show (Bin a) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

showsPrec :: Int -> Bin a -> ShowS #

show :: Bin a -> String #

showList :: [Bin a] -> ShowS #

Serialize a => DynVal (Bin a) # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep (Bin a) :: * #

Methods

toRep :: Bin a -> DynRep (Bin a) #

fromRep :: DynRep (Bin a) -> Maybe (Bin a) #

type DynRep (Bin a) # 
Instance details

Defined in Aws.DynamoDb.Core

type DynRep (Bin a) = DynBinary

newtype OldBool #

Constructors

OldBool Bool 
Instances
DynVal OldBool # 
Instance details

Defined in Aws.DynamoDb.Core

Associated Types

type DynRep OldBool :: * #

type DynRep OldBool # 
Instance details

Defined in Aws.DynamoDb.Core

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.

Minimal complete definition

fromData, toData

Methods

fromData :: a -> DValue #

toData :: DValue -> Maybe a #

Instances
DynData DValue # 
Instance details

Defined in Aws.DynamoDb.Core

DynData DynBinary # 
Instance details

Defined in Aws.DynamoDb.Core

DynData DynString # 
Instance details

Defined in Aws.DynamoDb.Core

DynData DynNumber # 
Instance details

Defined in Aws.DynamoDb.Core

DynData DynBool # 
Instance details

Defined in Aws.DynamoDb.Core

DynData (Set DynBinary) # 
Instance details

Defined in Aws.DynamoDb.Core

DynData (Set DynString) # 
Instance details

Defined in Aws.DynamoDb.Core

DynData (Set DynNumber) # 
Instance details

Defined in Aws.DynamoDb.Core

DynData (Set DynBool) # 
Instance details

Defined in Aws.DynamoDb.Core

newtype DynBinary #

Binary values stored in DynamoDb. Only used in defining new DynVal instances.

Constructors

DynBinary 

newtype DynNumber #

Numeric values stored in DynamoDb. Only used in defining new DynVal instances.

Constructors

DynNumber 

newtype DynString #

String values stored in DynamoDb. Only used in defining new DynVal instances.

Constructors

DynString 

Fields

newtype DynBool #

Boolean values stored in DynamoDb. Only used in defining new DynVal instances.

Constructors

DynBool 

Fields

Instances
Eq DynBool # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

(==) :: DynBool -> DynBool -> Bool #

(/=) :: DynBool -> DynBool -> Bool #

Ord DynBool # 
Instance details

Defined in Aws.DynamoDb.Core

Read DynBool # 
Instance details

Defined in Aws.DynamoDb.Core

Show DynBool # 
Instance details

Defined in Aws.DynamoDb.Core

DynData DynBool # 
Instance details

Defined in Aws.DynamoDb.Core

DynData (Set DynBool) # 
Instance details

Defined in Aws.DynamoDb.Core

Working with key/value pairs

data Attribute #

A key-value pair

Constructors

Attribute 

Fields

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.

attrTuple :: Attribute -> (Text, DValue) #

Convert attribute to a tuple representation

attr :: DynVal a => Text -> a -> Attribute #

Convenience function for constructing key-value pairs

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" ]

text :: Proxy Text #

Type witness for Text. See attrAs.

int :: Proxy Integer #

Type witness for Integer. See attrAs.

double :: Proxy Double #

Type witness for Double. See attrAs.

data PrimaryKey #

Primary keys consist of either just a Hash key (mandatory) or a hash key and a range key (optional).

Constructors

PrimaryKey 

hk :: Text -> DValue -> PrimaryKey #

Construct a hash-only primary key.

>>> hk "user-id" "ABCD"
>>> hk "user-id" (mkVal 23)

hrk #

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)

type Item = Map Text DValue #

A DynamoDb object is simply a key-value dictionary.

item :: [Attribute] -> Item #

Pack a list of attributes into an Item.

attributes :: Map Text DValue -> [Attribute] #

Unpack an Item into a list of attributes.

class ToDynItem a where #

Types convertible to DynamoDb Item collections.

Use attr and attrAs combinators to conveniently define instances.

Minimal complete definition

toItem

Methods

toItem :: a -> Item #

Instances
ToDynItem Item # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

toItem :: Item -> Item #

DynVal a => ToDynItem [(Text, a)] # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

toItem :: [(Text, a)] -> Item #

DynVal a => ToDynItem (Map Text a) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

toItem :: Map Text a -> Item #

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

parseItem

Methods

parseItem :: Item -> Parser a #

Instances
FromDynItem Item # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

parseItem :: Item -> Parser Item #

(Typeable a, DynVal a) => FromDynItem [(Text, a)] # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

parseItem :: Item -> Parser [(Text, a)] #

(Typeable a, DynVal a) => FromDynItem (Map Text a) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

parseItem :: Item -> Parser (Map Text a) #

fromItem :: FromDynItem a => Item -> Either String a #

Parse an Item into target type using the FromDynItem instance.

newtype Parser a #

A continuation-based parser type.

Constructors

Parser 

Fields

  • runParser :: forall f r. Failure f r -> Success a f r -> f r
     
Instances
Monad Parser # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

(>>=) :: Parser a -> (a -> Parser b) -> Parser b #

(>>) :: Parser a -> Parser b -> Parser b #

return :: a -> Parser a #

fail :: String -> Parser a #

Functor Parser # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

fmap :: (a -> b) -> Parser a -> Parser b #

(<$) :: a -> Parser b -> Parser a #

Applicative Parser # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

pure :: a -> Parser a #

(<*>) :: Parser (a -> b) -> Parser a -> Parser b #

liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c #

(*>) :: Parser a -> Parser b -> Parser b #

(<*) :: Parser a -> Parser b -> Parser a #

Alternative Parser # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

empty :: Parser a #

(<|>) :: Parser a -> Parser a -> Parser a #

some :: Parser a -> Parser [a] #

many :: Parser a -> Parser [a] #

MonadPlus Parser # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

mzero :: Parser a #

mplus :: Parser a -> Parser a -> Parser a #

Semigroup (Parser a) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

(<>) :: Parser a -> Parser a -> Parser a #

sconcat :: NonEmpty (Parser a) -> Parser a #

stimes :: Integral b => b -> Parser a -> Parser a #

Monoid (Parser a) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

mempty :: Parser a #

mappend :: Parser a -> Parser a -> Parser a #

mconcat :: [Parser a] -> Parser a #

getAttr #

Arguments

:: (Typeable a, DynVal a) 
=> Text

Attribute name

-> Item

Item from DynamoDb

-> Parser a 

Convenience combinator for parsing fields from an Item returned by DynamoDb.

getAttr' #

Arguments

:: DynVal a 
=> Text

Attribute name

-> Item

Item from DynamoDb

-> Parser (Maybe a) 

Parse attribute if it's present in the Item. Fail if attribute is present but conversion fails.

parseAttr #

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).

conditionsJson :: Text -> Conditions -> [Pair] #

JSON encoding of conditions parameter in various contexts.

data Condition #

A condition used by mutation operations (PutItem, UpdateItem, etc.).

Constructors

Condition 

Fields

data CondOp #

Conditional operation to perform on a field.

Instances
Eq CondOp # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

(==) :: CondOp -> CondOp -> Bool #

(/=) :: CondOp -> CondOp -> Bool #

Ord CondOp # 
Instance details

Defined in Aws.DynamoDb.Core

Read CondOp # 
Instance details

Defined in Aws.DynamoDb.Core

Show CondOp # 
Instance details

Defined in Aws.DynamoDb.Core

ToJSON CondOp # 
Instance details

Defined in Aws.DynamoDb.Core

data CondMerge #

How to merge multiple conditions.

Constructors

CondAnd 
CondOr 

data ConsumedCapacity #

The standard response metrics on capacity consumption.

data ReturnConsumption #

Constructors

RCIndexes 
RCTotal 
RCNone 
Instances
Eq ReturnConsumption # 
Instance details

Defined in Aws.DynamoDb.Core

Ord ReturnConsumption # 
Instance details

Defined in Aws.DynamoDb.Core

Read ReturnConsumption # 
Instance details

Defined in Aws.DynamoDb.Core

Show ReturnConsumption # 
Instance details

Defined in Aws.DynamoDb.Core

ToJSON ReturnConsumption # 
Instance details

Defined in Aws.DynamoDb.Core

Default ReturnConsumption # 
Instance details

Defined in Aws.DynamoDb.Core

data ItemCollectionMetrics #

Constructors

ItemCollectionMetrics 

Fields

data ReturnItemCollectionMetrics #

Constructors

RICMSize 
RICMNone 
Instances
Eq ReturnItemCollectionMetrics # 
Instance details

Defined in Aws.DynamoDb.Core

Ord ReturnItemCollectionMetrics # 
Instance details

Defined in Aws.DynamoDb.Core

Read ReturnItemCollectionMetrics # 
Instance details

Defined in Aws.DynamoDb.Core

Show ReturnItemCollectionMetrics # 
Instance details

Defined in Aws.DynamoDb.Core

ToJSON ReturnItemCollectionMetrics # 
Instance details

Defined in Aws.DynamoDb.Core

Default ReturnItemCollectionMetrics # 
Instance details

Defined in Aws.DynamoDb.Core

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

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.

Size estimation

class DynSize a where #

A class to help predict DynamoDb size of values, attributes and entire items. The result is given in number of bytes.

Minimal complete definition

dynSize

Methods

dynSize :: a -> Int #

Instances
DynSize Item # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

dynSize :: Item -> Int #

DynSize Attribute # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

dynSize :: Attribute -> Int #

DynSize DValue # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

dynSize :: DValue -> Int #

DynSize AttributeUpdate # 
Instance details

Defined in Aws.DynamoDb.Commands.UpdateItem

DynSize a => DynSize [a] # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

dynSize :: [a] -> Int #

DynSize a => DynSize (Maybe a) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

dynSize :: Maybe a -> Int #

(DynSize a, DynSize b) => DynSize (Either a b) # 
Instance details

Defined in Aws.DynamoDb.Core

Methods

dynSize :: Either a b -> Int #

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.

Constructors

DdbResponse 

shouldRetry :: DdbErrCode -> Bool #

Whether the action should be retried based on the received error.

data DdbError #

Potential errors raised by DynamoDB

Constructors

DdbError 

Fields

Instances
Eq DdbError # 
Instance details

Defined in Aws.DynamoDb.Core

Show DdbError # 
Instance details

Defined in Aws.DynamoDb.Core

Exception DdbError # 
Instance details

Defined in Aws.DynamoDb.Core

Internal Helpers

data AmazonError #

Constructors

AmazonError 

Fields

Instances
FromJSON AmazonError # 
Instance details

Defined in Aws.DynamoDb.Core