-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An API client for http://orchestrate.io/. -- @package orchestrate @version 0.2.0.0 module Database.Orchestrate.Types type APIKey = Text type Collection = Text type Key = Text type Ref = Text type Timestamp = Integer type Location = Text -- | This represents a function that makes a call to the Orchestrate API -- server. It takes Options, a URL String, and returns a -- Response. type RestCall a = Options -> String -> IO (Response a) type Limit = Int type Offset = Int type IfMatch' = Maybe Ref -- | A richer type than IfMatch for specifying conditional calls. data IfMatch -- | Only perform the action if the ref does exist. IfMatch :: Ref -> IfMatch -- | Only perform the action if the ref does not exist. IfNoneMatch :: Ref -> IfMatch -- | Always perform the action. NoMatch :: IfMatch -- | This is a range tuple. Each end can be specified separately. type Range a = (RangeEnd a, RangeEnd a) -- | This represents the end of a range. data RangeEnd a -- | The end should be inclusive. I.e., it should include a. Inclusive :: a -> RangeEnd a -- | The end should be exclusive. I.e., it should not include a. Exclusive :: a -> RangeEnd a -- | There is no bound on this end. Open :: RangeEnd a -- | A list of data returned by listV. -- -- type KVList v = ResultList (ResultItem Path v) -- | TombstoneItem data represents the data values in the database. data TombstoneItem v -- | TombstoneItem data are no longer alive. They are simply markers -- for deleted data. TombstoneItem :: !Path -> !Timestamp -> TombstoneItem v -- | The path to the deleted data. _tombstonePath :: TombstoneItem v -> !Path -- | The timestamp of this data. _tombstoneTime :: TombstoneItem v -> !Timestamp -- | LiveItem data are still in the database. LiveItem :: !Path -> !(Maybe v) -> !Timestamp -> TombstoneItem v -- | The path to the data. _livePath :: TombstoneItem v -> !Path -- | If values are requested, this will contain the data. _liveValue :: TombstoneItem v -> !(Maybe v) -- | The timestamp for the data. _liveTime :: TombstoneItem v -> !Timestamp -- | A Prism' into data created with the TombstoneItem -- constructor. _TombstoneItem :: Prism' (TombstoneItem v) (TombstoneItem v) -- | A Prism' into data created with the LiveItem -- constructor. _LiveItem :: Prism' (TombstoneItem v) (TombstoneItem v) livePath :: Traversal' (TombstoneItem v_aeRG) Path liveTime :: Traversal' (TombstoneItem v_aeRG) Timestamp liveValue :: Traversal (TombstoneItem v_aeRG) (TombstoneItem v_aeWM) (Maybe v_aeRG) (Maybe v_aeWM) tombstonePath :: Traversal' (TombstoneItem v_aeRG) Path tombstoneTime :: Traversal' (TombstoneItem v_aeRG) Timestamp -- | A list of events returned by listEvents. -- -- This data type uses two parameters: -- -- type EventList a b = ResultList (EventItem a b) type EventType = Text -- | The data necessary to access an event. data EventPath EventPath :: !Path -> !EventType -> !Timestamp -> !Int -> EventPath -- | The base Path to this data. _eventPath :: EventPath -> !Path -- | The kind of event. _eventPathType :: EventPath -> !EventType -- | The event's timestamp. _eventPathTime :: EventPath -> !Timestamp -- | The event's ordinal number. _eventPathOrd :: EventPath -> !Int eventPath :: Lens' EventPath Path eventPathType :: Lens' EventPath EventType eventPathTime :: Lens' EventPath Timestamp eventPathOrd :: Lens' EventPath Int -- | One item in an EventList. -- -- This data type uses two parameters: -- -- data EventItem a b EventItem :: !(ResultItem EventPath a) -> !Timestamp -> !Int -> EventItem a b -- | The data itself and the path to it. _eventItem :: EventItem a b -> !(ResultItem EventPath a) -- | The event's timestamp. _eventTime :: EventItem a b -> !Timestamp -- | The event's ordinal number. _eventOrd :: EventItem a b -> !Int eventItem :: Lens (EventItem a_adUI b_adUJ) (EventItem a_aeRc b_aeRd) (ResultItem EventPath a_adUI) (ResultItem EventPath a_aeRc) eventTime :: Lens (EventItem a_adUI b_adUJ) (EventItem a_adUI b_aeRf) Timestamp Timestamp eventOrd :: Lens (EventItem a_adUI b_adUJ) (EventItem a_adUI b_aeRe) Int Int type RelKind = Text -- | A list of edges returned by getRel. -- -- This datatype uses two parameters: -- -- type RelList a b = ResultList (ResultItem Path b) type QueryText = Text -- | The collection of search results. data SearchList v SearchList :: !(ResultList (SearchItem v)) -> !Int -> SearchList v -- | The list of search results. _searchResults :: SearchList v -> !(ResultList (SearchItem v)) -- | The total number of hits for the search. This may be more than the -- number of results returned. _searchTotal :: SearchList v -> !Int searchResults :: Lens (SearchList v_afKY) (SearchList v_afO3) (ResultList (SearchItem v_afKY)) (ResultList (SearchItem v_afO3)) searchTotal :: Lens' (SearchList v_afKY) Int -- | A single search item. data SearchItem v SearchItem :: !(ResultItem Path v) -> !Double -> SearchItem v -- | The path to the item and the item itself. _searchItem :: SearchItem v -> !(ResultItem Path v) -- | The item's relevancy to the query. _searchScore :: SearchItem v -> !Double searchItem :: Lens (SearchItem v_aeXy) (SearchItem v_afKJ) (ResultItem Path v_aeXy) (ResultItem Path v_afKJ) searchScore :: Lens' (SearchItem v_aeXy) Double -- | The data for a session with the Orchestrate database. data Session Session :: !Text -> !APIKey -> !Int -> !Options -> Session -- | The base URL for the Orchestrate API. _sessionURL :: Session -> !Text -- | The API key for accessing the API. _sessionKey :: Session -> !APIKey -- | The version of the API. _sessionVersion :: Session -> !Int -- | The baseline set of Options for making wreq calls. This -- includes the API key. _sessionOptions :: Session -> !Options sessionURL :: Lens' Session Text sessionKey :: Lens' Session APIKey sessionVersion :: Lens' Session Int sessionOptions :: Lens' Session Options -- | This is a class for data that can be stored in an Orchestrate -- Key/Value store. See Database.Orchestrate.KeyValue for -- where this is used. class (ToJSON a, FromJSON a) => OrchestrateData a tableName :: OrchestrateData a => a -> Collection dataKey :: OrchestrateData a => a -> Key -- | The type for the Orchestrate monad. All interactions with the -- Orchestrate API are run in this monad. It combines a reader over -- Session data with error handling using EitherT -- SomeException. newtype OrchestrateT m a OrchestrateT :: EitherT SomeException (ReaderT Session m) a -> OrchestrateT m a runOrchestrate :: OrchestrateT m a -> EitherT SomeException (ReaderT Session m) a -- | OrchestrateT over IO, the way God intended. type OrchestrateIO = OrchestrateT IO -- | OrchestrateT over Identity. Only the most useless monad -- ever. type Orchestrate = OrchestrateT Identity -- | A parameterized list of results returned by an API call. -- -- data ResultList i ResultList :: !Int -> ![i] -> !(Maybe Location) -> !(Maybe Location) -> ResultList i _resultCount :: ResultList i -> !Int _resultList :: ResultList i -> ![i] _resultPrev :: ResultList i -> !(Maybe Location) _resultNext :: ResultList i -> !(Maybe Location) resultCount :: Lens' (ResultList i_adlX) Int resultList :: Lens (ResultList i_adlX) (ResultList i_adLn) [i_adlX] [i_adLn] resultPrev :: Lens' (ResultList i_adlX) (Maybe Location) resultNext :: Lens' (ResultList i_adlX) (Maybe Location) -- | A parameterized single item returned in a collection by an API call. -- -- data ResultItem p v ResultItem :: !p -> !v -> ResultItem p v _itemPath :: ResultItem p v -> !p _itemValue :: ResultItem p v -> !v itemPath :: Lens (ResultItem p_adLU v_adLV) (ResultItem p_adQ8 v_adLV) p_adLU p_adQ8 itemValue :: Lens (ResultItem p_adLU v_adLV) (ResultItem p_adLU v_adQ9) v_adLV v_adQ9 -- | This represents the unique access information for a value in the -- store. data Path Path :: !Collection -> !Key -> !Ref -> Path -- | The collection containing the data. _itemCollection :: Path -> !Collection -- | The data's key in the collection. _itemKey :: Path -> !Key -- | The reference to the current version of the value. _itemRef :: Path -> !Ref itemCollection :: Lens' Path Collection itemKey :: Lens' Path Key itemRef :: Lens' Path Ref -- | Retrieves the monad environment. ask :: MonadReader r m => m r -- | Retrieves a function of the current environment. asks :: MonadReader r m => (r -> a) -> m a -- | Is used within a monadic computation to begin exception processing. throwError :: MonadError e m => forall a. e -> m a -- | A handler function to handle previous errors and return to normal -- execution. A common idiom is: -- --
--   do { action1; action2; action3 } `catchError` handler
--   
-- -- where the action functions can call throwError. Note -- that handler and the do-block must have the same return type. catchError :: MonadError e m => forall a. m a -> (e -> m a) -> m a instance FromJSON v => FromJSON (SearchList v) instance Show v => Show (SearchList v) instance FromJSON v => FromJSON (SearchItem v) instance Show v => Show (SearchItem v) instance FromJSON v => FromJSON (TombstoneItem v) instance Show v => Show (TombstoneItem v) instance FromJSON a => FromJSON (EventItem a b) instance Show a => Show (EventItem a b) instance ToJSON EventPath instance FromJSON EventPath instance Show EventPath instance (ToJSON p, ToJSON v) => ToJSON (ResultItem p v) instance (FromJSON p, FromJSON v) => FromJSON (ResultItem p v) instance (Show p, Show v) => Show (ResultItem p v) instance FromJSON r => FromJSON (ResultList r) instance Show i => Show (ResultList i) instance ToJSON Path instance FromJSON Path instance Monad m => Functor (OrchestrateT m) instance Monad m => Applicative (OrchestrateT m) instance Monad m => Monad (OrchestrateT m) instance Show Path instance Monad m => MonadError SomeException (OrchestrateT m) instance Monad m => MonadReader Session (OrchestrateT m) instance MonadIO m => MonadIO (OrchestrateT m) instance MonadTrans OrchestrateT instance Default Session instance Show IfMatch instance Show a => Show (RangeEnd a) instance Functor RangeEnd instance Show Session -- | This module implements some network-oriented utility functions. module Database.Orchestrate.Network -- | This takes a response and checks that the status code passes. -- -- If the HTTP status code is not OK, this returns an error in the -- OrchestrateT monad. checkResponse :: Monad m => Response a -> OrchestrateT m () -- | This checks the status code. Currently 200 and 204 are OK. Everything -- else is bad. Bad codes throw an exception in OrchestrateT. checkStatusCode :: Monad m => Int -> OrchestrateT m () module Database.Orchestrate.Utils -- | Run an OrchestrateT action with a Session that does -- not include authentication. This function will add proper -- authentication before running the action. runO :: Monad m => OrchestrateT m a -> Session -> m (Either SomeException a) -- | Run an OrchestrateT action with a Session that already -- includes authentication. -- -- This is the most minimal handler. runO' :: Monad m => OrchestrateT m a -> Session -> m (Either SomeException a) -- | Lifts an Either value into the OrchestrateT monad. orchestrateEither :: Monad m => Either SomeException a -> OrchestrateT m a -- | Lifts an IO action into the OrchestrateT monad. io :: MonadIO m => IO a -> OrchestrateT m a -- | This assembles and performs an API call. api :: RequestHeaders -> [Text] -> [FormParam] -> RestCall a -> OrchestrateIO (Response a) -- | This assembles and peforms an API call, lifting any status code errors -- out of the monad and returning them in an explicit Either. api' :: RequestHeaders -> [Text] -> [FormParam] -> RestCall a -> OrchestrateIO (Either Status (Response a)) -- | This assembles and performs an API call. It returns Nothing if -- the call returns a 404 status code. api404 :: Show a => RequestHeaders -> [Text] -> [FormParam] -> RestCall a -> OrchestrateIO (Maybe (Response a)) -- | This assembles and performs an API call and checks that the status -- passes checkResponse. apiCheck :: RequestHeaders -> [Text] -> [FormParam] -> RestCall a -> OrchestrateIO (Response a) -- | This assembles and performs an API call. Afterward it checks the -- status code and decodes the JSON response. apiCheckDecode :: FromJSON a => RequestHeaders -> [Text] -> [FormParam] -> RestCall ByteString -> OrchestrateIO a -- | Pings the Orchestrate API. ping :: OrchestrateIO () -- | Create the base Orchestrate API URL given the current Session. baseUrl :: Monad m => OrchestrateT m Text -- | Builds a URL from its assembled parts. buildUrl :: Monad m => [Text] -> OrchestrateT m String -- | Adds the API key to the default Options. withAuth' :: APIKey -> Options -- | Adds the API key to a set of wreq Options. withAuth :: APIKey -> Options -> Options -- | This returns the Session with the API key taken from the -- ORCHESTRATE_API environment variable. -- -- The value of sessionOptions will include authentication. envSession :: IO Session -- | Takes an IfMatch and returns a list of request headers. ifMatch :: IfMatch -> [Header] -- | Takes an IfMatch' and returns a list of request headers. ifMatch' :: IfMatch' -> [Header] -- | A prism over the collection part of a Location URL. locationCollection :: Prism' Text Text -- | A prism over the key part of a Location URL. locationKey :: Prism' Text Text -- | A prism over the ref part of a Location URL. locationRef :: Prism' Text Text -- | A prism over the type part of a Location URL from an event -- operation. locationType :: Prism' Text Text -- | A prism over the timestamp part of a Location URL from an event -- operation. locationTimestamp :: Prism' Text Integer -- | A prism over the ordinal part of a Location URL from an event -- operation. locationOrdinal :: Prism' Text Int -- | Retrieves the Location from a response's headers. getLocation :: Response a -> Text -- | Given a starting RangeEnd, return the form parameter. rangeStart :: FormValue a => ByteString -> RangeEnd a -> Maybe FormParam -- | Given an ending RangeEnd, return the form parameter. rangeEnd :: FormValue a => ByteString -> RangeEnd a -> Maybe FormParam -- | This takes a three-parameter function and rotates the parameters to -- return a function that takes the third parameter first. rot :: (a -> b -> c -> d) -> c -> a -> b -> d -- | Show data as Text. tshow :: Show a => a -> Text -- | Returns both the last item in a list and the list's init. -- -- If the list is empty, it will return (Nothing, []). -- Otherwise, it's an optimized call to (lastMay &&& -- initSafe). initTail :: [a] -> (Maybe a, [a]) -- | This module implements the Orchestrate Refs API. -- -- Refs represent the immutable values that have been associated with a -- key. module Database.Orchestrate.Ref -- | This retrieves a ref associated with some data. -- --
--   getRef "coll-name" "key" "43214321"
--   
getRef :: FromJSON r => Collection -> Key -> Ref -> OrchestrateIO (Maybe r) -- | This lists all the values that have been associated with a key in the -- database. Values are returned last to first. -- --
--   listRefs "coll-name" "key" Nothing Nothing False
--   
listRefs :: FromJSON v => Collection -> Key -> Maybe Int -> Maybe Int -> Bool -> OrchestrateIO (ResultList (TombstoneItem v)) -- | This module implements the Orchestrate Search API. module Database.Orchestrate.Search -- | This performs the query and returns the results. -- --
--   query "coll-name" "query" (Just 25) Nothing
--   
query :: FromJSON v => Collection -> QueryText -> Maybe Int -> Maybe Int -> OrchestrateIO (SearchList v) -- | This implements the Key/Value API. -- -- Generally, the data stored knows about its own key using via the -- OrchestrateData class instance defined for it. module Database.Orchestrate.KeyValue -- | This retrieves a value from a collection. -- --
--   lookup "contacts" "mom"
--   
lookup :: FromJSON v => Collection -> Key -> OrchestrateIO (Maybe v) -- | This lists all the data in the collection within the range given. -- --
--   listVals "coll-name" Nothing (Open, Open)
--   
listVals :: FromJSON v => Collection -> Maybe Int -> Range Key -> OrchestrateIO (KVList v) -- | This inserts data into the database or updates existing data using a -- key generated by the OrchestrateData instance. -- --
--   putV data NoMatch
--   
putV :: OrchestrateData v => v -> IfMatch -> OrchestrateIO Location -- | This inserts data into the database or updates data in the database. -- This overrides the key provided by the data type's -- OrchestrateData instance. However, it still requires an -- implementation of that data type for the collection name. -- --
--   putKV "key" data NoMatch
--   
putKV :: OrchestrateData v => Key -> v -> IfMatch -> OrchestrateIO Location -- | This inserts data in the database, generating a new database key for -- it. -- --
--   postV data
--   
postV :: OrchestrateData v => v -> OrchestrateIO (Location, Maybe Key) -- | This removes data from the database. -- --
--   deleteV data Nothing
--   
deleteV :: OrchestrateData v => v -> IfMatch' -> OrchestrateIO () -- | This removes data from the database. -- --
--   deleteKV "key" data Nothing
--   
deleteKV :: OrchestrateData v => Key -> v -> IfMatch' -> OrchestrateIO () -- | This purges data from the database. Purging not only removes the data, -- but also all history and secondary items for it. -- --
--   purgeV data Nothing
--   
purgeV :: OrchestrateData v => v -> IfMatch' -> OrchestrateIO () -- | This purges data from the database. Purging not only removes the data, -- but also all history and secondary items for it. -- --
--   purgeKV "key" data Nothing
--   
purgeKV :: OrchestrateData v => Key -> v -> IfMatch' -> OrchestrateIO () -- | This module implements the Graph API. module Database.Orchestrate.Graph -- | This retrieves a list of target nodes from edges originating from -- a. For more information see the API documentation. -- -- If the third parameter is not empty, it represents additional edges -- that will be traversed to get to the target. -- -- For example: -- --
--   getRel data "friend" ["last_name"]
--   
getRel :: (OrchestrateData a, FromJSON b) => a -> RelKind -> [RelKind] -> OrchestrateIO (RelList a b) -- | Creates a relationship (an edge) between two nodes. The edge has a -- RelKind type. See the API documentation for more -- information. -- -- For example: -- --
--   createRel start "parent" child
--   
createRel :: (OrchestrateData a, OrchestrateData b) => a -> RelKind -> b -> OrchestrateIO () -- | This removes a relationship (an edge) between two nodes. -- -- For example: -- --
--   deleteRel start "parent" child
--   
deleteRel :: (OrchestrateData a, OrchestrateData b) => a -> RelKind -> b -> OrchestrateIO () -- | This module implements the API calls for working with -- Orchestrate events. module Database.Orchestrate.Events -- | This retrieves a single event. See the API documentation for -- more information. -- -- For example, this retrieves a transaction event. -- --
--   getEvent data "transaction" 784111777000 79
--   
getEvent :: (OrchestrateData a, FromJSON b) => a -> EventType -> Timestamp -> Int -> OrchestrateIO (Maybe (EventItem b a)) -- | 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
--   
createEvent :: (OrchestrateData a, ToJSON b) => a -> EventType -> b -> Maybe Timestamp -> OrchestrateIO Location -- | 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
--   
updateEvent :: (OrchestrateData a, ToJSON b) => a -> EventType -> b -> Timestamp -> Int -> IfMatch' -> OrchestrateIO Location -- | This deletes an event. See the API documentation for more -- information. -- -- For example: -- --
--   deleteEvent data "transaction"
--       <$> loc ^? locationTimestamp
--       <*> loc ^? locationOrdinal
--   
deleteEvent :: OrchestrateData a => a -> EventType -> Timestamp -> Int -> IfMatch' -> OrchestrateIO () -- | 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)
--   
listEvents :: (OrchestrateData a, FromJSON b) => a -> EventType -> Maybe Int -> Range (Timestamp, Maybe Int) -> OrchestrateIO (EventList b a) -- | This takes a Location and an event datum and returns the -- EventItem representing it. locationEventItem :: Location -> a -> Maybe (EventItem a b) -- | This takes an EventItem and returns the datum and -- Location associated with that item. eventItemLocation :: Monad m => EventItem a b -> OrchestrateT m (a, Location) -- | This implements the API calls to manage collections on -- Orchestrate. module Database.Orchestrate.Collection -- | This deletes a collection. See the API documentation for more -- information. -- --
--   deleteCollection "collection-name"
--   
deleteCollection :: Collection -> OrchestrateIO () module Database.Orchestrate