Open nichtich opened 3 years ago
There are two different things here:
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:
uri
field. However, in BARTOC all schemes will have the BARTOC URI in that field, right? Not sure how we get around this.VOCID
).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:
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.)
How about transforming API
into _cdkRegistries
with an array of cocoda-sdk registry configurations?
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. 👍
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.