servant-github-0.1.0.0: Bindings to GitHub API using servant.

Copyright(c) Finlay Thompson, 2015
LicenseBSD3
Maintainerfinlay.thompson@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Network.GitHub

Contents

Description

The GitHub monad provides support for:

  • Managing the authentication token. It can be Nothing, in which case no Authentication header is sent to the API,
  • Setting the User-agent header string. This defaults to "servant-github", but can be set inside the GitHub monad using the setUserAgent, and
  • Keeping track of the pagination in the case of calls that return lists of objects.

Synopsis

GitHub API calls

Functions that directly access the GitHub API. These functions all run in the GitHub monad.

userOrganisations :: GitHub [Organisation] Source

Get list of Organisation records for authorised user

organisationTeams :: OrgLogin -> GitHub [Team] Source

Get list of Team records, given the organisation login

getTeam :: TeamId -> GitHub Team Source

Get the Team record associated to a TeamId

teamMembers :: TeamId -> GitHub [Member] Source

Get list of Member records assoctiated to Team given by Team Id

teamRepositories :: TeamId -> GitHub [Repository] Source

Get list of Repository records assoctiated to Team given by Team Id

GitHub monad

Use the runGitHub function to execute the GitHub client function.

type GitHub = ReaderT (Maybe AuthToken) (StateT GitHubState (EitherT ServantError IO)) Source

The GitHub monad provides execution context

runGitHub :: GitHub a -> Maybe AuthToken -> IO (Either ServantError a) Source

You need to provide a 'Maybe AuthToken' to lift a GitHub computation into the IO monad.

data AuthToken Source

Token used to authorize access to the GitHub API. see https://developer.github.com/v3/oauth/

Instances

Eq AuthToken Source 
IsString AuthToken Source 
ToText AuthToken Source 
HasGitHub (Paginated a) Source

Instance for the case where we have paginated results

HasGitHub (Single a) Source

Instance for the case where we have single result

HasGitHub (a -> b -> c -> Paginated d) Source 
HasGitHub (a -> b -> Paginated c) Source 
HasGitHub (a -> Paginated b) Source 
HasGitHub (a -> b -> c -> Single d) Source 
HasGitHub (a -> b -> Single c) Source 
HasGitHub (a -> Single b) Source 

setUserAgent :: Text -> GitHub () Source

Overide default value for User-agent header. Note, GitHub requires that a User-agent header be set.

Pagination

Functions for managing the pagination features of the GitHub API

resetPagination :: GitHub () Source

Set next page back to 1, and remove the links

recurseOff :: GitHub () Source

Turn automatic recusive behaviour on and off.

If recursive is on, paginated results will be automatically followed and concated together.

recurseOn :: GitHub () Source

Turn automatic recusive behaviour on and off.

If recursive is on, paginated results will be automatically followed and concated together.

pageSize :: Int -> GitHub () Source

The default number of records per page is set to 100. Smaller pages can be set, but not bigger than 100.

getLinks :: GitHub (Maybe [Link]) Source

Return the Link header. This is only set when there are futher pages.