package activitypub_client
Library
Module
Module type
Parameter
Class
Class type
val conf : Conf.t
val actor_conf : Conf.actor
val actor_iri : Iri.t
include Ldp.Http.Http
val dbg : string -> unit Lwt.t
All *_exn
functions performing queries may raise a Ldp.Types.Error
exception. Other query functions may raise such an exception if they only return Ok ...
or Error query_error
. Functions returning Ok ...
or Error Types.error
should not raise Ldp.Types.Error
exception.
The optional headers
parameter is used to specify headers of the query. The optional accept
parameter, when allowed, can be used to specify the accepted format of the response body. If specified, it is added to the headers of the query.
The optional follow
parameter for some functions is used to specify how many redirections (i.e. response with 3XX HTTP code) to follow. Default is 1
.
val head :
?follow:int ->
?headers:Cohttp.Header.t ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
head iri
performs a HEAD query on iri
and returns response as a Ldp.Types.meta
.
val head_exn :
?follow:int ->
?headers:Cohttp.Header.t ->
Iri.t ->
Ldp.Types.meta Lwt.t
val get_non_rdf :
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
Iri.t ->
(Ldp.Ct.t * string, Ldp.Http.query_error) Stdlib.result Lwt.t
get_non_rdf iri
performs a GET query on iri
and returns the content type and body of the response. follow
parameter defaults to 1 and indicate the number of redirections to follow (HTTP code 302 or 302).
val get_non_rdf_exn :
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
Iri.t ->
(Ldp.Ct.t * string) Lwt.t
val get_rdf :
?g:Rdf.Graph.graph ->
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
?parse:bool ->
Iri.t ->
(string * Rdf.Graph.graph option, Ldp.Types.error) Stdlib.result Lwt.t
get_rdf iri
retrieves a RDF resource at iri
. A graph is returned only if optional argument parse
is true
(default is false
if no graph is given, else true
). An existing graph can be given with optional argument g
. If so, and if contents must be parsed, this graph is filled by parsing the response contents. Else a new graph is created, with iri
as name.
val get_rdf_exn :
?g:Rdf.Graph.graph ->
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
?parse:bool ->
Iri.t ->
(string * Rdf.Graph.graph option) Lwt.t
val get_rdf_graph :
?g:Rdf.Graph.graph ->
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
Iri.t ->
(Rdf.Graph.graph, Ldp.Types.error) Stdlib.result Lwt.t
Same as get_rdf
but always parse the response contents to return the graph at iri
(of fill the graph given as g
argument).
val get_rdf_graph_exn :
?g:Rdf.Graph.graph ->
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
Iri.t ->
Rdf.Graph.graph Lwt.t
val get_container :
?g:Rdf.Graph.graph ->
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
Iri.t ->
(Rdf.Graph.graph, Ldp.Types.error) Stdlib.result Lwt.t
Same as get_rdf_graph
but may be enhanced in the future.
val get_container_exn :
?g:Rdf.Graph.graph ->
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
Iri.t ->
Rdf.Graph.graph Lwt.t
val get :
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
?parse:bool ->
Iri.t ->
(Ldp.Types.resource, Ldp.Types.error) Stdlib.result Lwt.t
get iri
returns the resource at iri
. Optional argument parse
(default: true
) indicates whether response contents must be parsed or not, when response content-type is text/turtle
or application/rdf+xml
. If response is not a graph or is not parsed, a non-rdf resource is returned. Else if graph is a container, a container resource is returned, else a rdf resource is returned.
val get_exn :
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
?parse:bool ->
Iri.t ->
Ldp.Types.resource Lwt.t
val post :
?headers:Cohttp.Header.t ->
?data:string ->
?ct:Ldp.Ct.t ->
?slug:string ->
?typ:Iri.t ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
post iri
performs a POST query at iri
and returns the response information. Specific optional arguments are:
data
is the body of the query, i.e. the posted data.ct
is the content-type of the posted-data. Default isLdp.Ct.ct_turtle
.slug
is used to suggest the URI of the created resource.typ
indicates the type iri of the created resource.
val post_exn :
?headers:Cohttp.Header.t ->
?data:string ->
?ct:Ldp.Ct.t ->
?slug:string ->
?typ:Iri.t ->
Iri.t ->
Ldp.Types.meta Lwt.t
val post_container :
?headers:Cohttp.Header.t ->
?data:Rdf.Graph.graph ->
?slug:string ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
Same as post
but specialized to post a new container. The optional data
is a graph, and the type iri of the created resource is set to Rdf.Ldp.c_BasicContainer
.
val post_container_exn :
?headers:Cohttp.Header.t ->
?data:Rdf.Graph.graph ->
?slug:string ->
Iri.t ->
Ldp.Types.meta Lwt.t
val post_direct_container :
?headers:Cohttp.Header.t ->
?data:Rdf.Graph.graph ->
?slug:string ->
?membershipResource:Iri.t ->
relation:[< `HasMember of Iri.t | `IsMemberOf of Iri.t ] ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
Same as post_container
but specialized to post a direct container. The type iri of the created resource is set to Rdf.Ldp.c_DirectContainer
.
val post_direct_container_exn :
?headers:Cohttp.Header.t ->
?data:Rdf.Graph.graph ->
?slug:string ->
?membershipResource:Iri.t ->
relation:[< `HasMember of Iri.t | `IsMemberOf of Iri.t ] ->
Iri.t ->
Ldp.Types.meta Lwt.t
val post_indirect_container :
?headers:Cohttp.Header.t ->
?data:Rdf.Graph.graph ->
?slug:string ->
?membershipResource:Iri.t ->
relation:[< `HasMember of Iri.t | `IsMemberOf of Iri.t ] ->
insertedContent:Iri.t ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
Same as post_container
but specialized to post a indirect container. The type iri of the created resource is set to Rdf.Ldp.c_IndirectContainer
.
val post_indirect_container_exn :
?headers:Cohttp.Header.t ->
?data:Rdf.Graph.graph ->
?slug:string ->
?membershipResource:Iri.t ->
relation:[< `HasMember of Iri.t | `IsMemberOf of Iri.t ] ->
insertedContent:Iri.t ->
Iri.t ->
Ldp.Types.meta Lwt.t
val post_rdf :
?headers:Cohttp.Header.t ->
?data:Rdf.Graph.graph ->
?slug:string ->
?typ:Iri.t ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
Same as post
but optional data is specified as a rdf graph, represented as text/turtle
in the query. Default typ
is Rdf.Ldp.c_RDFSource
.
val post_rdf_exn :
?headers:Cohttp.Header.t ->
?data:Rdf.Graph.graph ->
?slug:string ->
?typ:Iri.t ->
Iri.t ->
Ldp.Types.meta Lwt.t
val post_non_rdf :
?headers:Cohttp.Header.t ->
?data:string ->
?ct:Ldp.Ct.t ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
Same as post
with optional typ
set to Rdf.Ldp.c_NonRDFSource
.
val post_non_rdf_exn :
?headers:Cohttp.Header.t ->
?data:string ->
?ct:Ldp.Ct.t ->
Iri.t ->
Ldp.Types.meta Lwt.t
val put :
?headers:Cohttp.Header.t ->
?data:string ->
?ct:Ldp.Ct.t ->
?typ:Iri.t ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
put iri
performs a PUT query at iri
. data
is the body of the query. Default content-type ct
is text/turtle
. Default typ
is Rdf.Ldp.c_nonRdfSource
.
val put_exn :
?headers:Cohttp.Header.t ->
?data:string ->
?ct:Ldp.Ct.t ->
?typ:Iri.t ->
Iri.t ->
Ldp.Types.meta Lwt.t
val put_rdf :
?headers:Cohttp.Header.t ->
data:Rdf.Graph.graph ->
?typ:Iri.t ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
Same as put
for data is specified as a rdf graph, represented as text/turtle
in the query and default typ
is Rdf.Ldp.c_RDFSource
.
val put_rdf_exn :
?headers:Cohttp.Header.t ->
data:Rdf.Graph.graph ->
?typ:Iri.t ->
Iri.t ->
Ldp.Types.meta Lwt.t
val patch_with_query :
?headers:Cohttp.Header.t ->
Iri.t ->
string ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
patch_with_query iri q
performs a PATCH query at iri
with q
being a sparql query (represented as string).
val patch_with_query_exn :
?headers:Cohttp.Header.t ->
Iri.t ->
string ->
Ldp.Types.meta Lwt.t
val patch :
?headers:Cohttp.Header.t ->
?del:Rdf.Graph.graph ->
?ins:Rdf.Graph.graph ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
patch iri
performs a PATCH query at iri
. Optional arguments:
del
specifies triples to delete.ins
specifies triples to add.
val patch_exn :
?headers:Cohttp.Header.t ->
?del:Rdf.Graph.graph ->
?ins:Rdf.Graph.graph ->
Iri.t ->
Ldp.Types.meta Lwt.t
val delete :
?headers:Cohttp.Header.t ->
Iri.t ->
(Ldp.Types.meta, Ldp.Http.query_error) Stdlib.result Lwt.t
delete iri
performs a DELETE query on iri
.
val delete_exn : ?headers:Cohttp.Header.t -> Iri.t -> Ldp.Types.meta Lwt.t
val login :
?headers:Cohttp.Header.t ->
Iri.t ->
(string option, Ldp.Http.query_error) Stdlib.result Lwt.t
login ?headers iri
performs a HEAD query on iri
to authenticate and returns the user login (the user
field of the Ldp.Types.meta
structure returned by head
.
val login_exn : ?headers:Cohttp.Header.t -> Iri.t -> string option Lwt.t
val fold_get :
?onerror:[ `Fail | `Ignore | `Report of exn -> unit Lwt.t ] ->
?follow:int ->
?headers:Cohttp.Header.t ->
?accept:Ldp.Ct.t list ->
?parse:bool ->
('a -> Ldp.Types.resource -> 'a Lwt.t) ->
'a ->
Iri.t list ->
'a Lwt.t
fold_get iris
performs GET queries on each IRI of iris
, acting like fold_left
. See get
for argument parse
. The optional argument onerror
specified what to do in case of error. Default is to fail (`Fail
), but is is possible to ignore errors (`Ignore
) or provide a function called on the raised exception (`Report f
).
val fold_get_graph :
?onerror:[ `Fail | `Ignore | `Report of exn -> unit Lwt.t ] ->
?follow:int ->
?headers:Cohttp.Header.t ->
Rdf.Graph.graph ->
Iri.t list ->
unit Lwt.t
fold_get_graph g iris
performs GET queries on each IRI of iris
and merge each retrieved graph into g
. If a retrieved resource is not a RDF resource, it is ignored. See fold_get
for optional argument onerror
.