-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bindings to GitHub API using servant. -- -- This package provides a servant-client based client for accessing the -- GitHub API v3. -- -- The github client is provided through the Network.GitHub.GitHub -- monad, which provides support for managing the user-agent (a -- requirement for github), an authentication token, and, pagination -- support when the resulting value is a list. -- --
-- import System.Environment -- import Data.String -- import Network.GitHub -- -- main = do -- token <- fmap fromString <$> lookupEnv "GITHUB_TOKEN" -- result <- runGitHub userOrganisations token -- case result of -- Left e -> print e -- Right orgs -> mapM_ print orgs --@package servant-github @version 0.1.0.2 module Network.GitHub.Client -- | Wrapper around the servant client function, that takes care of -- the extra headers that required for the GitHub monad. github :: (HasClient (AddHeaders api), HasGitHub (Client (AddHeaders api))) => Proxy api -> EmbedGitHub (Client (AddHeaders api)) -- | Token used to authorize access to the GitHub API. see -- https://developer.github.com/v3/oauth/ data AuthToken -- | The GitHub monad provides execution context type GitHub = ReaderT (Maybe AuthToken) (StateT GitHubState (EitherT ServantError IO)) -- | You need to provide a 'Maybe AuthToken' to lift a GitHub -- computation into the IO monad. runGitHub :: GitHub a -> Maybe AuthToken -> IO (Either ServantError a) -- | GitHubState options that control which headers are provided to the API -- and stores the Link header result data GitHubState GitHubState :: Int -> Int -> Maybe [Link] -> Bool -> Text -> GitHubState -- | The number of records returned per page [perPage] :: GitHubState -> Int -- | The page number returned [page] :: GitHubState -> Int -- | Contains the returned Link header, if available. [links] :: GitHubState -> Maybe [Link] -- | Flag to set the recursive mode on [recurse] :: GitHubState -> Bool -- | Text to send as User-agent [useragent] :: GitHubState -> Text -- | This class defines how the client code is actually called. class HasGitHub a embedGitHub :: HasGitHub a => a -> EmbedGitHub a -- | Closed type family for recursively defining the GitHub client funciton -- types -- | Closed type family that adds standard headers to the incoming servant -- API type. The extra headers are put after any arguments types. -- | Closed type family that adds headers necessary for pagination. In -- particular, it captures the Link header from the response. -- | Client function that returns a single result type Single a = Maybe Text -> Maybe AuthToken -> EitherT ServantError IO a -- | Client function that returns a list of results, and is therefore -- paginated type Paginated a = Maybe Text -> Maybe AuthToken -> Maybe Int -> Maybe Int -> EitherT ServantError IO (Headers '[Header "Link" Text] [a]) -- | Overide default value for User-agent header. Note, GitHub requires -- that a User-agent header be set. setUserAgent :: Text -> GitHub () -- | Set next page back to 1, and remove the links resetPagination :: GitHub () -- | Turn automatic recusive behaviour on and off. -- -- If recursive is on, paginated results will be automatically followed -- and concated together. recurseOff :: GitHub () -- | Turn automatic recusive behaviour on and off. -- -- If recursive is on, paginated results will be automatically followed -- and concated together. recurseOn :: GitHub () -- | The default number of records per page is set to 100. Smaller pages -- can be set, but not bigger than 100. pageSize :: Int -> GitHub () -- | Return the Link header. This is only set when there are futher -- pages. getLinks :: GitHub (Maybe [Link]) instance GHC.Show.Show Network.GitHub.Client.GitHubState instance GHC.Classes.Eq Network.GitHub.Client.AuthToken instance Data.String.IsString Network.GitHub.Client.AuthToken instance Servant.Common.Text.ToText Network.GitHub.Client.AuthToken instance Network.GitHub.Client.HasGitHub (Network.GitHub.Client.Paginated a) instance Network.GitHub.Client.HasGitHub (Network.GitHub.Client.Single a) instance Network.GitHub.Client.HasGitHub (a -> Network.GitHub.Client.Single b) instance Network.GitHub.Client.HasGitHub (a -> b -> Network.GitHub.Client.Single c) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> Network.GitHub.Client.Single d) instance Network.GitHub.Client.HasGitHub (a -> Network.GitHub.Client.Paginated b) instance Network.GitHub.Client.HasGitHub (a -> b -> Network.GitHub.Client.Paginated c) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> Network.GitHub.Client.Paginated d) -- | Most of the types only parse part of the data availble in the return -- values from the GitHub API. These will be added to as required. module Network.GitHub.Types -- | Organisation data Organisation Organisation :: OrgLogin -> Int -> Maybe Text -> Organisation [orgLogin] :: Organisation -> OrgLogin [orgId] :: Organisation -> Int [orgDescription] :: Organisation -> Maybe Text -- | Primary identifier for an organisation is the login type OrgLogin = Text -- | Team data Team Team :: TeamId -> Text -> Maybe Text -> Maybe Text -> Team [teamId] :: Team -> TeamId [teamName] :: Team -> Text [teamDescription] :: Team -> Maybe Text [teamPermission] :: Team -> Maybe Text -- | Identifier for a team id type TeamId = Integer -- | Member data Member Member :: MemberId -> Text -> Member [memberId] :: Member -> MemberId [memberLogin] :: Member -> Text -- | members are identified by ids type MemberId = Integer -- | Repository data Repository Repository :: RepositoryName -> Maybe Text -> Bool -> Repository [repositoryName] :: Repository -> RepositoryName [repositoryDescription] :: Repository -> Maybe Text [repositoryPrivate] :: Repository -> Bool -- | repositories are identified by their name type RepositoryName = Text instance GHC.Show.Show Network.GitHub.Types.Repository instance GHC.Classes.Eq Network.GitHub.Types.Repository instance GHC.Show.Show Network.GitHub.Types.Member instance GHC.Classes.Eq Network.GitHub.Types.Member instance GHC.Show.Show Network.GitHub.Types.Team instance GHC.Classes.Eq Network.GitHub.Types.Team instance GHC.Show.Show Network.GitHub.Types.Organisation instance GHC.Classes.Eq Network.GitHub.Types.Organisation instance Data.Aeson.Types.Class.FromJSON Network.GitHub.Types.Organisation instance Data.Aeson.Types.Class.FromJSON Network.GitHub.Types.Team instance Data.Aeson.Types.Class.FromJSON Network.GitHub.Types.Member instance Data.Aeson.Types.Class.FromJSON Network.GitHub.Types.Repository module Network.GitHub.API -- | https://developer.github.com/v3/orgs/#list-your-organizations type UserOrganisations = "user" :> ("orgs" :> Get '[JSON] [Organisation]) -- | https://developer.github.com/v3/orgs/teams/#list-teams type OrganisationTeams = "orgs" :> (Capture "org" OrgLogin :> ("teams" :> Get '[JSON] [Team])) -- | https://developer.github.com/v3/orgs/teams/#list-team-members type TeamMembers = "teams" :> (Capture "id" TeamId :> ("members" :> Get '[JSON] [Member])) -- | https://developer.github.com/v3/orgs/teams/#list-team-repos type TeamRepositories = "teams" :> (Capture "id" TeamId :> ("repos" :> Get '[JSON] [Repository])) -- | https://developer.github.com/v3/orgs/teams/#get-team type GetTeam = "teams" :> (Capture "id" TeamId :> Get '[JSON] Team) -- | The GitHub monad provides support for: -- --