Copyright | (c) Finlay Thompson, 2015 |
---|---|
License | BSD3 |
Maintainer | finlay.thompson@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
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.
- userOrganisations :: GitHub [Organisation]
- organisationTeams :: OrgLogin -> GitHub [Team]
- getTeam :: TeamId -> GitHub Team
- teamMembers :: TeamId -> GitHub [Member]
- teamRepositories :: TeamId -> GitHub [Repository]
- type GitHub = ReaderT (Maybe AuthToken) (StateT GitHubState (EitherT ServantError IO))
- runGitHub :: GitHub a -> Maybe AuthToken -> IO (Either ServantError a)
- data AuthToken
- setUserAgent :: Text -> GitHub ()
- resetPagination :: GitHub ()
- recurseOff :: GitHub ()
- recurseOn :: GitHub ()
- pageSize :: Int -> GitHub ()
- getLinks :: GitHub (Maybe [Link])
- module Network.GitHub.API
- module Network.GitHub.Types
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
teamMembers :: TeamId -> GitHub [Member] Source
teamRepositories :: TeamId -> GitHub [Repository] Source
Get list of Repository
records assoctiated to Team
given by Team Id
GitHub monad
type GitHub = ReaderT (Maybe AuthToken) (StateT GitHubState (EitherT ServantError IO)) Source
The GitHub
monad provides execution context
Token used to authorize access to the GitHub API. see https://developer.github.com/v3/oauth/
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.
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.
module Network.GitHub.API
module Network.GitHub.Types