APIs

Client

class fdpclient.client.Client(host)[source]

Bases: object

The Client object to connect to a FAIR Data Point server.

FAIR Data Point server contains 4 types of metadata as described in the specification:

type

path

fdp

<host>/fdp or <host>

catalog

<host>/catalog

dataset

<host>/dataset

distribution

<host>/distribution

A server may use the host URL to store the ‘fdp’ metadata, and then the ‘fdp’ path is the same as the host.

Parameters

host (str) – the host URL

Examples

>>> client = Client('http://fdp.fairdatapoint.nl`)
>>> fdp_metadata = client.read_fdp()
>>> catalog_metadata = client.read_catalog('catalog01')
>>> print(fdp_metadata, catalog_metadata)
create_fdp(data, format='turtle', **kwargs)[source]

Create fdp metadata.

Parameters
  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

create_catalog(data, format='turtle', **kwargs)[source]

Create a new catalog metadata.

Parameters
  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

create_dataset(data, format='turtle', **kwargs)[source]

Create a new dataset metadata.

Parameters
  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

create_distribution(data, format='turtle', **kwargs)[source]

Create a new distribution metadata.

Parameters
  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

read_fdp(format='turtle', **kwargs)[source]

Read the fdp metadata.

Parameters
  • format (str, optional) – the format of the metadata. This argument overwrites the request header accept. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

Returns

rdflib.Graph – RDF graph of the requested metadata.

read_catalog(id, format='turtle', **kwargs)[source]

Read a catalog metadata.

Parameters
  • id (str) – the identifier of the metadata.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header accept. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

Returns

rdflib.Graph – RDF graph of the requested metadata.

read_dataset(id, format='turtle', **kwargs)[source]

Read a dataset metadata.

Parameters
  • id (str) – the identifier of the metadata.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header accept. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

Returns

rdflib.Graph – RDF graph of the requested metadata.

read_distribution(id, format='turtle', **kwargs)[source]

Read a distribution metadata.

Parameters
  • id (str) – the identifier of the metadata.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header accept. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

Returns

rdflib.Graph – RDF graph of the requested metadata.

update_fdp(data, format='turtle', **kwargs)[source]

Update the fdp metadata.

Parameters
  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

update_catalog(id, data, format='turtle', **kwargs)[source]

Update a catalog metadata.

Parameters
  • id (str) – the identifier of the metadata.

  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

update_dataset(id, data, format='turtle', **kwargs)[source]

Update a dataset metadata.

Parameters
  • id (str) – the identifier of the metadata.

  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

update_distribution(id, data, format='turtle', **kwargs)[source]

Update a distribution metadata.

Parameters
  • id (str) – the identifier of the metadata.

  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

delete_catalog(id, **kwargs)[source]

Delete a catalog metadata.

Parameters
  • id (str) – the identifier of the metadata.

  • **kwargs – Optional arguments that requests.request() takes.

delete_dataset(id, **kwargs)[source]

Delete a dataset metadata.

Parameters
  • id (str) – the identifier of the metadata.

  • **kwargs – Optional arguments that requests.request() takes.

delete_distribution(id, **kwargs)[source]

Delete a distribution metadata.

Parameters
  • id (str) – the identifier of the metadata.

  • **kwargs – Optional arguments that requests.request() takes.

_detect_fdp_url()[source]

Detect the internal path of fdp

Raises

RuntimeError – failed to find the fdp url

Returns

str – the internal path of fdp, i.e. ‘fdp’ or ‘’.

_request(operation, type, id=None, data=None, format='turtle', **kwargs)[source]

Private request method.

Parameters
  • operation (str) – the request operation. Available options: ‘read’, ‘write’, ‘update’ and ‘delete’. See fdpclient.operations.

  • type (str) – the type of metadata. Available types: ‘fdp’, ‘catalog’, ‘dataset’ and ‘distribution’.

  • id (str) – the identifier of the metadata. Defaults to None.

  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body. Defaults to None.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type or accept. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. See fdpclient.config.DATA_FORMATS. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

Returns

None or rdflib.Graph – RDF graph of the requested metadata.

Operations

fdpclient.operations.create(url, data, format='turtle', **kwargs)[source]

Send a create request.

Parameters
  • url (str) – URL for creating a metadata.

  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

fdpclient.operations.read(url, format='turtle', **kwargs)[source]

Send a read request.

Parameters
  • url (str) – URL for reading a metadata.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header accept. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

Returns

rdflib.Graph – RDF graph of the requested metadata.

fdpclient.operations.update(url, data, format='turtle', **kwargs)[source]

Send an update request.

Parameters
  • url (str) – URL for updating a metadata.

  • data (str, bytes, file-like object or rdflib.Graph) – the content of metadata to send in the request body.

  • format (str, optional) – the format of the metadata. This argument overwrites the request header content-type. Available options are ‘turtle’, ‘n3’, ‘nt’, ‘xml’ and ‘json-ld’. Defaults to ‘turtle’.

  • **kwargs – Optional arguments that requests.request() takes.

fdpclient.operations.delete(url, **kwargs)[source]

Send a delete request.

Parameters
  • url (str) – URL for deleting a metadata.

  • **kwargs – Optional arguments that requests.request() takes.

fdpclient.operations._check_data(data, format)[source]

Check input data type and convert Graph data to bytes

Global Variables

fdpclient.config.DATA_FORMATS = {'json-ld': 'application/ld+json', 'n3': 'text/n3', 'nt': 'application/n-triples', 'turtle': 'text/turtle', 'xml': 'application/rdf+xml'}

Metadata formats with corresponding content type