package ldp

  1. Overview
  2. Docs
val dbg : string -> unit Lwt.t

All functions performing queries may raise a 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.

val head : ?headers:Cohttp.Header.t -> Iri.t -> Types.meta Lwt.t

head iri performs a HEAD query on iri and returns response as a Ldp.Types.meta.

val get_non_rdf : ?headers:Cohttp.Header.t -> ?accept:Ct.mime list -> Iri.t -> (Ct.t * string) Lwt.t

get_non_rdf iri performs a GET query on iri and returns the content type and body of the response.

val get_rdf : ?g:Rdf.Graph.graph -> ?headers:Cohttp.Header.t -> ?accept:Ct.mime list -> ?parse:bool -> Iri.t -> (string * (Rdf.Graph.graph, Types.error) Stdlib.result option) 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_graph : ?g:Rdf.Graph.graph -> ?headers:Cohttp.Header.t -> ?accept:Ct.mime list -> Iri.t -> Rdf.Graph.graph 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_container : ?g:Rdf.Graph.graph -> ?headers:Cohttp.Header.t -> ?accept:Ct.mime list -> Iri.t -> Rdf.Graph.graph Lwt.t

Same as get_rdf_graph but may be enhanced in the future.

val get : ?headers:Cohttp.Header.t -> ?accept:Ct.mime list -> ?parse:bool -> Iri.t -> Types.resource 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 post : ?headers:Cohttp.Header.t -> ?data:string -> ?ct:Ct.t -> ?slug:string -> ?typ:Iri.t -> Iri.t -> Types.meta 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 is Ldp.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_container : ?headers:Cohttp.Header.t -> ?data:Rdf.Graph.graph -> ?slug:string -> Iri.t -> Types.meta 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_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 -> Types.meta 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_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 -> Types.meta 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_rdf : ?headers:Cohttp.Header.t -> ?data:Rdf.Graph.graph -> ?slug:string -> ?typ:Iri.t -> Iri.t -> Types.meta 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_non_rdf : ?headers:Cohttp.Header.t -> ?data:string -> ?ct:Ct.t -> Iri.t -> Types.meta Lwt.t

Same as post with optional typ set to Rdf.Ldp.c_NonRDFSource.

val put : ?headers:Cohttp.Header.t -> ?data:string -> ?ct:Ct.t -> ?typ:Iri.t -> Iri.t -> Types.meta 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_rdf : ?headers:Cohttp.Header.t -> data:Rdf.Graph.graph -> ?typ:Iri.t -> Iri.t -> Types.meta 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 patch_with_query : ?headers:Cohttp.Header.t -> Iri.t -> string -> unit Lwt.t

patch_with_query iri q performs a PATCH query at iri with q being a sparql query (represented as string).

val patch : ?headers:Cohttp.Header.t -> ?del:Rdf.Graph.graph -> ?ins:Rdf.Graph.graph -> Iri.t -> unit Lwt.t

patch iri performs a PATCH query at iri. Optional arguments:

  • del specifies triples to delete.
  • ins specifies triples to add.
val delete : ?headers:Cohttp.Header.t -> Iri.t -> unit Lwt.t

delete iri performs a DELETE query on iri.

val login : ?headers:Cohttp.Header.t -> Iri.t -> string option 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 fold_get : ?onerror:[ `Fail | `Ignore | `Report of exn -> unit Lwt.t ] -> ?headers:Cohttp.Header.t -> ?accept:Ct.mime list -> ?parse:bool -> ('a -> 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 ] -> ?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.

OCaml

Innovation. Community. Security.