From: Lucas Di Pentima Date: Tue, 22 Feb 2022 17:58:29 +0000 (-0300) Subject: 18574: Adds /arvados/v1/vocabulary to the discovery document. X-Git-Tag: 2.4.0~67^2~16 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/82c424076577660d96173213a0d2db5f7c1450d7 18574: Adds /arvados/v1/vocabulary to the discovery document. Also, adds vocabulary caching on PySDK's API client. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/sdk/python/arvados/api.py b/sdk/python/arvados/api.py index 88596211d4..e0d1c50f03 100644 --- a/sdk/python/arvados/api.py +++ b/sdk/python/arvados/api.py @@ -253,6 +253,7 @@ def api(version=None, cache=True, host=None, token=None, insecure=False, svc.insecure = insecure svc.request_id = request_id svc.config = lambda: util.get_config_once(svc) + svc.vocabulary = lambda: util.get_vocabulary_once(svc) kwargs['http'].max_request_size = svc._rootDesc.get('maxRequestSize', 0) kwargs['http'].cache = None kwargs['http']._request_id = lambda: svc.request_id or util.new_request_id() diff --git a/sdk/python/arvados/util.py b/sdk/python/arvados/util.py index 2380e48b73..be8a03fc31 100644 --- a/sdk/python/arvados/util.py +++ b/sdk/python/arvados/util.py @@ -491,3 +491,11 @@ def get_config_once(svc): if not hasattr(svc, '_cached_config'): svc._cached_config = svc.configs().get().execute() return svc._cached_config + +def get_vocabulary_once(svc): + if not svc._rootDesc.get('resources').get('vocabularies', False): + # Old API server version, no vocabulary export endpoint + return {} + if not hasattr(svc, '_cached_vocabulary'): + svc._cached_vocabulary = svc.vocabularies().get().execute() + return svc._cached_vocabulary diff --git a/services/api/app/controllers/arvados/v1/schema_controller.rb b/services/api/app/controllers/arvados/v1/schema_controller.rb index 59ac639baf..100b916817 100644 --- a/services/api/app/controllers/arvados/v1/schema_controller.rb +++ b/services/api/app/controllers/arvados/v1/schema_controller.rb @@ -37,7 +37,7 @@ class Arvados::V1::SchemaController < ApplicationController # format is YYYYMMDD, must be fixed width (needs to be lexically # sortable), updated manually, may be used by clients to # determine availability of API server features. - revision: "20210628", + revision: "20220222", source_version: AppVersion.hash, sourceVersion: AppVersion.hash, # source_version should be deprecated in the future packageVersion: AppVersion.package_version, @@ -427,6 +427,27 @@ class Arvados::V1::SchemaController < ApplicationController } } + discovery[:resources]['vocabularies'] = { + methods: { + get: { + id: "arvados.vocabularies.get", + path: "vocabulary", + httpMethod: "GET", + description: "Get vocabulary definition", + parameters: { + }, + parameterOrder: [ + ], + response: { + }, + scopes: [ + "https://api.arvados.org/auth/arvados", + "https://api.arvados.org/auth/arvados.readonly" + ] + }, + } + } + discovery[:resources]['sys'] = { methods: { get: {