Github.API
The API
module contains functionality that relates to the entirety of the GitHub API and these bindings. In particular, this module contains:
val code_handler : expected_code:Cohttp.Code.status_code -> 'a -> 'a handler
code_handler ~expected_code parse
is a response handler that fires for responses with status expected_code
and applies parse
.
val get : ?rate:rate -> ?fail_handlers:'a parse handler list -> ?expected_code:Cohttp.Code.status_code ->
?media_type:string -> ?headers:Cohttp.Header.t -> ?token:Token.t ->
?params:(string * string) list -> uri:Uri.t -> 'a parse -> 'a Response.t Monad.t
get ?rate ?fail_handlers ?expected_code ?headers ?token
?params uri p
is the p
-parsed response to a GitHub API HTTP GET request to uri
with extra query parameters params
and extra headers headers
. If token
is supplied, it will be used instead of any token bound into the monad. p
will only fire if the response status is expected_code
which defaults to 200 OK
. If the response status is not expected_code
, fail_handlers
, if any, will be checked in the order supplied. The rate
parameter determines which rate limit accounting regime will be used for caching rate limit values in response headers.
val get_stream : ?rate:rate -> ?fail_handlers:'a Stream.parse handler list ->
?expected_code:Cohttp.Code.status_code -> ?media_type:string -> ?headers:Cohttp.Header.t ->
?token:Token.t -> ?params:(string * string) list -> uri:Uri.t -> 'a Stream.parse -> 'a Stream.t
get_stream uri stream_p
is the Stream.t
encapsulating lazy stream_p
-parsed responses to GitHub API HTTP GET requests to uri
and its successors. For an explanation of the other parameters, see get
.
val post : ?rate:rate -> ?fail_handlers:'a parse handler list -> expected_code:Cohttp.Code.status_code ->
?headers:Cohttp.Header.t -> ?body:string -> ?token:Token.t -> ?params:(string * string) list ->
uri:Uri.t -> 'a parse -> 'a Response.t Monad.t
post uri p
is the p
-parsed response to a GitHub API HTTP POST request to uri
. For an explanation of the other parameters, see get
.
val delete : ?rate:rate -> ?fail_handlers:'a parse handler list ->
?expected_code:Cohttp.Code.status_code -> ?headers:Cohttp.Header.t -> ?token:Token.t ->
?params:(string * string) list -> uri:Uri.t -> 'a parse -> 'a Response.t Monad.t
delete uri p
is the p
-parsed response to a GitHub API HTTP DELETE request to uri
. For an explanation of the other parameters, see get
.
val patch : ?rate:rate -> ?fail_handlers:'a parse handler list -> expected_code:Cohttp.Code.status_code
-> ?headers:Cohttp.Header.t -> ?body:string -> ?token:Token.t -> ?params:(string * string) list ->
uri:Uri.t -> 'a parse -> 'a Response.t Monad.t
patch uri p
is the p
-parsed response to a GitHub API HTTP PATCH request to uri
. For an explanation of the other parameters, see get
.
val put : ?rate:rate -> ?fail_handlers:'a parse handler list -> expected_code:Cohttp.Code.status_code ->
?headers:Cohttp.Header.t -> ?body:string -> ?token:Token.t -> ?params:(string * string) list ->
uri:Uri.t -> 'a parse -> 'a Response.t Monad.t
put uri p
is the p
-parsed response to a GitHub API HTTP PUT request to uri
. For an explanation of the other parameters, see get
.
val set_user_agent : string -> unit Monad.t
set_user_agent ua
contains monadic state that will cause bound requests to use the User-Agent
header value of ua
.
set_token token
contains monadic state that will cause bound requests to use token
for authentication by default. This function enables the creation of large, generic monadic compositions that do not have to be parameterized by authentication token.
val get_rate : ?rate:rate -> ?token:Token.t -> unit -> Github_t.rate Monad.t
get_rate ?rate ()
is the, possibly cached, rate limit information for the rate limit regime ?rate
(default Core
).
get_rate_limit ()
is the, possibly cached, Core
total request quota for the current token.
get_rate_remaining ()
is the, possibly cached, Core
remaining request quota for the current token.
get_rate_reset ()
is the, possibly cached, Core
UNIX epoch expiry time (s) when the remaining request quota will be reset to the total request quota for the current token.
val string_of_message : Github_t.message -> string
string_of_message message
is the English language error message that GitHub generated in message
.