Copyright | (c) Finlay Thompson 2015 |
---|---|
License | BSD3 |
Maintainer | finlay.thompson@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
- github :: (HasClient (AddHeaders api), HasGitHub (Client (AddHeaders api))) => Proxy api -> EmbedGitHub (Client (AddHeaders api))
- data AuthToken
- 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 GitHubState = GitHubState {}
- class HasGitHub a where
- embedGitHub :: HasGitHub a => a -> EmbedGitHub a
- type family EmbedGitHub a :: * where ...
- type family AddHeaders a :: * where ...
- type family ReadHeaders a :: * where ...
- type Single a = Maybe Text -> Maybe AuthToken -> ClientM a
- type Paginated a = Maybe Text -> Maybe AuthToken -> Maybe Int -> Maybe Int -> ClientM (Headers '[Header "Link" Text] [a])
- setUserAgent :: Text -> GitHub ()
- resetPagination :: GitHub ()
- recurseOff :: GitHub ()
- recurseOn :: GitHub ()
- pageSize :: Int -> GitHub ()
- getLinks :: GitHub (Maybe [Link])
Documentation
github :: (HasClient (AddHeaders api), HasGitHub (Client (AddHeaders api))) => Proxy api -> EmbedGitHub (Client (AddHeaders api)) Source #
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 # | |
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.
data GitHubState Source #
GitHubState options that control which headers are provided to the API
and stores the Link
header result
class HasGitHub a where Source #
This class defines how the client code is actually called.
embedGitHub :: a -> EmbedGitHub a 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 # | |
embedGitHub :: HasGitHub a => a -> EmbedGitHub a Source #
type family EmbedGitHub a :: * where ... Source #
Closed type family for recursively defining the GitHub client funciton types
EmbedGitHub (Single a) = GitHub a | |
EmbedGitHub (Paginated a) = GitHub [a] | |
EmbedGitHub (CountedPaginated name a) = GitHub (CountedList name a) | |
EmbedGitHub (a -> b) = a -> EmbedGitHub b |
type family AddHeaders a :: * where ... Source #
Closed type family that adds standard headers to the incoming servant API type. The extra headers are put after any arguments types.
AddHeaders ((sym :: Symbol) :> last) = (sym :: Symbol) :> AddHeaders last | |
AddHeaders (first :> last) = first :> AddHeaders last | |
AddHeaders last = Header "User-Agent" Text :> (Header "Authorization" AuthToken :> ReadHeaders last) |
type family ReadHeaders a :: * where ... Source #
Closed type family that adds headers necessary for pagination. In particular, it captures the Link header from the response.
type Single a = Maybe Text -> Maybe AuthToken -> ClientM a Source #
Client function that returns a single result
type Paginated a = Maybe Text -> Maybe AuthToken -> Maybe Int -> Maybe Int -> ClientM (Headers '[Header "Link" Text] [a]) Source #
Client function that returns a list of results, and is therefore paginated
setUserAgent :: Text -> GitHub () Source #
Overide default value for User-agent header. Note, GitHub requires that a User-agent header be set.
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.