Note

This is a public alpha release, and therefore features and functionality may change and the software and documentation may contain technical bugs or other issues. If you discover any issues please consider registering a GitHub issue.

api.views.datasources module

This module contains the API endpoint viewset defining the PEDASI Application API.

class api.views.datasources.DataSourceApiViewset(**kwargs)[source]

Bases: rest_framework.viewsets.ReadOnlyModelViewSet

Provides views for:

/api/datasources/
List all datasources.models.DataSources.
/api/datasources/<int>/
Retrieve a single datasources.models.DataSource.
/api/datasources/<int>/quality/
Get the quality level of a datasources.models.DataSource using the current ruleset.
/api/datasources/<int>/prov/
Retrieve PROV records related to a datasources.models.DataSource.
/api/datasources/<int>/metadata/
Retrieve datasources.models.DataSource metadata via API call to data source URL.
/api/datasources/<int>/data/
Retrieve datasources.models.DataSource data via API call to data source URL.
/api/datasources/<int>/datasets/
Retrieve datasources.models.DataSource list of data sets via API call to data source URL.
/api/datasources/<int>/datasets/<href>/metadata/
Retrieve datasources.models.DataSource metadata for a single dataset via API call to data source URL.
/api/datasources/<int>/datasets/<href>/metadata/
Retrieve datasources.models.DataSource data for a single dataset via API call to data source URL.
data(request, pk=None)[source]

View for /api/datasources/<int>/data/

Retrieve DataSource data via API call to data source URL.

dataset_data(request, pk=None, **kwargs)[source]

View for /api/datasources/<int>/datasets/<href>/data/

Retrieve DataSource data for a single dataset via API call to data source URL.

dataset_metadata(request, pk=None, **kwargs)[source]

View for /api/datasources/<int>/datasets/<href>/metadata/

Retrieve DataSource metadata for a single dataset via API call to data source URL.

datasets(request, pk=None)[source]

View for /api/datasources/<int>/datasets/

Retrieve DataSource list of data sets via API call to data source URL.

list(request, *args, **kwargs)[source]

List the queryset after filtering by request query parameters for data source metadata.

metadata(request, pk=None)[source]

View for /api/datasources/<int>/metadata/

Retrieve DataSource metadata via API call to data source URL.

permission_classes = [<class 'api.permissions.ViewPermission'>]
post_data(request: rest_framework.request.Request, pk=None)[source]

Add data to this data source. Only applicable to internal data sources.

Data can be added either as JSON body text or as a POSTed CSV file.

prov(request, pk=None)[source]

View for /api/datasources/<int>/prov/

Retrieve PROV records related to a DataSource.

put_data(request: rest_framework.request.Request, pk=None)[source]
quality(request, pk=None)[source]

View for /api/datasources/<int>/quality/

Get the quality level of a data source using the current ruleset.

queryset
serializer_class

alias of datasources.serializers.DataSourceSerializer

try_passthrough_response(map_response: Callable[[...], django.http.response.HttpResponse], error_message: str, dataset: str = None) → django.http.response.HttpResponse[source]

Attempt to pass a response from the data connector using the function map_response.

If the data connectors raises an error (AttributeError, DatasetNotFoundError or NotImplementedError) then return an error response.

Parameters:
  • map_response – Function to get response from data connector - must return HttpResponse
  • error_message – Error message in case data connector raises an error
  • dataset – Dataset to access within data source
Returns:

HttpResponse from data connector or error response

class api.views.datasources.MetadataItemApiViewset(**kwargs)[source]

Bases: rest_framework.viewsets.ModelViewSet

API ViewSet for viewing and managing dynamic metadata items on a data sources.

get_datasource()[source]
get_queryset()[source]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

perform_create(serializer)[source]
permission_classes = [<class 'api.permissions.IsOwnerOrReadOnly'>]
serializer_class

alias of datasources.serializers.MetadataItemSerializer