-- 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.6 -- | 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 -- | List of results including a total count data CountedList (name :: Symbol) a CountedList :: Int -> [a] -> CountedList a [totalCount] :: CountedList a -> Int [items] :: CountedList a -> [a] -- | Organisation data Organisation Organisation :: OrgLogin -> Int -> Maybe Text -> Organisation [orgLogin] :: Organisation -> OrgLogin [orgId] :: Organisation -> Int [orgDescription] :: Organisation -> Maybe Text -- | OrganisationMember data OrganisationMember OrganisationMember :: Text -> Text -> Organisation -> Member -> OrganisationMember [orgmemberRole] :: OrganisationMember -> Text [orgmemberState] :: OrganisationMember -> Text [orgmemberOrganisation] :: OrganisationMember -> Organisation [orgmemberUser] :: OrganisationMember -> Member -- | Primary identifier for an organisation is the login type OrgLogin = Text type Owner = Text newtype UserLogin UserLogin :: Text -> UserLogin -- | 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 -> Maybe Text -> Bool -> Maybe Permission -> Repository [repositoryName] :: Repository -> RepositoryName [repositoryDescription] :: Repository -> Maybe Text [repositoryDefaultBranch] :: Repository -> Maybe Text [repositoryPrivate] :: Repository -> Bool [repositoryPermissions] :: Repository -> Maybe Permission -- | Repositories type Repositories = CountedList "repositories" Repository data Permission Push :: Permission Pull :: Permission Admin :: Permission -- | repositories are identified by their name type RepositoryName = Text -- | Organisation data User User :: Text -> Int -> Maybe Text -> Maybe Text -> Maybe Text -> User [userLogin] :: User -> Text [userId] :: User -> Int [userName] :: User -> Maybe Text [userCompany] :: User -> Maybe Text [userEmail] :: User -> Maybe Text -- | Commit type RepoName = Text type Sha = Text data Commit Commit :: Text -> Text -> Commit [commitMessage] :: Commit -> Text [commitUrl] :: Commit -> Text -- | Content data Content Content :: Text -> Text -> Int -> Text -> Text -> Text -> Content [contentType] :: Content -> Text [contentEncoding] :: Content -> Text [contentSize] :: Content -> Int [contentName] :: Content -> Text [contentPath] :: Content -> Text [contentContent] :: Content -> Text -- | Issue data Issue Issue :: Int -> Text -> Text -> Text -> Text -> UserLogin -> Maybe UserLogin -> Maybe Milestone -> [Label] -> Bool -> Int -> UTCTime -> UTCTime -> Maybe UTCTime -> Issue [issueNumber] :: Issue -> Int [issueUrl] :: Issue -> Text [issueState] :: Issue -> Text [issueTitle] :: Issue -> Text [issueBody] :: Issue -> Text [issueUser] :: Issue -> UserLogin [issueAssignee] :: Issue -> Maybe UserLogin [issueMilestone] :: Issue -> Maybe Milestone [issueLabels] :: Issue -> [Label] [issueLocked] :: Issue -> Bool [issueComments] :: Issue -> Int [issueCreated] :: Issue -> UTCTime [issueUpdated] :: Issue -> UTCTime [issueClosed] :: Issue -> Maybe UTCTime newtype Label Label :: Text -> Label data Milestone Milestone :: Int -> Text -> Text -> Maybe Text -> UserLogin -> Int -> Int -> UTCTime -> Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime -> Milestone [milestoneNumber] :: Milestone -> Int [milestoneState] :: Milestone -> Text [milestoneTitle] :: Milestone -> Text [milestoneDescripiton] :: Milestone -> Maybe Text [milestoneCreator] :: Milestone -> UserLogin [milestoneOpenIssues] :: Milestone -> Int [milestoneClosedIssues] :: Milestone -> Int [milestoneCreated] :: Milestone -> UTCTime [milestoneUpdated] :: Milestone -> Maybe UTCTime [milestoneClosed] :: Milestone -> Maybe UTCTime [milestoneDueOn] :: Milestone -> Maybe UTCTime data EarlyAccessJSON -- | Installation data Installation Installation :: Int -> Int -> Int -> Text -> Installation [installationId] :: Installation -> Int [installationAppId] :: Installation -> Int [installationTargetId] :: Installation -> Int [installationTargetType] :: Installation -> Text -- | IntegrationInstallations type Installations = CountedList "integration_installations" Installation data InstallationAccessToken InstallationAccessToken :: Text -> InstallationAccessToken [token] :: InstallationAccessToken -> Text data InstallationUser InstallationUser :: Int -> InstallationUser [user_id] :: InstallationUser -> Int instance GHC.Generics.Generic Network.GitHub.Types.InstallationUser instance GHC.Show.Show Network.GitHub.Types.InstallationUser instance GHC.Classes.Eq Network.GitHub.Types.InstallationUser instance GHC.Generics.Generic Network.GitHub.Types.InstallationAccessToken instance GHC.Show.Show Network.GitHub.Types.InstallationAccessToken instance GHC.Classes.Eq Network.GitHub.Types.InstallationAccessToken instance GHC.Show.Show Network.GitHub.Types.Installation instance GHC.Classes.Eq Network.GitHub.Types.Installation instance GHC.Show.Show Network.GitHub.Types.Issue instance GHC.Classes.Eq Network.GitHub.Types.Issue instance GHC.Generics.Generic Network.GitHub.Types.Issue instance GHC.Show.Show Network.GitHub.Types.Label instance GHC.Classes.Eq Network.GitHub.Types.Label instance GHC.Classes.Eq Network.GitHub.Types.Milestone instance GHC.Show.Show Network.GitHub.Types.Milestone instance GHC.Classes.Eq Network.GitHub.Types.UserLogin instance GHC.Show.Show Network.GitHub.Types.UserLogin instance GHC.Show.Show Network.GitHub.Types.Content instance GHC.Classes.Eq Network.GitHub.Types.Content instance GHC.Show.Show Network.GitHub.Types.Commit instance GHC.Classes.Eq Network.GitHub.Types.Commit instance GHC.Show.Show Network.GitHub.Types.User instance GHC.Classes.Eq Network.GitHub.Types.User instance GHC.Show.Show Network.GitHub.Types.Repository instance GHC.Classes.Eq Network.GitHub.Types.Repository instance GHC.Classes.Eq Network.GitHub.Types.Permission instance GHC.Show.Show Network.GitHub.Types.OrganisationMember instance GHC.Classes.Eq Network.GitHub.Types.OrganisationMember 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.FromJSON.FromJSON a, GHC.TypeLits.KnownSymbol name) => Data.Aeson.Types.FromJSON.FromJSON (Network.GitHub.Types.CountedList name a) instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Organisation instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Team instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Member instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.OrganisationMember instance GHC.Show.Show Network.GitHub.Types.Permission instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Permission instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Repository instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.User instance Data.Aeson.Types.ToJSON.ToJSON Network.GitHub.Types.User instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Commit instance Data.Aeson.Types.ToJSON.ToJSON Network.GitHub.Types.Commit instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Content instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.UserLogin instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Milestone instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Label instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Issue instance Data.Aeson.Types.FromJSON.FromJSON t => Servant.API.ContentTypes.MimeUnrender Network.GitHub.Types.EarlyAccessJSON t instance Servant.API.ContentTypes.Accept Network.GitHub.Types.EarlyAccessJSON instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.Installation instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.InstallationAccessToken instance Data.Aeson.Types.ToJSON.ToJSON Network.GitHub.Types.InstallationAccessToken instance Data.Aeson.Types.FromJSON.FromJSON Network.GitHub.Types.InstallationUser instance Data.Aeson.Types.ToJSON.ToJSON Network.GitHub.Types.InstallationUser 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 ClientM) runGitHubClientM :: ClientM a -> IO (Either ServantError a) -- | Most of the time we must use api.github.com, but calling -- loginoauthaccess_token only works if sent to github.com. runGitHubNotApiClientM :: ClientM a -> IO (Either ServantError a) runGitHub' :: GitHub a -> Maybe AuthToken -> ClientM a -- | 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 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 -> ClientM a -- | Client function that returns a list of results, and is therefore -- paginated type Paginated a = Maybe Text -> Maybe AuthToken -> Maybe Int -> Maybe Int -> ClientM (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.Classes.Eq Network.GitHub.Client.AuthToken instance Data.String.IsString Network.GitHub.Client.AuthToken instance Web.Internal.HttpApiData.ToHttpApiData Network.GitHub.Client.AuthToken instance Network.GitHub.Client.HasGitHub (Network.GitHub.Client.Paginated a) instance Network.GitHub.Client.HasGitHub (Network.GitHub.Client.CountedPaginated name 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 -> b -> c -> d -> Network.GitHub.Client.Single e) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> Network.GitHub.Client.Single f) 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) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> Network.GitHub.Client.Paginated e) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> Network.GitHub.Client.Paginated f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> Network.GitHub.Client.Paginated f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> Network.GitHub.Client.Paginated f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> Network.GitHub.Client.Paginated f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> k -> Network.GitHub.Client.Paginated f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> k -> l -> Network.GitHub.Client.Paginated f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> k -> l -> m -> Network.GitHub.Client.Paginated f) instance Network.GitHub.Client.HasGitHub (a -> Network.GitHub.Client.CountedPaginated name b) instance Network.GitHub.Client.HasGitHub (a -> b -> Network.GitHub.Client.CountedPaginated name c) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> Network.GitHub.Client.CountedPaginated name d) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> Network.GitHub.Client.CountedPaginated name e) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> Network.GitHub.Client.CountedPaginated name f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> Network.GitHub.Client.CountedPaginated name f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> Network.GitHub.Client.CountedPaginated name f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> Network.GitHub.Client.CountedPaginated name f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> k -> Network.GitHub.Client.CountedPaginated name f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> k -> l -> Network.GitHub.Client.CountedPaginated name f) instance Network.GitHub.Client.HasGitHub (a -> b -> c -> d -> e -> g -> h -> i -> k -> l -> m -> Network.GitHub.Client.CountedPaginated name f) 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/members/#list-your-organization-memberships type UserOrganisationMemberships = "user" :> ("memberships" :> ("orgs" :> Get '[JSON] [OrganisationMember])) -- | 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) -- | -- https://developer.github.com/v3/users/#get-the-authenticated-user type GetUser = "user" :> Get '[JSON] User -- | https://developer.github.com/v3/users/#get-a-single-user type GetUserByLogin = "user" :> (QueryParam "username" String :> Get '[JSON] User) -- | https://developer.github.com/v3/repos/#list-your-repositories type UserRepositories = "user" :> ("repos" :> (QueryParam "type" String :> Get '[JSON] [Repository])) -- | -- https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation type UserInstallationRepositories = "user" :> ("installations" :> (Capture "installation_id" Int :> ("repositories" :> Get '[EarlyAccessJSON] Repositories))) -- | -- https://developer.github.com/v3/repos/#list-organization-repositories type OrganisationRepositories = "orgs" :> (Capture "org" OrgLogin :> ("repos" :> Get '[JSON] [Repository])) -- | -- https://developer.github.com/early-access/integrations/integrations-vs-oauth-applications/#repository-discovery type InstallationRepositories = "installation" :> ("repositories" :> Get '[EarlyAccessJSON] Repositories) -- | https://developer.github.com/v3/apps/#find-installations type AppInstallations = "app" :> ("installations" :> Get '[EarlyAccessJSON] [Installation]) -- | -- https://developer.github.com/v3/apps/#list-installations-for-user type UserInstallations = "user" :> ("installations" :> (QueryParam "access_token" String :> Get '[EarlyAccessJSON] Installations)) -- | -- https://developer.github.com/v3/repos/collaborators/#list-collaborators type RepositoryCollaborators = "repos" :> (Capture "org" OrgLogin :> (Capture "repo" RepoName :> ("collaborators" :> Get '[JSON] [Member]))) -- | -- https://developer.github.com/v3/repos/commits/#get-a-single-commit type GetCommit = "repos" :> (Capture "org" OrgLogin :> (Capture "repo" RepoName :> ("commits" :> (Capture "sha" Sha :> Get '[JSON] Commit)))) -- | https://developer.github.com/v3/repos/contents/#get-contents -- GET repos:owner:repocontents/:path type GetContent = "repos" :> (Capture "org" OrgLogin :> (Capture "repo" RepoName :> ("contents" :> (Capture "path" String :> (QueryParam "ref" String :> (QueryParam "path" String :> Get '[JSON] Content)))))) -- | -- https://developer.github.com/v3/issues/#list-issues-for-a-repository -- GET repos:owner:repoissues type GetIssues = "repos" :> (Capture "owner" Owner :> (Capture "repo" RepoName :> ("issues" :> (QueryParam "milestone" String :> (QueryParam "state" String :> (QueryParam "assignee" String :> (QueryParam "creator" String :> (QueryParam "mentioned" String :> (QueryParam "labels" String :> (QueryParam "sort" String :> (QueryParam "direction" String :> (QueryParam "since" String :> Get '[JSON] [Issue])))))))))))) type ReqInstallationAccessToken = "installations" :> (Capture "installation_id" Int :> ("access_tokens" :> (Header "User-Agent" String :> (Header "Authorization" String :> (ReqBody '[JSON] (Maybe InstallationUser) :> Post '[EarlyAccessJSON] InstallationAccessToken))))) -- | The GitHub monad provides support for: -- --