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]
- userOrganisationMemberships :: GitHub [OrganisationMember]
- organisationTeams :: OrgLogin -> GitHub [Team]
- getTeam :: TeamId -> GitHub Team
- teamMembers :: TeamId -> GitHub [Member]
- teamRepositories :: TeamId -> GitHub [Repository]
- user :: GitHub User
- userByLogin :: Maybe String -> GitHub User
- userRepositories :: Maybe String -> GitHub [Repository]
- userInstallationRepositories :: Int -> GitHub Repositories
- organisationRepositories :: OrgLogin -> GitHub [Repository]
- installationRepositories :: GitHub Repositories
- appInstallations :: GitHub [Installation]
- userInstallations :: Maybe String -> GitHub Installations
- repositoryCollaborators :: OrgLogin -> RepoName -> GitHub [Member]
- getCommit :: OrgLogin -> RepoName -> Sha -> GitHub Commit
- getContent :: OrgLogin -> RepoName -> String -> Maybe String -> Maybe String -> GitHub Content
- getIssues :: GHOptions -> Owner -> RepoName -> GitHub [Issue]
- integrationJWT :: (MonadRandom m, MonadError e m, AsError e) => JWK -> Int -> UTCTime -> m Text
- reqInstallationAccessToken :: JWK -> Int -> Int -> Maybe InstallationUser -> ClientM InstallationAccessToken
- type GitHub = ReaderT (Maybe AuthToken) (StateT GitHubState ClientM)
- runGitHubClientM :: ClientM a -> IO (Either ServantError a)
- runGitHubNotApiClientM :: ClientM a -> IO (Either ServantError a)
- runGitHub' :: GitHub a -> Maybe AuthToken -> ClientM a
- 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
userOrganisationMemberships :: GitHub [OrganisationMember] Source #
Get list of OrganisationMember
records for authorised user
organisationTeams :: OrgLogin -> GitHub [Team] Source #
Get list of Team
records, given the organisation login
teamRepositories :: TeamId -> GitHub [Repository] Source #
Get list of Repository
records assoctiated to Team
given by Team Id
userRepositories :: Maybe String -> GitHub [Repository] Source #
Get repositories for the authorised user
userInstallationRepositories :: Int -> GitHub Repositories Source #
List repositories that are accessible to the authenticated user for an installation.
organisationRepositories :: OrgLogin -> GitHub [Repository] Source #
Get repositories for an organisation login
installationRepositories :: GitHub Repositories Source #
Get repositories for the installation (current token should be an installation token)
appInstallations :: GitHub [Installation] Source #
Get installations for the appliction
userInstallations :: Maybe String -> GitHub Installations Source #
List installations that are accessible to the authenticated user.
repositoryCollaborators :: OrgLogin -> RepoName -> GitHub [Member] Source #
Get repositories for the installation (current token should be an installation token)
getContent :: OrgLogin -> RepoName -> String -> Maybe String -> Maybe String -> GitHub Content Source #
Get content for repo and reference and path
integrationJWT :: (MonadRandom m, MonadError e m, AsError e) => JWK -> Int -> UTCTime -> m Text Source #
reqInstallationAccessToken :: JWK -> Int -> Int -> Maybe InstallationUser -> ClientM InstallationAccessToken Source #
GitHub monad
type GitHub = ReaderT (Maybe AuthToken) (StateT GitHubState ClientM) Source #
The GitHub
monad provides execution context
runGitHubClientM :: ClientM a -> IO (Either ServantError a) Source #
runGitHubNotApiClientM :: ClientM a -> IO (Either ServantError a) Source #
Most of the time we must use api.github.com, but calling loginoauthaccess_token only works if sent to github.com.
Token used to authorize access to the GitHub API. see https://developer.github.com/v3/oauth/
Eq AuthToken Source # | |
IsString AuthToken Source # | |
ToHttpApiData 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 -> d -> e -> g -> h -> i -> k -> l -> m -> Paginated f) Source # | |
HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> k -> l -> Paginated f) Source # | |
HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> k -> Paginated f) Source # | |
HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> Paginated f) Source # | |
HasGitHub (a -> b -> c -> d -> e -> g -> h -> Paginated f) Source # | |
HasGitHub (a -> b -> c -> d -> e -> g -> Paginated f) Source # | |
HasGitHub (a -> b -> c -> d -> e -> Paginated f) Source # | |
HasGitHub (a -> b -> c -> d -> Paginated e) Source # | |
HasGitHub (a -> b -> c -> Paginated d) Source # | |
HasGitHub (a -> b -> Paginated c) Source # | |
HasGitHub (a -> Paginated b) Source # | |
HasGitHub (a -> b -> c -> d -> e -> Single f) Source # | |
HasGitHub (a -> b -> c -> d -> Single e) 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.
module Network.GitHub.API
module Network.GitHub.Types