orchestrate-0.2.0.3: An API client for http://orchestrate.io/.

Safe HaskellNone
LanguageHaskell2010

Database.Orchestrate.Events

Contents

Description

This module implements the API calls for working with Orchestrate events.

Synopsis

API Functions

getEvent Source

Arguments

:: (OrchestrateData a, FromJSON b) 
=> a

The data that the event is associated with.

-> EventType

The kind of event.

-> Timestamp

The event's timestamp.

-> Int

The event's ordinal number.

-> OrchestrateIO (Maybe (EventItem b a))

Just the event or Nothing.

This retrieves a single event. See the API documentation for more information.

For example, this retrieves a transaction event.

getEvent data "transaction" 784111777000 79

createEvent Source

Arguments

:: (OrchestrateData a, ToJSON b) 
=> a

The data that the event is associated with.

-> EventType

The kind of event.

-> b

The event data.

-> Maybe Timestamp

The event's timestamp. If not given, the current time is used.

-> OrchestrateIO Location

Returns the event's location.

This creates an event and returns its Location. See API document for more information.

For example, this creates a transaction, using the current time for the timestamp.

createEvent data "transaction" transactionData Nothing

updateEvent Source

Arguments

:: (OrchestrateData a, ToJSON b) 
=> a

The data that the event is associated with.

-> EventType

The kind of event.

-> b

The updated event data.

-> Timestamp

The timestamp for the event.

-> Int

The ordinal for the event.

-> IfMatch'

If given, will only succeed if the ref matches the event's currently stored ref.

-> OrchestrateIO Location

Returns the Location for the new event data.

This updates the data for an event. The storage is keyed by type, timestamp, and ordinal, so the event data can change. See the API documentation for more information.

For example:

updateEvent data "transaction" updatedTransactionData
    <$> loc ^? locationTimestamp
    <*> loc ^? locationOrdinal

deleteEvent Source

Arguments

:: OrchestrateData a 
=> a

The data that the event is associated with.

-> EventType

The kind of event.

-> Timestamp

The timestamp for the event.

-> Int

The ordinal for the event.

-> IfMatch'

If given, will only succeed if the ref matches the event's currently stored ref.

-> OrchestrateIO () 

This deletes an event. See the API documentation for more information.

For example:

deleteEvent data "transaction"
    <$> loc ^? locationTimestamp
    <*> loc ^? locationOrdinal

listEvents Source

Arguments

:: (OrchestrateData a, FromJSON b) 
=> a

The data the events are to associated with.

-> EventType

The type of events to retrieve.

-> Maybe Int

The maximum number of event data to return. The default is 10, and the maximum is 100.

-> Range (Timestamp, Maybe Int)

The range of events to retrieve. Each range is the timestamp and maybe the ordinal.

-> OrchestrateIO (EventList b a) 

This lists all the events within a given range for a data. See the API documentation for more information.

For example:

listEvents data "transaction" (Just 25) (Open, Open)

Location Conversion Functions

locationEventItem :: Location -> a -> Maybe (EventItem a b) Source

This takes a Location and an event datum and returns the EventItem representing it.

eventItemLocation :: Monad m => EventItem a b -> OrchestrateT m (a, Location) Source

This takes an EventItem and returns the datum and Location associated with that item.