Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module implements the API calls for working with Orchestrate events.
- getEvent :: (OrchestrateData a, FromJSON b) => a -> EventType -> Timestamp -> Int -> OrchestrateIO (Maybe (EventItem b a))
- createEvent :: (OrchestrateData a, ToJSON b) => a -> EventType -> b -> Maybe Timestamp -> OrchestrateIO Location
- updateEvent :: (OrchestrateData a, ToJSON b) => a -> EventType -> b -> Timestamp -> Int -> IfMatch' -> OrchestrateIO Location
- deleteEvent :: OrchestrateData a => a -> EventType -> Timestamp -> Int -> IfMatch' -> OrchestrateIO ()
- listEvents :: (OrchestrateData a, FromJSON b) => a -> EventType -> Maybe Int -> Range (Timestamp, Maybe Int) -> OrchestrateIO (EventList b a)
- locationEventItem :: Location -> a -> Maybe (EventItem a b)
- eventItemLocation :: Monad m => EventItem a b -> OrchestrateT m (a, Location)
API Functions
:: (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)) |
This retrieves a single event. See the API documentation for more information.
For example, this retrieves a transaction event.
getEvent data "transaction" 784111777000 79
:: (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
:: (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 |
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
:: 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
:: (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
eventItemLocation :: Monad m => EventItem a b -> OrchestrateT m (a, Location) Source