github-rest-1.0.2: Query the GitHub REST API programmatically

MaintainerBrandon Chinn <brandon@leapyear.io>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

GitHub.REST.Monad.Class

Description

Defines MonadGitHubREST that gives a monad m the capability to query the GitHub REST API.

Synopsis

Documentation

class Monad m => MonadGitHubREST m where Source #

A type class for monads that can query the GitHub REST API.

Example:

-- create the "foo" branch
queryGitHub GHEndpoint
  { method = POST
  , endpoint = "/repos/:owner/:repo/git/refs"
  , endpointVals =
    [ "owner" := "alice"
    , "repo" := "my-project"
    ]
  , ghData =
    [ "ref" := "refs/heads/foo"
    , "sha" := "1234567890abcdef"
    ]
  }

It's recommended that you create functions for the API endpoints you're using:

deleteBranch branch = queryGitHub GHEndpoint
  { method = DELETE
  , endpoint = "/repos/:owner/:repo/git/refs/:ref"
  , endpointVals =
    [ "owner" := "alice"
    , "repo" := "my-project"
    , "ref" := "heads/" <> branch
    ]
  , ghData = []
  }

Minimal complete definition

queryGitHubPage'

Methods

queryGitHubPage' :: FromJSON a => GHEndpoint -> m (Either (Text, Text) (a, PageLinks)) Source #

Query GitHub, returning Right (payload, links) if successful, where payload is the response that GitHub sent back and links containing any pagination links GitHub may have sent back. If the response could not be decoded as JSON, returns Left (error message, response from server).

Errors on network connection failures or if GitHub sent back an error message. Use githubTry if you wish to handle GitHub errors.

queryGitHubPage :: FromJSON a => GHEndpoint -> m (a, PageLinks) Source #

queryGitHubPage', except calls fail if JSON decoding fails.

queryGitHub :: FromJSON a => GHEndpoint -> m a Source #

queryGitHubPage, except ignoring pagination links.

queryGitHubAll :: (FromJSON a, Monoid a) => GHEndpoint -> m a Source #

Repeatedly calls queryGitHubPage for each page returned by GitHub and concatenates the results.

queryGitHub_ :: GHEndpoint -> m () Source #

queryGitHub, except ignores the result.

Instances
MonadGitHubREST m => MonadGitHubREST (MaybeT m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class

MonadIO m => MonadGitHubREST (GitHubT m) Source # 
Instance details

Defined in GitHub.REST.Monad

MonadGitHubREST m => MonadGitHubREST (ExceptT e m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class

MonadGitHubREST m => MonadGitHubREST (IdentityT m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class

MonadGitHubREST m => MonadGitHubREST (StateT s m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class

MonadGitHubREST m => MonadGitHubREST (StateT s m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class

(Monoid w, MonadGitHubREST m) => MonadGitHubREST (WriterT w m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class

(Monoid w, MonadGitHubREST m) => MonadGitHubREST (WriterT w m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class

MonadGitHubREST m => MonadGitHubREST (ReaderT r m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class

(Monoid w, MonadGitHubREST m) => MonadGitHubREST (RWST r w s m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class

(Monoid w, MonadGitHubREST m) => MonadGitHubREST (RWST r w s m) Source # 
Instance details

Defined in GitHub.REST.Monad.Class