Skip to content
This repository has been archived by the owner on Oct 8, 2022. It is now read-only.

Commit

Permalink
update ServiceProvider constant and keys
Browse files Browse the repository at this point in the history
  • Loading branch information
zzeppozz committed Apr 26, 2021
1 parent e38db0d commit dbebdf5
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 54 deletions.
51 changes: 33 additions & 18 deletions docs/s2n_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,57 @@
S-to-the-n services
----------------------

* map: return metadata containing url endpoint for map and layernames for
predicted species distribution and occurrence points
* name
* occ: <server>/api/v1/occ
* dataset: <server>/api/v1/dataset
* resolve: <server>/api/v1/resolve/specify
* map: <server>/api/v1/map::
return metadata, url endpoints, and layernames for predicted species distributions and
occurrence points

* name: <server>/api/v1/name::
return metadata for taxonomic information on a string

* occ: <server>/api/v1/occ::
return metadata for species occurrence points for a GUID, or for a GBIF dataset GUID

* resolve: <server>/api/v1/resolve::
return unique identifier metadata including a direct URL for a data object. Currently
implemented only for Specify GUIDs and endpoints

Code resources
--------------------

* The core APIs are defined in the directory: src/LmRex/services/api/v1 .
There are currently 5 files (categories) that organize them:
map, name, occ, dataset, resolve, and I will add a 6th - heartbeat.
There are currently 4 files (categories) that organize them:
map, name, occ, resolve, and I will add a 5th - heartbeat.

* The classes in these files all inherit from _S2nService in the base.py file,
which implements some methods to ensure they all behave consistently and use a
subset of the same parameters and defaults. The _standardize_params method
contains defaults for url keyword parameters.

The root.py file contains the cherrypy commands and configuration to expose
* The root.py file contains the cherrypy commands and configuration to expose
the services.

In the src/LmRex/common/lmconstants.py file are the constants that are used in
multiple places.
* In the src/LmRex/common/lmconstants.py file are the constants that are used in
multiple places.

* **TST_VALUES** contains names and guids that can be used for testing
services, some will return data, some will not, but none should return
errors.

* **APIService** contains the URL service endpoints for the different
categories of services.
* **ServiceProvider** contains the name, endpoint, and service categories

* **ServiceProvider** contains the name, and service categories
available for that provider.

* All service endpoints (following the server url) will start the
root (/api/v1), then category. The "tentacles" service that queries all
available providers for that category will be at that endpoint
(example: /api/v1/name). The endpoint for each individual provider will be
appended to the url for a single provider query
(example: /api/v1/occ/gbif uses ServiceProvider.GBIF['endpoint']).
* These URL endpoints are constructed in the base class classmethod
_S2nService.endpoint() using the class attributes SERVICE_PROVIDER and
PROVIDER in each subclass
(example: /api/v1/name).

* All service endpoints accept a query parameter "provider" for the providers
available for that service, listed in ServiceProvider class. The values may be one or
more of the following: bison, gbif, idb, itis, lm, mopho, specify.

TODO
----------------------
*
61 changes: 30 additions & 31 deletions lmtrex/common/lmconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,12 @@ class APIService:
# TODO: Consider an Extension service for Digital Object Architecture
SpecimenExtension = 'occext'
Name = 'name'
Dataset = 'dataset'
Map = 'map'
Heartbeat = 'heartbeat'
Resolve = 'resolve'

# .............................................................................
class ServiceProviderNew:
class ServiceProvider:
BISON = {
S2nKey.NAME: 'BISON', S2nKey.PARAM: 'bison', S2nKey.SERVICES: [APIService.Dataset]}
GBIF = {
Expand Down Expand Up @@ -205,35 +204,35 @@ def all(cls):
ServiceProviderNew.ITISSolr, ServiceProviderNew.Lifemapper,
ServiceProviderNew.MorphoSource, ServiceProviderNew.Specify]

# .............................................................................
class ServiceProvider:
S2N = {
S2nKey.NAME: 'S2N', 'endpoint': '', 'services': [
APIService.Occurrence, APIService.Name, APIService.Dataset,
APIService.Map]}
BISON = {
S2nKey.NAME: 'BISON', 'endpoint': 'bison', 'services': [APIService.Dataset]}
GBIF = {
S2nKey.NAME: 'GBIF', 'endpoint': 'gbif', 'service': [
APIService.Occurrence, APIService.Name, APIService.Dataset]}
iDigBio = {
S2nKey.NAME: 'iDigBio', 'endpoint': 'idb', 'services': [
APIService.Occurrence]}
ITISSolr = {
S2nKey.NAME: 'ITIS Solr Web Services', 'endpoint': 'itis', 'services': [
APIService.Name]}
ITISWebService = {
S2nKey.NAME: 'ITIS Web Services', 'endpoint': 'itis2', 'services': [
APIService.Name]}
Lifemapper = {
S2nKey.NAME: 'Lifemapper', 'endpoint': 'lm', 'services': [
APIService.Map]}
MorphoSource = {
S2nKey.NAME: 'MorphoSource', 'endpoint': 'mopho', 'services': [
APIService.Occurrence]}
Specify = {
S2nKey.NAME: 'Specify', 'endpoint': 'specify', 'services': [
APIService.Occurrence, APIService.Resolve]}
# # .............................................................................
# class ServiceProvider:
# S2N = {
# S2nKey.NAME: 'S2N', 'endpoint': '', 'services': [
# APIService.Occurrence, APIService.Name, APIService.Dataset,
# APIService.Map]}
# BISON = {
# S2nKey.NAME: 'BISON', 'endpoint': 'bison', 'services': [APIService.Dataset]}
# GBIF = {
# S2nKey.NAME: 'GBIF', 'endpoint': 'gbif', 'service': [
# APIService.Occurrence, APIService.Name, APIService.Dataset]}
# iDigBio = {
# S2nKey.NAME: 'iDigBio', 'endpoint': 'idb', 'services': [
# APIService.Occurrence]}
# ITISSolr = {
# S2nKey.NAME: 'ITIS Solr Web Services', 'endpoint': 'itis', 'services': [
# APIService.Name]}
# ITISWebService = {
# S2nKey.NAME: 'ITIS Web Services', 'endpoint': 'itis2', 'services': [
# APIService.Name]}
# Lifemapper = {
# S2nKey.NAME: 'Lifemapper', 'endpoint': 'lm', 'services': [
# APIService.Map]}
# MorphoSource = {
# S2nKey.NAME: 'MorphoSource', 'endpoint': 'mopho', 'services': [
# APIService.Occurrence]}
# Specify = {
# S2nKey.NAME: 'Specify', 'endpoint': 'specify', 'services': [
# APIService.Occurrence, APIService.Resolve]}



Expand Down
2 changes: 1 addition & 1 deletion lmtrex/tools/provider/gbif.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# .............................................................................
class GbifAPI(APIQuery):
"""Class to query GBIF APIs and return results"""
PROVIDER = ServiceProvider.GBIF['name']
PROVIDER = ServiceProvider.GBIF[S2nKey.NAME]
# ...............................................
def __init__(self, service=GBIF.SPECIES_SERVICE, key=None,
other_filters=None, logger=None):
Expand Down
2 changes: 1 addition & 1 deletion lmtrex/tools/provider/itis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ItisAPI(APIQuery):
https://www.itis.gov/solr_documentation.html and
https://www.itis.gov/web_service.html
"""
PROVIDER = ServiceProvider.ITISSolr['name']
PROVIDER = ServiceProvider.ITISSolr[S2nKey.NAME]
# ...............................................
def __init__(
self, base_url, service=None, q_filters={}, other_filters={},
Expand Down
2 changes: 1 addition & 1 deletion lmtrex/tools/provider/lifemapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# .............................................................................
class LifemapperAPI(APIQuery):
"""Class to query Lifemapper portal APIs and return results"""
PROVIDER = ServiceProvider.Lifemapper['name']
PROVIDER = ServiceProvider.Lifemapper[S2nKey.NAME]
# ...............................................
def __init__(
self, resource=Lifemapper.PROJ_RESOURCE, ident=None, command=None,
Expand Down
2 changes: 1 addition & 1 deletion lmtrex/tools/provider/mopho.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# .............................................................................
class MorphoSourceAPI(APIQuery):
"""Class to query Specify portal APIs and return results"""
PROVIDER = ServiceProvider.MorphoSource['name']
PROVIDER = ServiceProvider.MorphoSource[S2nKey.NAME]
# ...............................................
def __init__(
self, resource=MorphoSource.OCC_RESOURCE, q_filters={},
Expand Down
2 changes: 1 addition & 1 deletion lmtrex/tools/provider/specify.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# .............................................................................
class SpecifyPortalAPI(APIQuery):
"""Class to query Specify portal APIs and return results"""
PROVIDER = ServiceProvider.Specify['name']
PROVIDER = ServiceProvider.Specify[S2nKey.NAME]
# ...............................................
def __init__(self, url=None, logger=None):
"""Constructor for SpecifyPortalAPI class"""
Expand Down

0 comments on commit dbebdf5

Please sign in to comment.