gbv / bartoc.org

Source code of BARTOC.org user interface
https://bartoc.org/
23 stars 10 forks source link

Show service API status #82

Open nichtich opened 3 years ago

nichtich commented 3 years ago

Create a function that given a service API URL finds out the API type and returns an Registry instance on success. Otherwise the API type is unknown or the API client could not be initialized for instance because the API is offline. The heuristic can be based on known URL patterns it does not need to be 100%. Later we can extend to more sophisticated API type detection.

Then use this to show a green "Online" badge next to the service API URL on success.

stefandesu commented 3 years ago

There are two different things here:

  1. Detecting the type of API (i.e. which provider in cocoda-sdk should be used), and initialize it with cocoda-sdk.
  2. Detecting whether the API is currently reachable.

1. Can be done synchronously and we will have a CDK registry that can be used for querying the API. However, at that point we won't know whether the API is online at the moment.

2. Can be done manually by calling the .init() method. However, this will only work for the type ConceptApi and if the API has a /status endpoint. At least with cocoda-sdk it is currently not possible to simply determine whether an API is reachable other than making a request that should normally succeed.

I also noticed some other issues that will come up if we are planning to use this for querying data from a certain vocabulary:

nichtich commented 3 years ago

By now we will only have ConceptApi, SkosmosApi or unknown (e.g. when the API URL points to the documentation of a non-standard API). The badge could also show the type of API, e.g.

To further check whether the API is reachable:

However, this will only work for the type ConceptApi and if the API has a /status endpoint.

AFAIK this applies to all existing JSKOS API endpoints. For Skosmos it is more difficult, better make it an independent issue.

So for this issue the API status would be any of:

stefandesu commented 3 years ago

Any suggestions on how to identify the API? Or would it make sense to add an API_TYPE field for vocabularies? (Which would be difficult since API is an array of strings. In this case it would make more sense to have registry objects, for example.)

nichtich commented 3 years ago

How about transforming API into _cdkRegistries with an array of cocoda-sdk registry configurations?

stefandesu commented 3 years ago

I'd be fine with that. In Cocoda and cocoda-sdk, we are using _registry for individual items to indicate their registry. Not sure if it makes sense to align to that in some way. An array with cocoda-sdk registry configurations sound fine though. 👍