From fd59efa1a16b3291c929645e8b80b6fa238de806 Mon Sep 17 00:00:00 2001 From: DPeterK Date: Fri, 21 Jan 2022 16:54:49 +0000 Subject: [PATCH 1/2] Initial code commit --- edr_data_interface/__init__.py | 0 edr_data_interface/abstract/__init__.py | 0 edr_data_interface/abstract/capabilities.py | 21 +++++++++++ edr_data_interface/abstract/core.py | 3 ++ edr_data_interface/concrete/__init__.py | 0 edr_data_interface/concrete/dummy/__init__.py | 1 + .../concrete/dummy/capabilities.py | 35 +++++++++++++++++++ 7 files changed, 60 insertions(+) create mode 100644 edr_data_interface/__init__.py create mode 100644 edr_data_interface/abstract/__init__.py create mode 100644 edr_data_interface/abstract/capabilities.py create mode 100644 edr_data_interface/abstract/core.py create mode 100644 edr_data_interface/concrete/__init__.py create mode 100644 edr_data_interface/concrete/dummy/__init__.py create mode 100644 edr_data_interface/concrete/dummy/capabilities.py diff --git a/edr_data_interface/__init__.py b/edr_data_interface/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/edr_data_interface/abstract/__init__.py b/edr_data_interface/abstract/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/edr_data_interface/abstract/capabilities.py b/edr_data_interface/abstract/capabilities.py new file mode 100644 index 0000000..dc23883 --- /dev/null +++ b/edr_data_interface/abstract/capabilities.py @@ -0,0 +1,21 @@ +from .core import Interface + + +class API(Interface): + pass + + +class Capabilities(Interface): + def __init__( + self, + api_link_href: str, + collections_link_href: str, + conformance_link_href: str, + ) -> None: + self.api_link_href = api_link_href + self.collections_link_href = collections_link_href + self.conformance_link_href = conformance_link_href + + +class Conformance(Interface): + pass \ No newline at end of file diff --git a/edr_data_interface/abstract/core.py b/edr_data_interface/abstract/core.py new file mode 100644 index 0000000..77a9f35 --- /dev/null +++ b/edr_data_interface/abstract/core.py @@ -0,0 +1,3 @@ +class Interface(object): + def data(self): + raise NotImplemented \ No newline at end of file diff --git a/edr_data_interface/concrete/__init__.py b/edr_data_interface/concrete/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/edr_data_interface/concrete/dummy/__init__.py b/edr_data_interface/concrete/dummy/__init__.py new file mode 100644 index 0000000..3fdc92d --- /dev/null +++ b/edr_data_interface/concrete/dummy/__init__.py @@ -0,0 +1 @@ +from .capabilities import API, Capabilities, Conformance \ No newline at end of file diff --git a/edr_data_interface/concrete/dummy/capabilities.py b/edr_data_interface/concrete/dummy/capabilities.py new file mode 100644 index 0000000..d87537e --- /dev/null +++ b/edr_data_interface/concrete/dummy/capabilities.py @@ -0,0 +1,35 @@ +from ...abstract.capabilities import API, Capabilities, Conformance + + +class API(API): + def data(self): + return None + + +class Capabilities(Capabilities): + def data(self): + return { + "title": "A dummy example", + "description": "This is a dummy example of templating a capabilities request.", + "links_api_href": self.api_link_href, + "links_conformance_href": self.conformance_link_href, + "links_collections_href": self.collections_link_href, + "keywords": ["Example", "Dummy"], + "provider_name": "Galadriel", + "provider_url": None, + "contact_email": "dummy@example.com", + "contact_phone": "07987 654321", + "contact_fax": None, + "contact_hours": "9 til 5", + "contact_instructions": "Don't", + "contact_address": "Over there", + "contact_postcode": "ZZ99 9ZZ", + "contact_city": "Neverland", + "contact_state": "", + "contact_country": "Wakanda", + } + + +class Conformance(Conformance): + def data(self): + return ["example", "dummy"] From 2b3a27a5cc31b0a94e89f9a30c7c96c00409f213 Mon Sep 17 00:00:00 2001 From: DPeterK Date: Fri, 21 Jan 2022 17:06:29 +0000 Subject: [PATCH 2/2] Populate readme --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0851a04..37f61f7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ # EDRDataInterface -The interface between `edr_server` and real-world datasets that you wish to serve. +The interface between [`edr_server`](https://github.com/ADAQ-AQI/edr-server) and real-world datasets that you wish to serve. + +## Overview + +This is an interface between real-world datasets that you wish to serve using EDR, and the abstract implementation of a server found in [`edr_server`](https://github.com/ADAQ-AQI/edr-server). The interface presents an abstract reference implementation for the interface (including any common functionality for the interface), and a single concrete implementation (called `dummy`). This demonstrates how the interface could be used in practice to represent your data. + +## Using it + +Duplicate the `dummy` implementation and customise it to connect to and serve your data. In [`edr_server`](https://github.com/ADAQ-AQI/edr-server), specify the name of your concrete implementation in [`config.yml`](https://github.com/ADAQ-AQI/edr-server/blob/main/etc/config.yml) in the entry `data.interface.name`.