From d436b96b6251c4a3a169d832be2e840f36b700c8 Mon Sep 17 00:00:00 2001 From: Roman Sutormin Date: Thu, 23 Feb 2017 11:02:15 -0800 Subject: [PATCH 01/13] Fix for typo in auth URL parameter name. --- deploy.cfg | 2 +- lib/biokbase/catalog/Impl.py | 13 ++- lib/biokbase/catalog/Server.py | 126 +++++++++++++++-------------- lib/biokbase/catalog/authclient.py | 4 +- 4 files changed, 74 insertions(+), 71 deletions(-) diff --git a/deploy.cfg b/deploy.cfg index 562b916..7f56ca7 100644 --- a/deploy.cfg +++ b/deploy.cfg @@ -13,7 +13,7 @@ mongodb-database = catalog #mongodb-pwd = add password here # The KBase auth server url. -auth-server-url = https://kbase.us/services/authorization/Sessions/Login +auth-service-url = https://kbase.us/services/authorization/Sessions/Login # Path to docker socket/host docker-base-url = unix://var/run/docker.sock diff --git a/lib/biokbase/catalog/Impl.py b/lib/biokbase/catalog/Impl.py index 0c094f0..9077a36 100644 --- a/lib/biokbase/catalog/Impl.py +++ b/lib/biokbase/catalog/Impl.py @@ -14,16 +14,16 @@ class Catalog: Service for managing, registering, and building KBase Modules using the KBase SDK. ''' - ######## WARNING FOR GEVENT USERS ####### + ######## WARNING FOR GEVENT USERS ####### noqa # Since asynchronous IO can lead to methods - even the same method - # interrupting each other, you must be *very* careful when using global # state. A method could easily clobber the state set by another while # the latter method is running. - ######################################### + ######################################### noqa VERSION = "0.0.1" - GIT_URL = "https://github.com/mrcreosote/catalog" - GIT_COMMIT_HASH = "e2e1ccec3e9441ec62d189962190a6bcd9ceb7a8" - + GIT_URL = "https://github.com/rsutormin/catalog" + GIT_COMMIT_HASH = "554f89662992b978951d94ec0672c00cf7de55f7" + #BEGIN_CLASS_HEADER #END_CLASS_HEADER @@ -42,7 +42,7 @@ def __init__(self, config): print('Initialization complete.') #END_CONSTRUCTOR pass - + def version(self, ctx): """ @@ -1359,7 +1359,6 @@ def is_admin(self, ctx, username): 'returnVal is not type int as required.') # return the results return [returnVal] - def status(self, ctx): #BEGIN_STATUS returnVal = {'state': "OK", 'message': "", 'version': self.VERSION, diff --git a/lib/biokbase/catalog/Server.py b/lib/biokbase/catalog/Server.py index e807597..ac40f11 100644 --- a/lib/biokbase/catalog/Server.py +++ b/lib/biokbase/catalog/Server.py @@ -20,7 +20,7 @@ DEPLOY = 'KB_DEPLOYMENT_CONFIG' SERVICE = 'KB_SERVICE_NAME' -AUTH = 'auth-server-url' +AUTH = 'auth-service-url' # Note that the error fields do not match the 2.0 JSONRPC spec @@ -45,7 +45,7 @@ def get_config(): config = get_config() -from biokbase.catalog.Impl import Catalog # @IgnorePep8 +from biokbase.catalog.Impl import Catalog # noqa @IgnorePep8 impl_Catalog = Catalog(config) @@ -109,7 +109,11 @@ def _call_method(self, ctx, request): # Exception was raised inside the method. newerr = JSONServerError() newerr.trace = traceback.format_exc() - newerr.data = e.message + if isinstance(e.message, basestring): + newerr.data = e.message + else: + # Some exceptions embed other exceptions as the message + newerr.data = repr(e.message) raise newerr return result @@ -171,7 +175,7 @@ def call_py(self, ctx, jsondata): def _handle_request(self, ctx, request): """Handles given request and returns its response.""" - if self.method_data[request['method']].has_key('types'): # @IgnorePep8 + if self.method_data[request['method']].has_key('types'): # noqa @IgnorePep8 self._validate_params_types(request['method'], request['params']) result = self._call_method(ctx, request) @@ -332,187 +336,187 @@ def __init__(self): self.rpc_service.add(impl_Catalog.version, name='Catalog.version', types=[]) - self.method_authentication['Catalog.version'] = 'none' + self.method_authentication['Catalog.version'] = 'none' # noqa self.rpc_service.add(impl_Catalog.is_registered, name='Catalog.is_registered', types=[dict]) - self.method_authentication['Catalog.is_registered'] = 'none' + self.method_authentication['Catalog.is_registered'] = 'none' # noqa self.rpc_service.add(impl_Catalog.register_repo, name='Catalog.register_repo', types=[dict]) - self.method_authentication['Catalog.register_repo'] = 'required' + self.method_authentication['Catalog.register_repo'] = 'required' # noqa self.rpc_service.add(impl_Catalog.push_dev_to_beta, name='Catalog.push_dev_to_beta', types=[dict]) - self.method_authentication['Catalog.push_dev_to_beta'] = 'required' + self.method_authentication['Catalog.push_dev_to_beta'] = 'required' # noqa self.rpc_service.add(impl_Catalog.request_release, name='Catalog.request_release', types=[dict]) - self.method_authentication['Catalog.request_release'] = 'required' + self.method_authentication['Catalog.request_release'] = 'required' # noqa self.rpc_service.add(impl_Catalog.list_requested_releases, name='Catalog.list_requested_releases', types=[]) - self.method_authentication['Catalog.list_requested_releases'] = 'none' + self.method_authentication['Catalog.list_requested_releases'] = 'none' # noqa self.rpc_service.add(impl_Catalog.review_release_request, name='Catalog.review_release_request', types=[dict]) - self.method_authentication['Catalog.review_release_request'] = 'required' + self.method_authentication['Catalog.review_release_request'] = 'required' # noqa self.rpc_service.add(impl_Catalog.list_basic_module_info, name='Catalog.list_basic_module_info', types=[dict]) - self.method_authentication['Catalog.list_basic_module_info'] = 'none' + self.method_authentication['Catalog.list_basic_module_info'] = 'none' # noqa self.rpc_service.add(impl_Catalog.add_favorite, name='Catalog.add_favorite', types=[dict]) - self.method_authentication['Catalog.add_favorite'] = 'required' + self.method_authentication['Catalog.add_favorite'] = 'required' # noqa self.rpc_service.add(impl_Catalog.remove_favorite, name='Catalog.remove_favorite', types=[dict]) - self.method_authentication['Catalog.remove_favorite'] = 'required' + self.method_authentication['Catalog.remove_favorite'] = 'required' # noqa self.rpc_service.add(impl_Catalog.list_favorites, name='Catalog.list_favorites', types=[basestring]) - self.method_authentication['Catalog.list_favorites'] = 'none' + self.method_authentication['Catalog.list_favorites'] = 'none' # noqa self.rpc_service.add(impl_Catalog.list_app_favorites, name='Catalog.list_app_favorites', types=[dict]) - self.method_authentication['Catalog.list_app_favorites'] = 'none' + self.method_authentication['Catalog.list_app_favorites'] = 'none' # noqa self.rpc_service.add(impl_Catalog.list_favorite_counts, name='Catalog.list_favorite_counts', types=[dict]) - self.method_authentication['Catalog.list_favorite_counts'] = 'none' + self.method_authentication['Catalog.list_favorite_counts'] = 'none' # noqa self.rpc_service.add(impl_Catalog.get_module_info, name='Catalog.get_module_info', types=[dict]) - self.method_authentication['Catalog.get_module_info'] = 'none' + self.method_authentication['Catalog.get_module_info'] = 'none' # noqa self.rpc_service.add(impl_Catalog.get_version_info, name='Catalog.get_version_info', types=[dict]) - self.method_authentication['Catalog.get_version_info'] = 'none' + self.method_authentication['Catalog.get_version_info'] = 'none' # noqa self.rpc_service.add(impl_Catalog.list_released_module_versions, name='Catalog.list_released_module_versions', types=[dict]) - self.method_authentication['Catalog.list_released_module_versions'] = 'none' + self.method_authentication['Catalog.list_released_module_versions'] = 'none' # noqa self.rpc_service.add(impl_Catalog.get_module_version, name='Catalog.get_module_version', types=[dict]) - self.method_authentication['Catalog.get_module_version'] = 'none' + self.method_authentication['Catalog.get_module_version'] = 'none' # noqa self.rpc_service.add(impl_Catalog.list_local_functions, name='Catalog.list_local_functions', types=[dict]) - self.method_authentication['Catalog.list_local_functions'] = 'none' + self.method_authentication['Catalog.list_local_functions'] = 'none' # noqa self.rpc_service.add(impl_Catalog.get_local_function_details, name='Catalog.get_local_function_details', types=[dict]) - self.method_authentication['Catalog.get_local_function_details'] = 'none' + self.method_authentication['Catalog.get_local_function_details'] = 'none' # noqa self.rpc_service.add(impl_Catalog.module_version_lookup, name='Catalog.module_version_lookup', types=[dict]) - self.method_authentication['Catalog.module_version_lookup'] = 'none' + self.method_authentication['Catalog.module_version_lookup'] = 'none' # noqa self.rpc_service.add(impl_Catalog.list_service_modules, name='Catalog.list_service_modules', types=[dict]) - self.method_authentication['Catalog.list_service_modules'] = 'none' + self.method_authentication['Catalog.list_service_modules'] = 'none' # noqa self.rpc_service.add(impl_Catalog.set_registration_state, name='Catalog.set_registration_state', types=[dict]) - self.method_authentication['Catalog.set_registration_state'] = 'required' + self.method_authentication['Catalog.set_registration_state'] = 'required' # noqa self.rpc_service.add(impl_Catalog.get_module_state, name='Catalog.get_module_state', types=[dict]) - self.method_authentication['Catalog.get_module_state'] = 'none' + self.method_authentication['Catalog.get_module_state'] = 'none' # noqa self.rpc_service.add(impl_Catalog.get_build_log, name='Catalog.get_build_log', types=[basestring]) - self.method_authentication['Catalog.get_build_log'] = 'none' + self.method_authentication['Catalog.get_build_log'] = 'none' # noqa self.rpc_service.add(impl_Catalog.get_parsed_build_log, name='Catalog.get_parsed_build_log', types=[dict]) - self.method_authentication['Catalog.get_parsed_build_log'] = 'none' + self.method_authentication['Catalog.get_parsed_build_log'] = 'none' # noqa self.rpc_service.add(impl_Catalog.list_builds, name='Catalog.list_builds', types=[dict]) - self.method_authentication['Catalog.list_builds'] = 'none' + self.method_authentication['Catalog.list_builds'] = 'none' # noqa self.rpc_service.add(impl_Catalog.delete_module, name='Catalog.delete_module', types=[dict]) - self.method_authentication['Catalog.delete_module'] = 'required' + self.method_authentication['Catalog.delete_module'] = 'required' # noqa self.rpc_service.add(impl_Catalog.migrate_module_to_new_git_url, name='Catalog.migrate_module_to_new_git_url', types=[dict]) - self.method_authentication['Catalog.migrate_module_to_new_git_url'] = 'required' + self.method_authentication['Catalog.migrate_module_to_new_git_url'] = 'required' # noqa self.rpc_service.add(impl_Catalog.set_to_active, name='Catalog.set_to_active', types=[dict]) - self.method_authentication['Catalog.set_to_active'] = 'required' + self.method_authentication['Catalog.set_to_active'] = 'required' # noqa self.rpc_service.add(impl_Catalog.set_to_inactive, name='Catalog.set_to_inactive', types=[dict]) - self.method_authentication['Catalog.set_to_inactive'] = 'required' + self.method_authentication['Catalog.set_to_inactive'] = 'required' # noqa self.rpc_service.add(impl_Catalog.is_approved_developer, name='Catalog.is_approved_developer', types=[list]) - self.method_authentication['Catalog.is_approved_developer'] = 'none' + self.method_authentication['Catalog.is_approved_developer'] = 'none' # noqa self.rpc_service.add(impl_Catalog.list_approved_developers, name='Catalog.list_approved_developers', types=[]) - self.method_authentication['Catalog.list_approved_developers'] = 'none' + self.method_authentication['Catalog.list_approved_developers'] = 'none' # noqa self.rpc_service.add(impl_Catalog.approve_developer, name='Catalog.approve_developer', types=[basestring]) - self.method_authentication['Catalog.approve_developer'] = 'required' + self.method_authentication['Catalog.approve_developer'] = 'required' # noqa self.rpc_service.add(impl_Catalog.revoke_developer, name='Catalog.revoke_developer', types=[basestring]) - self.method_authentication['Catalog.revoke_developer'] = 'required' + self.method_authentication['Catalog.revoke_developer'] = 'required' # noqa self.rpc_service.add(impl_Catalog.log_exec_stats, name='Catalog.log_exec_stats', types=[dict]) - self.method_authentication['Catalog.log_exec_stats'] = 'required' + self.method_authentication['Catalog.log_exec_stats'] = 'required' # noqa self.rpc_service.add(impl_Catalog.get_exec_aggr_stats, name='Catalog.get_exec_aggr_stats', types=[dict]) - self.method_authentication['Catalog.get_exec_aggr_stats'] = 'none' + self.method_authentication['Catalog.get_exec_aggr_stats'] = 'none' # noqa self.rpc_service.add(impl_Catalog.get_exec_aggr_table, name='Catalog.get_exec_aggr_table', types=[dict]) - self.method_authentication['Catalog.get_exec_aggr_table'] = 'required' + self.method_authentication['Catalog.get_exec_aggr_table'] = 'required' # noqa self.rpc_service.add(impl_Catalog.get_exec_raw_stats, name='Catalog.get_exec_raw_stats', types=[dict]) - self.method_authentication['Catalog.get_exec_raw_stats'] = 'required' + self.method_authentication['Catalog.get_exec_raw_stats'] = 'required' # noqa self.rpc_service.add(impl_Catalog.get_client_groups, name='Catalog.get_client_groups', types=[dict]) - self.method_authentication['Catalog.get_client_groups'] = 'none' + self.method_authentication['Catalog.get_client_groups'] = 'none' # noqa self.rpc_service.add(impl_Catalog.set_client_group_config, name='Catalog.set_client_group_config', types=[dict]) - self.method_authentication['Catalog.set_client_group_config'] = 'required' + self.method_authentication['Catalog.set_client_group_config'] = 'required' # noqa self.rpc_service.add(impl_Catalog.remove_client_group_config, name='Catalog.remove_client_group_config', types=[dict]) - self.method_authentication['Catalog.remove_client_group_config'] = 'required' + self.method_authentication['Catalog.remove_client_group_config'] = 'required' # noqa self.rpc_service.add(impl_Catalog.list_client_group_configs, name='Catalog.list_client_group_configs', types=[dict]) - self.method_authentication['Catalog.list_client_group_configs'] = 'none' + self.method_authentication['Catalog.list_client_group_configs'] = 'none' # noqa self.rpc_service.add(impl_Catalog.set_volume_mount, name='Catalog.set_volume_mount', types=[dict]) - self.method_authentication['Catalog.set_volume_mount'] = 'required' + self.method_authentication['Catalog.set_volume_mount'] = 'required' # noqa self.rpc_service.add(impl_Catalog.remove_volume_mount, name='Catalog.remove_volume_mount', types=[dict]) - self.method_authentication['Catalog.remove_volume_mount'] = 'required' + self.method_authentication['Catalog.remove_volume_mount'] = 'required' # noqa self.rpc_service.add(impl_Catalog.list_volume_mounts, name='Catalog.list_volume_mounts', types=[dict]) - self.method_authentication['Catalog.list_volume_mounts'] = 'required' + self.method_authentication['Catalog.list_volume_mounts'] = 'required' # noqa self.rpc_service.add(impl_Catalog.is_admin, name='Catalog.is_admin', types=[basestring]) - self.method_authentication['Catalog.is_admin'] = 'none' + self.method_authentication['Catalog.is_admin'] = 'none' # noqa self.rpc_service.add(impl_Catalog.status, name='Catalog.status', types=[dict]) @@ -568,7 +572,8 @@ def __call__(self, environ, start_response): if token is None and auth_req == 'required': err = JSONServerError() err.data = ( - 'Authentication required for Catalog ' + + 'Authentication required for ' + + 'Catalog ' + 'but no authentication header was passed') raise err elif token is None and auth_req == 'optional': @@ -600,7 +605,7 @@ def __call__(self, environ, start_response): } trace = jre.trace if hasattr(jre, 'trace') else None rpc_result = self.process_error(err, ctx, req, trace) - except Exception, e: + except Exception: err = {'error': {'code': 0, 'name': 'Unexpected Server Error', 'message': 'An unexpected server error ' + @@ -610,10 +615,10 @@ def __call__(self, environ, start_response): rpc_result = self.process_error(err, ctx, req, traceback.format_exc()) - # print 'The request method was %s\n' % environ['REQUEST_METHOD'] - # print 'The environment dictionary is:\n%s\n' % pprint.pformat(environ) @IgnorePep8 - # print 'The request body was: %s' % request_body - # print 'The result from the method call is:\n%s\n' % \ + # print 'Request method was %s\n' % environ['REQUEST_METHOD'] + # print 'Environment dictionary is:\n%s\n' % pprint.pformat(environ) + # print 'Request body was: %s' % request_body + # print 'Result from the method call is:\n%s\n' % \ # pprint.pformat(rpc_result) if rpc_result: @@ -649,11 +654,12 @@ def process_error(self, error, context, request, trace=None): return json.dumps(error) def now_in_utc(self): - # Taken from http://stackoverflow.com/questions/3401428/how-to-get-an-isoformat-datetime-string-including-the-default-timezone @IgnorePep8 + # noqa Taken from http://stackoverflow.com/questions/3401428/how-to-get-an-isoformat-datetime-string-including-the-default-timezone @IgnorePep8 dtnow = datetime.datetime.now() dtutcnow = datetime.datetime.utcnow() delta = dtnow - dtutcnow - hh, mm = divmod((delta.days * 24*60*60 + delta.seconds + 30) // 60, 60) + hh, mm = divmod((delta.days * 24 * 60 * 60 + delta.seconds + 30) // 60, + 60) return "%s%+02d:%02d" % (dtnow.isoformat(), hh, mm) application = Application() @@ -682,9 +688,7 @@ def now_in_utc(self): print "Monkeypatching std libraries for async" from gevent import monkey monkey.patch_all() - uwsgi.applications = { - '': application - } + uwsgi.applications = {'': application} except ImportError: # Not available outside of wsgi, ignore pass diff --git a/lib/biokbase/catalog/authclient.py b/lib/biokbase/catalog/authclient.py index b590a55..9a15713 100644 --- a/lib/biokbase/catalog/authclient.py +++ b/lib/biokbase/catalog/authclient.py @@ -24,7 +24,7 @@ def __init__(self, maxsize=2000): self._halfmax = maxsize / 2 # int division to round down def get_user(self, token): - token = hashlib.sha256(token).hexdigest(); + token = hashlib.sha256(token).hexdigest() with self._lock: usertime = self._cache.get(token) if not usertime: @@ -40,7 +40,7 @@ def add_valid_token(self, token, user): raise ValueError('Must supply token') if not user: raise ValueError('Must supply user') - token = hashlib.sha256(token).hexdigest(); + token = hashlib.sha256(token).hexdigest() with self._lock: self._cache[token] = [user, _time.time()] if len(self._cache) > self._maxsize: From 836f87b47ffef4496ffcafb52dfef2060d24792c Mon Sep 17 00:00:00 2001 From: Roman Sutormin Date: Tue, 28 Mar 2017 15:38:30 -0700 Subject: [PATCH 02/13] job_id field in execution stats; support for hidden config parameters. --- README.md | 3 + catalog.spec | 40 ++ lib/Bio/KBase/Catalog/Client.pm | 426 +++++++++++++++++- lib/biokbase/catalog/Client.py | 56 ++- lib/biokbase/catalog/Impl.py | 76 +++- lib/biokbase/catalog/Server.py | 12 + lib/biokbase/catalog/controller.py | 37 +- lib/biokbase/catalog/db.py | 46 +- lib/biokbase/catalog/version.py | 2 +- lib/java/us/kbase/catalog/CatalogClient.java | 50 ++ .../catalog/GetHiddenConfigParamsInput.java | 60 +++ .../kbase/catalog/HiddenConfigParameter.java | 136 ++++++ .../us/kbase/catalog/LogExecStatsParams.java | 22 +- .../ModifyHiddenConfigParamsInput.java | 61 +++ lib/javascript/Client.js | 39 ++ test/basic_catalog_test.py | 2 +- test/execution_stats_test.py | 10 +- test/hidden_config_params_test.py | 133 ++++++ 18 files changed, 1189 insertions(+), 22 deletions(-) create mode 100644 lib/java/us/kbase/catalog/GetHiddenConfigParamsInput.java create mode 100644 lib/java/us/kbase/catalog/HiddenConfigParameter.java create mode 100644 lib/java/us/kbase/catalog/ModifyHiddenConfigParamsInput.java create mode 100644 test/hidden_config_params_test.py diff --git a/README.md b/README.md index fdd98b7..31ed98b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ develop: [![Build Status](https://travis-ci.org/kbase/catalog.svg?branch=develop Code coverage: (develop branch) [![Coverage Status](https://coveralls.io/repos/github/kbase/catalog/badge.svg?branch=develop)](https://coveralls.io/github/kbase/catalog?branch=develop) +#### v2.0.7 - 3/28/17 + - Added job_id field to raw execution statistics + - Support for hidden configuration parameters #### v2.0.6 - 12/7/16 - Bug is fixed in module registration related to docker client timeout happening diff --git a/catalog.spec b/catalog.spec index 8028e80..408bb11 100644 --- a/catalog.spec +++ b/catalog.spec @@ -635,6 +635,7 @@ module Catalog { float exec_start_time; float finish_time; boolean is_error; + string job_id; } LogExecStatsParams; /* @@ -783,4 +784,43 @@ module Catalog { /* returns true (1) if the user is an admin, false (0) otherwise */ funcdef is_admin(string username) returns (boolean); + /* + version_tag - optional version (commit hash, tag or semantic one) of module, if not set + then default "" value is used which means parameter is applied to any version; + is_password - optional flag meaning to hide this parameter's value in UI. + */ + typedef structure { + string module_name; + string version_tag; + string param_name; + boolean is_password; + string param_value; + } HiddenConfigParameter; + + typedef structure { + list data; + } ModifyHiddenConfigParamsInput; + + /* + Only admins can use this function. + */ + funcdef set_hidden_config_params(ModifyHiddenConfigParamsInput params) + returns () authentication required; + + /* + Only admins can use this function. + */ + funcdef remove_hidden_config_params(ModifyHiddenConfigParamsInput params) + returns () authentication required; + + typedef structure { + string module_name; + } GetHiddenConfigParamsInput; + + /* + Only admins can use this function. + */ + funcdef get_hidden_config_params(GetHiddenConfigParamsInput params) + returns (list) authentication required; + }; diff --git a/lib/Bio/KBase/Catalog/Client.pm b/lib/Bio/KBase/Catalog/Client.pm index 2735f06..67e010d 100644 --- a/lib/Bio/KBase/Catalog/Client.pm +++ b/lib/Bio/KBase/Catalog/Client.pm @@ -81,12 +81,19 @@ sub new # We create an auth token, passing through the arguments that we were (hopefully) given. { - my $token = Bio::KBase::AuthToken->new(@args); + my %arg_hash2 = @args; + if (exists $arg_hash2{"token"}) { + $self->{token} = $arg_hash2{"token"}; + } elsif (exists $arg_hash2{"user_id"}) { + my $token = Bio::KBase::AuthToken->new(@args); + if (!$token->error_message) { + $self->{token} = $token->token; + } + } - if (!$token->error_message) + if (exists $self->{token}) { - $self->{token} = $token->token; - $self->{client}->{token} = $token->token; + $self->{client}->{token} = $self->{token}; } } @@ -3613,6 +3620,7 @@ LogExecStatsParams is a reference to a hash where the following keys are defined exec_start_time has a value which is a float finish_time has a value which is a float is_error has a value which is a Catalog.boolean + job_id has a value which is a string boolean is an int @@ -3633,6 +3641,7 @@ LogExecStatsParams is a reference to a hash where the following keys are defined exec_start_time has a value which is a float finish_time has a value which is a float is_error has a value which is a Catalog.boolean + job_id has a value which is a string boolean is an int @@ -4729,6 +4738,302 @@ returns true (1) if the user is an admin, false (0) otherwise } } + + +=head2 set_hidden_config_params + + $obj->set_hidden_config_params($params) + +=over 4 + +=item Parameter and return types + +=begin html + +
+$params is a Catalog.ModifyHiddenConfigParamsInput
+ModifyHiddenConfigParamsInput is a reference to a hash where the following keys are defined:
+	data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter
+HiddenConfigParameter is a reference to a hash where the following keys are defined:
+	module_name has a value which is a string
+	version_tag has a value which is a string
+	param_name has a value which is a string
+	is_password has a value which is a Catalog.boolean
+	param_value has a value which is a string
+boolean is an int
+
+
+ +=end html + +=begin text + +$params is a Catalog.ModifyHiddenConfigParamsInput +ModifyHiddenConfigParamsInput is a reference to a hash where the following keys are defined: + data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter +HiddenConfigParameter is a reference to a hash where the following keys are defined: + module_name has a value which is a string + version_tag has a value which is a string + param_name has a value which is a string + is_password has a value which is a Catalog.boolean + param_value has a value which is a string +boolean is an int + + +=end text + +=item Description + +Only admins can use this function. + +=back + +=cut + + sub set_hidden_config_params +{ + my($self, @args) = @_; + +# Authentication: required + + if ((my $n = @args) != 1) + { + Bio::KBase::Exceptions::ArgumentValidationError->throw(error => + "Invalid argument count for function set_hidden_config_params (received $n, expecting 1)"); + } + { + my($params) = @args; + + my @_bad_arguments; + (ref($params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"params\" (value was \"$params\")"); + if (@_bad_arguments) { + my $msg = "Invalid arguments passed to set_hidden_config_params:\n" . join("", map { "\t$_\n" } @_bad_arguments); + Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg, + method_name => 'set_hidden_config_params'); + } + } + + my $url = $self->{url}; + my $result = $self->{client}->call($url, $self->{headers}, { + method => "Catalog.set_hidden_config_params", + params => \@args, + }); + if ($result) { + if ($result->is_error) { + Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message, + code => $result->content->{error}->{code}, + method_name => 'set_hidden_config_params', + data => $result->content->{error}->{error} # JSON::RPC::ReturnObject only supports JSONRPC 1.1 or 1.O + ); + } else { + return; + } + } else { + Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method set_hidden_config_params", + status_line => $self->{client}->status_line, + method_name => 'set_hidden_config_params', + ); + } +} + + + +=head2 remove_hidden_config_params + + $obj->remove_hidden_config_params($params) + +=over 4 + +=item Parameter and return types + +=begin html + +
+$params is a Catalog.ModifyHiddenConfigParamsInput
+ModifyHiddenConfigParamsInput is a reference to a hash where the following keys are defined:
+	data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter
+HiddenConfigParameter is a reference to a hash where the following keys are defined:
+	module_name has a value which is a string
+	version_tag has a value which is a string
+	param_name has a value which is a string
+	is_password has a value which is a Catalog.boolean
+	param_value has a value which is a string
+boolean is an int
+
+
+ +=end html + +=begin text + +$params is a Catalog.ModifyHiddenConfigParamsInput +ModifyHiddenConfigParamsInput is a reference to a hash where the following keys are defined: + data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter +HiddenConfigParameter is a reference to a hash where the following keys are defined: + module_name has a value which is a string + version_tag has a value which is a string + param_name has a value which is a string + is_password has a value which is a Catalog.boolean + param_value has a value which is a string +boolean is an int + + +=end text + +=item Description + +Only admins can use this function. + +=back + +=cut + + sub remove_hidden_config_params +{ + my($self, @args) = @_; + +# Authentication: required + + if ((my $n = @args) != 1) + { + Bio::KBase::Exceptions::ArgumentValidationError->throw(error => + "Invalid argument count for function remove_hidden_config_params (received $n, expecting 1)"); + } + { + my($params) = @args; + + my @_bad_arguments; + (ref($params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"params\" (value was \"$params\")"); + if (@_bad_arguments) { + my $msg = "Invalid arguments passed to remove_hidden_config_params:\n" . join("", map { "\t$_\n" } @_bad_arguments); + Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg, + method_name => 'remove_hidden_config_params'); + } + } + + my $url = $self->{url}; + my $result = $self->{client}->call($url, $self->{headers}, { + method => "Catalog.remove_hidden_config_params", + params => \@args, + }); + if ($result) { + if ($result->is_error) { + Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message, + code => $result->content->{error}->{code}, + method_name => 'remove_hidden_config_params', + data => $result->content->{error}->{error} # JSON::RPC::ReturnObject only supports JSONRPC 1.1 or 1.O + ); + } else { + return; + } + } else { + Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method remove_hidden_config_params", + status_line => $self->{client}->status_line, + method_name => 'remove_hidden_config_params', + ); + } +} + + + +=head2 get_hidden_config_params + + $return = $obj->get_hidden_config_params($params) + +=over 4 + +=item Parameter and return types + +=begin html + +
+$params is a Catalog.GetHiddenConfigParamsInput
+$return is a reference to a list where each element is a Catalog.HiddenConfigParameter
+GetHiddenConfigParamsInput is a reference to a hash where the following keys are defined:
+	module_name has a value which is a string
+HiddenConfigParameter is a reference to a hash where the following keys are defined:
+	module_name has a value which is a string
+	version_tag has a value which is a string
+	param_name has a value which is a string
+	is_password has a value which is a Catalog.boolean
+	param_value has a value which is a string
+boolean is an int
+
+
+ +=end html + +=begin text + +$params is a Catalog.GetHiddenConfigParamsInput +$return is a reference to a list where each element is a Catalog.HiddenConfigParameter +GetHiddenConfigParamsInput is a reference to a hash where the following keys are defined: + module_name has a value which is a string +HiddenConfigParameter is a reference to a hash where the following keys are defined: + module_name has a value which is a string + version_tag has a value which is a string + param_name has a value which is a string + is_password has a value which is a Catalog.boolean + param_value has a value which is a string +boolean is an int + + +=end text + +=item Description + +Only admins can use this function. + +=back + +=cut + + sub get_hidden_config_params +{ + my($self, @args) = @_; + +# Authentication: required + + if ((my $n = @args) != 1) + { + Bio::KBase::Exceptions::ArgumentValidationError->throw(error => + "Invalid argument count for function get_hidden_config_params (received $n, expecting 1)"); + } + { + my($params) = @args; + + my @_bad_arguments; + (ref($params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"params\" (value was \"$params\")"); + if (@_bad_arguments) { + my $msg = "Invalid arguments passed to get_hidden_config_params:\n" . join("", map { "\t$_\n" } @_bad_arguments); + Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg, + method_name => 'get_hidden_config_params'); + } + } + + my $url = $self->{url}; + my $result = $self->{client}->call($url, $self->{headers}, { + method => "Catalog.get_hidden_config_params", + params => \@args, + }); + if ($result) { + if ($result->is_error) { + Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message, + code => $result->content->{error}->{code}, + method_name => 'get_hidden_config_params', + data => $result->content->{error}->{error} # JSON::RPC::ReturnObject only supports JSONRPC 1.1 or 1.O + ); + } else { + return wantarray ? @{$result->result} : $result->result->[0]; + } + } else { + Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method get_hidden_config_params", + status_line => $self->{client}->status_line, + method_name => 'get_hidden_config_params', + ); + } +} + sub status { @@ -4772,16 +5077,16 @@ sub version { Bio::KBase::Exceptions::JSONRPC->throw( error => $result->error_message, code => $result->content->{code}, - method_name => 'is_admin', + method_name => 'get_hidden_config_params', ); } else { return wantarray ? @{$result->result} : $result->result->[0]; } } else { Bio::KBase::Exceptions::HTTP->throw( - error => "Error invoking method is_admin", + error => "Error invoking method get_hidden_config_params", status_line => $self->{client}->status_line, - method_name => 'is_admin', + method_name => 'get_hidden_config_params', ); } } @@ -6547,6 +6852,7 @@ creation_time has a value which is a float exec_start_time has a value which is a float finish_time has a value which is a float is_error has a value which is a Catalog.boolean +job_id has a value which is a string @@ -6565,6 +6871,7 @@ creation_time has a value which is a float exec_start_time has a value which is a float finish_time has a value which is a float is_error has a value which is a Catalog.boolean +job_id has a value which is a string =end text @@ -6994,6 +7301,111 @@ client_group has a value which is a string +=head2 HiddenConfigParameter + +=over 4 + + + +=item Description + +version_tag - optional version (commit hash, tag or semantic one) of module, if not set + then default "" value is used which means parameter is applied to any version; +is_password - optional flag meaning to hide this parameter's value in UI. + + +=item Definition + +=begin html + +
+a reference to a hash where the following keys are defined:
+module_name has a value which is a string
+version_tag has a value which is a string
+param_name has a value which is a string
+is_password has a value which is a Catalog.boolean
+param_value has a value which is a string
+
+
+ +=end html + +=begin text + +a reference to a hash where the following keys are defined: +module_name has a value which is a string +version_tag has a value which is a string +param_name has a value which is a string +is_password has a value which is a Catalog.boolean +param_value has a value which is a string + + +=end text + +=back + + + +=head2 ModifyHiddenConfigParamsInput + +=over 4 + + + +=item Definition + +=begin html + +
+a reference to a hash where the following keys are defined:
+data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter
+
+
+ +=end html + +=begin text + +a reference to a hash where the following keys are defined: +data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter + + +=end text + +=back + + + +=head2 GetHiddenConfigParamsInput + +=over 4 + + + +=item Definition + +=begin html + +
+a reference to a hash where the following keys are defined:
+module_name has a value which is a string
+
+
+ +=end html + +=begin text + +a reference to a hash where the following keys are defined: +module_name has a value which is a string + + +=end text + +=back + + + =cut package Bio::KBase::Catalog::Client::RpcClient; diff --git a/lib/biokbase/catalog/Client.py b/lib/biokbase/catalog/Client.py index f91a76b..37d7d32 100644 --- a/lib/biokbase/catalog/Client.py +++ b/lib/biokbase/catalog/Client.py @@ -837,7 +837,7 @@ def log_exec_stats(self, params, context=None): "func_name" of String, parameter "git_commit_hash" of String, parameter "creation_time" of Double, parameter "exec_start_time" of Double, parameter "finish_time" of Double, parameter "is_error" - of type "boolean" (@range [0,1]) + of type "boolean" (@range [0,1]), parameter "job_id" of String """ return self._client.call_method( 'Catalog.log_exec_stats', @@ -1009,6 +1009,60 @@ def is_admin(self, username, context=None): 'Catalog.is_admin', [username], self._service_ver, context) + def set_hidden_config_params(self, params, context=None): + """ + Only admins can use this function. + :param params: instance of type "ModifyHiddenConfigParamsInput" -> + structure: parameter "data" of list of type + "HiddenConfigParameter" (version_tag - optional version (commit + hash, tag or semantic one) of module, if not set then default "" + value is used which means parameter is applied to any version; + is_password - optional flag meaning to hide this parameter's value + in UI.) -> structure: parameter "module_name" of String, parameter + "version_tag" of String, parameter "param_name" of String, + parameter "is_password" of type "boolean" (@range [0,1]), + parameter "param_value" of String + """ + return self._client.call_method( + 'Catalog.set_hidden_config_params', + [params], self._service_ver, context) + + def remove_hidden_config_params(self, params, context=None): + """ + Only admins can use this function. + :param params: instance of type "ModifyHiddenConfigParamsInput" -> + structure: parameter "data" of list of type + "HiddenConfigParameter" (version_tag - optional version (commit + hash, tag or semantic one) of module, if not set then default "" + value is used which means parameter is applied to any version; + is_password - optional flag meaning to hide this parameter's value + in UI.) -> structure: parameter "module_name" of String, parameter + "version_tag" of String, parameter "param_name" of String, + parameter "is_password" of type "boolean" (@range [0,1]), + parameter "param_value" of String + """ + return self._client.call_method( + 'Catalog.remove_hidden_config_params', + [params], self._service_ver, context) + + def get_hidden_config_params(self, params, context=None): + """ + Only admins can use this function. + :param params: instance of type "GetHiddenConfigParamsInput" -> + structure: parameter "module_name" of String + :returns: instance of list of type "HiddenConfigParameter" + (version_tag - optional version (commit hash, tag or semantic one) + of module, if not set then default "" value is used which means + parameter is applied to any version; is_password - optional flag + meaning to hide this parameter's value in UI.) -> structure: + parameter "module_name" of String, parameter "version_tag" of + String, parameter "param_name" of String, parameter "is_password" + of type "boolean" (@range [0,1]), parameter "param_value" of String + """ + return self._client.call_method( + 'Catalog.get_hidden_config_params', + [params], self._service_ver, context) + def status(self, context=None): return self._client.call_method('Catalog.status', [], self._service_ver, context) diff --git a/lib/biokbase/catalog/Impl.py b/lib/biokbase/catalog/Impl.py index 9077a36..1485587 100644 --- a/lib/biokbase/catalog/Impl.py +++ b/lib/biokbase/catalog/Impl.py @@ -21,8 +21,8 @@ class Catalog: # the latter method is running. ######################################### noqa VERSION = "0.0.1" - GIT_URL = "https://github.com/rsutormin/catalog" - GIT_COMMIT_HASH = "554f89662992b978951d94ec0672c00cf7de55f7" + GIT_URL = "https://github.com/kbase/catalog" + GIT_COMMIT_HASH = "6858eb635ce51972b6e3b6dc6f8c367be6a79b75" #BEGIN_CLASS_HEADER #END_CLASS_HEADER @@ -1095,7 +1095,7 @@ def log_exec_stats(self, ctx, params): "func_name" of String, parameter "git_commit_hash" of String, parameter "creation_time" of Double, parameter "exec_start_time" of Double, parameter "finish_time" of Double, parameter "is_error" - of type "boolean" (@range [0,1]) + of type "boolean" (@range [0,1]), parameter "job_id" of String """ # ctx is the context object #BEGIN log_exec_stats @@ -1112,9 +1112,10 @@ def log_exec_stats(self, ctx, params): exec_start_time = params['exec_start_time'] finish_time = params['finish_time'] is_error = params['is_error'] != 0 + job_id = params.get('job_id') self.cc.log_exec_stats(admin_user_id, user_id, app_module_name, app_id, func_module_name, func_name, git_commit_hash, creation_time, exec_start_time, - finish_time, is_error) + finish_time, is_error, job_id) #END log_exec_stats pass @@ -1359,6 +1360,73 @@ def is_admin(self, ctx, username): 'returnVal is not type int as required.') # return the results return [returnVal] + + def set_hidden_config_params(self, ctx, params): + """ + Only admins can use this function. + :param params: instance of type "ModifyHiddenConfigParamsInput" -> + structure: parameter "data" of list of type + "HiddenConfigParameter" (version_tag - optional version (commit + hash, tag or semantic one) of module, if not set then default "" + value is used which means parameter is applied to any version; + is_password - optional flag meaning to hide this parameter's value + in UI.) -> structure: parameter "module_name" of String, parameter + "version_tag" of String, parameter "param_name" of String, + parameter "is_password" of type "boolean" (@range [0,1]), + parameter "param_value" of String + """ + # ctx is the context object + #BEGIN set_hidden_config_params + self.cc.set_hidden_config_params(ctx['user_id'], params) + #END set_hidden_config_params + pass + + def remove_hidden_config_params(self, ctx, params): + """ + Only admins can use this function. + :param params: instance of type "ModifyHiddenConfigParamsInput" -> + structure: parameter "data" of list of type + "HiddenConfigParameter" (version_tag - optional version (commit + hash, tag or semantic one) of module, if not set then default "" + value is used which means parameter is applied to any version; + is_password - optional flag meaning to hide this parameter's value + in UI.) -> structure: parameter "module_name" of String, parameter + "version_tag" of String, parameter "param_name" of String, + parameter "is_password" of type "boolean" (@range [0,1]), + parameter "param_value" of String + """ + # ctx is the context object + #BEGIN remove_hidden_config_params + self.cc.remove_hidden_config_params(ctx['user_id'], params) + #END remove_hidden_config_params + pass + + def get_hidden_config_params(self, ctx, params): + """ + Only admins can use this function. + :param params: instance of type "GetHiddenConfigParamsInput" -> + structure: parameter "module_name" of String + :returns: instance of list of type "HiddenConfigParameter" + (version_tag - optional version (commit hash, tag or semantic one) + of module, if not set then default "" value is used which means + parameter is applied to any version; is_password - optional flag + meaning to hide this parameter's value in UI.) -> structure: + parameter "module_name" of String, parameter "version_tag" of + String, parameter "param_name" of String, parameter "is_password" + of type "boolean" (@range [0,1]), parameter "param_value" of String + """ + # ctx is the context object + # return variables are: returnVal + #BEGIN get_hidden_config_params + returnVal = self.cc.get_hidden_config_params(ctx['user_id'], params) + #END get_hidden_config_params + + # At some point might do deeper type checking... + if not isinstance(returnVal, list): + raise ValueError('Method get_hidden_config_params return value ' + + 'returnVal is not type list as required.') + # return the results + return [returnVal] def status(self, ctx): #BEGIN_STATUS returnVal = {'state': "OK", 'message': "", 'version': self.VERSION, diff --git a/lib/biokbase/catalog/Server.py b/lib/biokbase/catalog/Server.py index ac40f11..5d38e50 100644 --- a/lib/biokbase/catalog/Server.py +++ b/lib/biokbase/catalog/Server.py @@ -517,6 +517,18 @@ def __init__(self): name='Catalog.is_admin', types=[basestring]) self.method_authentication['Catalog.is_admin'] = 'none' # noqa + self.rpc_service.add(impl_Catalog.set_hidden_config_params, + name='Catalog.set_hidden_config_params', + types=[dict]) + self.method_authentication['Catalog.set_hidden_config_params'] = 'required' # noqa + self.rpc_service.add(impl_Catalog.remove_hidden_config_params, + name='Catalog.remove_hidden_config_params', + types=[dict]) + self.method_authentication['Catalog.remove_hidden_config_params'] = 'required' # noqa + self.rpc_service.add(impl_Catalog.get_hidden_config_params, + name='Catalog.get_hidden_config_params', + types=[dict]) + self.method_authentication['Catalog.get_hidden_config_params'] = 'required' # noqa self.rpc_service.add(impl_Catalog.status, name='Catalog.status', types=[dict]) diff --git a/lib/biokbase/catalog/controller.py b/lib/biokbase/catalog/controller.py index dd87334..36fd7b9 100644 --- a/lib/biokbase/catalog/controller.py +++ b/lib/biokbase/catalog/controller.py @@ -1174,12 +1174,12 @@ def version(self): def log_exec_stats(self, admin_user_id, user_id, app_module_name, app_id, func_module_name, func_name, git_commit_hash, creation_time, exec_start_time, finish_time, - is_error): + is_error, job_id): if not self.is_admin(admin_user_id): raise ValueError('You do not have permission to log execution statistics.') self.db.add_exec_stats_raw(user_id, app_module_name, app_id, func_module_name, func_name, git_commit_hash, creation_time, exec_start_time, finish_time, - is_error) + is_error, job_id) parts = datetime.fromtimestamp(creation_time).isocalendar() week_time_range = str(parts[0]) + "-W" + str(parts[1]) self.db.add_exec_stats_apps(app_module_name, app_id, creation_time, exec_start_time, @@ -1444,10 +1444,43 @@ def list_volume_mounts(self, username, filter): return self.db.list_volume_mounts(processed_filter) + def set_hidden_config_params(self, username, params): + if not self.is_admin(username): + raise ValueError('You do not have permission to work with hidden configuration ' + + 'parameters.') + + if 'data' not in params: + raise ValueError('data parameter field is required') + if not isinstance(params['data'], list): + raise ValueError('data parameter field must be a list') + data_list = params['data'] + self.db.set_hidden_config_params(data_list) + + + def remove_hidden_config_params(self, username, params): + if not self.is_admin(username): + raise ValueError('You do not have permission to work with hidden configuration ' + + 'parameters.') + if 'data' not in params: + raise ValueError('data parameter field is required') + if not isinstance(params['data'], list): + raise ValueError('data parameter field must be a list') + data_list = params['data'] + self.db.remove_hidden_config_params(data_list) + def get_hidden_config_params(self, username, params): + if not self.is_admin(username): + raise ValueError('You do not have permission to work with hidden configuration ' + + 'parameters.') + if 'function_name' not in params: + raise ValueError('function_name parameter field is required') + if not isinstance(params['module_name'], basestring): + raise ValueError('module_name parameter field must be a string') + module_name = params['module_name'] + return self.db.get_hidden_config_params(module_name) diff --git a/lib/biokbase/catalog/db.py b/lib/biokbase/catalog/db.py index e1ec00d..819cf60 100644 --- a/lib/biokbase/catalog/db.py +++ b/lib/biokbase/catalog/db.py @@ -125,6 +125,7 @@ class MongoCatalogDBI: _EXEC_STATS_RAW='exec_stats_raw' _EXEC_STATS_APPS='exec_stats_apps' _EXEC_STATS_USERS='exec_stats_users' + _HIDDEN_CONFIG_PARAMS='hidden_config_params' def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): @@ -151,6 +152,8 @@ def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): self.exec_stats_apps = self.db[MongoCatalogDBI._EXEC_STATS_APPS] self.exec_stats_users = self.db[MongoCatalogDBI._EXEC_STATS_USERS] + self.hidden_config_params = self.db[MongoCatalogDBI._HIDDEN_CONFIG_PARAMS] + # check the db schema self.check_db_schema() @@ -241,6 +244,14 @@ def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): ('function_name', ASCENDING)], unique=True, sparse=False) + # hidden configuration parameters + self.local_functions.ensure_index('module_name_lc') + self.local_functions.ensure_index([ + ('module_name_lc',ASCENDING), + ('version_tag',ASCENDING), + ('param_name',ASCENDING)], + unique=True, sparse=False) + def is_registered(self,module_name='',git_url=''): if not module_name and not git_url: @@ -1083,7 +1094,8 @@ def _check_update_result(self, result): return '{}' def add_exec_stats_raw(self, user_id, app_module_name, app_id, func_module_name, func_name, - git_commit_hash, creation_time, exec_start_time, finish_time, is_error): + git_commit_hash, creation_time, exec_start_time, finish_time, is_error, + job_id): stats = { 'user_id': user_id, 'app_module_name': app_module_name, @@ -1094,7 +1106,8 @@ def add_exec_stats_raw(self, user_id, app_module_name, app_id, func_module_name, 'creation_time': creation_time, 'exec_start_time': exec_start_time, 'finish_time': finish_time, - 'is_error': is_error + 'is_error': is_error, + 'job_id': job_id } self.exec_stats_raw.insert(stats) @@ -1225,6 +1238,35 @@ def get_exec_raw_stats(self, minTime, maxTime): + def set_hidden_config_params(self, data_list): + for param_data in data_list: + param_data['module_name_lc'] = param_data['module_name'] + param_data['version_tag'] = param_data.get('version_tag', '') + self.hidden_config_params.update( + { + 'module_name_lc':param_data['module_name_lc'], + 'version_tag':param_data['version_tag'], + 'param_name':param_data['param_name'] + }, + param_data, + upsert=True) + + def remove_hidden_config_params(self, data_list): + for param_data in data_list: + param_data['module_name_lc'] = param_data['module_name'] + param_data['version_tag'] = param_data.get('version_tag', '') + self.hidden_config_params.remove( + { + 'module_name_lc':param_data['module_name_lc'], + 'version_tag':param_data['version_tag'], + 'param_name':param_data['param_name'] + }) + + def get_hidden_config_params(self, module_name): + selection = { "_id": 0, "module_name_lc": 0 } + filter = { "module_name_lc": module_name.lower() } + return list(self.hidden_config_params.find(filter, selection)) + # DB version handling diff --git a/lib/biokbase/catalog/version.py b/lib/biokbase/catalog/version.py index df5c1c9..5aef087 100644 --- a/lib/biokbase/catalog/version.py +++ b/lib/biokbase/catalog/version.py @@ -1,2 +1,2 @@ # File that simply defines version information -CATALOG_VERSION = '2.0.6' \ No newline at end of file +CATALOG_VERSION = '2.0.7' \ No newline at end of file diff --git a/lib/java/us/kbase/catalog/CatalogClient.java b/lib/java/us/kbase/catalog/CatalogClient.java index 85a2c85..5d9b98e 100644 --- a/lib/java/us/kbase/catalog/CatalogClient.java +++ b/lib/java/us/kbase/catalog/CatalogClient.java @@ -932,6 +932,56 @@ public Long isAdmin(String username, RpcContext... jsonRpcContext) throws IOExce return res.get(0); } + /** + *

Original spec-file function name: set_hidden_config_params

+ *
+     * Only admins can use this function.
+     * 
+ * @param params instance of type {@link us.kbase.catalog.ModifyHiddenConfigParamsInput ModifyHiddenConfigParamsInput} + * @throws IOException if an IO exception occurs + * @throws JsonClientException if a JSON RPC exception occurs + */ + public void setHiddenConfigParams(ModifyHiddenConfigParamsInput params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + List args = new ArrayList(); + args.add(params); + TypeReference retType = new TypeReference() {}; + caller.jsonrpcCall("Catalog.set_hidden_config_params", args, retType, false, true, jsonRpcContext, this.serviceVersion); + } + + /** + *

Original spec-file function name: remove_hidden_config_params

+ *
+     * Only admins can use this function.
+     * 
+ * @param params instance of type {@link us.kbase.catalog.ModifyHiddenConfigParamsInput ModifyHiddenConfigParamsInput} + * @throws IOException if an IO exception occurs + * @throws JsonClientException if a JSON RPC exception occurs + */ + public void removeHiddenConfigParams(ModifyHiddenConfigParamsInput params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + List args = new ArrayList(); + args.add(params); + TypeReference retType = new TypeReference() {}; + caller.jsonrpcCall("Catalog.remove_hidden_config_params", args, retType, false, true, jsonRpcContext, this.serviceVersion); + } + + /** + *

Original spec-file function name: get_hidden_config_params

+ *
+     * Only admins can use this function.
+     * 
+ * @param params instance of type {@link us.kbase.catalog.GetHiddenConfigParamsInput GetHiddenConfigParamsInput} + * @return instance of list of type {@link us.kbase.catalog.HiddenConfigParameter HiddenConfigParameter} + * @throws IOException if an IO exception occurs + * @throws JsonClientException if a JSON RPC exception occurs + */ + public List getHiddenConfigParams(GetHiddenConfigParamsInput params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + List args = new ArrayList(); + args.add(params); + TypeReference>> retType = new TypeReference>>() {}; + List> res = caller.jsonrpcCall("Catalog.get_hidden_config_params", args, retType, true, true, jsonRpcContext, this.serviceVersion); + return res.get(0); + } + public Map status(RpcContext... jsonRpcContext) throws IOException, JsonClientException { List args = new ArrayList(); TypeReference>> retType = new TypeReference>>() {}; diff --git a/lib/java/us/kbase/catalog/GetHiddenConfigParamsInput.java b/lib/java/us/kbase/catalog/GetHiddenConfigParamsInput.java new file mode 100644 index 0000000..a68d4ae --- /dev/null +++ b/lib/java/us/kbase/catalog/GetHiddenConfigParamsInput.java @@ -0,0 +1,60 @@ + +package us.kbase.catalog; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + *

Original spec-file type: GetHiddenConfigParamsInput

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("com.googlecode.jsonschema2pojo") +@JsonPropertyOrder({ + "module_name" +}) +public class GetHiddenConfigParamsInput { + + @JsonProperty("module_name") + private String moduleName; + private Map additionalProperties = new HashMap(); + + @JsonProperty("module_name") + public String getModuleName() { + return moduleName; + } + + @JsonProperty("module_name") + public void setModuleName(String moduleName) { + this.moduleName = moduleName; + } + + public GetHiddenConfigParamsInput withModuleName(String moduleName) { + this.moduleName = moduleName; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperties(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return ((((("GetHiddenConfigParamsInput"+" [moduleName=")+ moduleName)+", additionalProperties=")+ additionalProperties)+"]"); + } + +} diff --git a/lib/java/us/kbase/catalog/HiddenConfigParameter.java b/lib/java/us/kbase/catalog/HiddenConfigParameter.java new file mode 100644 index 0000000..e5d6807 --- /dev/null +++ b/lib/java/us/kbase/catalog/HiddenConfigParameter.java @@ -0,0 +1,136 @@ + +package us.kbase.catalog; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + *

Original spec-file type: HiddenConfigParameter

+ *
+ * version_tag - optional version (commit hash, tag or semantic one) of module, if not set
+ *     then default "" value is used which means parameter is applied to any version;
+ * is_password - optional flag meaning to hide this parameter's value in UI.
+ * 
+ * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("com.googlecode.jsonschema2pojo") +@JsonPropertyOrder({ + "module_name", + "version_tag", + "param_name", + "is_password", + "param_value" +}) +public class HiddenConfigParameter { + + @JsonProperty("module_name") + private String moduleName; + @JsonProperty("version_tag") + private String versionTag; + @JsonProperty("param_name") + private String paramName; + @JsonProperty("is_password") + private Long isPassword; + @JsonProperty("param_value") + private String paramValue; + private Map additionalProperties = new HashMap(); + + @JsonProperty("module_name") + public String getModuleName() { + return moduleName; + } + + @JsonProperty("module_name") + public void setModuleName(String moduleName) { + this.moduleName = moduleName; + } + + public HiddenConfigParameter withModuleName(String moduleName) { + this.moduleName = moduleName; + return this; + } + + @JsonProperty("version_tag") + public String getVersionTag() { + return versionTag; + } + + @JsonProperty("version_tag") + public void setVersionTag(String versionTag) { + this.versionTag = versionTag; + } + + public HiddenConfigParameter withVersionTag(String versionTag) { + this.versionTag = versionTag; + return this; + } + + @JsonProperty("param_name") + public String getParamName() { + return paramName; + } + + @JsonProperty("param_name") + public void setParamName(String paramName) { + this.paramName = paramName; + } + + public HiddenConfigParameter withParamName(String paramName) { + this.paramName = paramName; + return this; + } + + @JsonProperty("is_password") + public Long getIsPassword() { + return isPassword; + } + + @JsonProperty("is_password") + public void setIsPassword(Long isPassword) { + this.isPassword = isPassword; + } + + public HiddenConfigParameter withIsPassword(Long isPassword) { + this.isPassword = isPassword; + return this; + } + + @JsonProperty("param_value") + public String getParamValue() { + return paramValue; + } + + @JsonProperty("param_value") + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + + public HiddenConfigParameter withParamValue(String paramValue) { + this.paramValue = paramValue; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperties(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return ((((((((((((("HiddenConfigParameter"+" [moduleName=")+ moduleName)+", versionTag=")+ versionTag)+", paramName=")+ paramName)+", isPassword=")+ isPassword)+", paramValue=")+ paramValue)+", additionalProperties=")+ additionalProperties)+"]"); + } + +} diff --git a/lib/java/us/kbase/catalog/LogExecStatsParams.java b/lib/java/us/kbase/catalog/LogExecStatsParams.java index 4006d40..89ab8b4 100644 --- a/lib/java/us/kbase/catalog/LogExecStatsParams.java +++ b/lib/java/us/kbase/catalog/LogExecStatsParams.java @@ -40,7 +40,8 @@ "creation_time", "exec_start_time", "finish_time", - "is_error" + "is_error", + "job_id" }) public class LogExecStatsParams { @@ -64,6 +65,8 @@ public class LogExecStatsParams { private Double finishTime; @JsonProperty("is_error") private Long isError; + @JsonProperty("job_id") + private String jobId; private Map additionalProperties = new HashMap(); @JsonProperty("user_id") @@ -216,6 +219,21 @@ public LogExecStatsParams withIsError(Long isError) { return this; } + @JsonProperty("job_id") + public String getJobId() { + return jobId; + } + + @JsonProperty("job_id") + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public LogExecStatsParams withJobId(String jobId) { + this.jobId = jobId; + return this; + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; @@ -228,7 +246,7 @@ public void setAdditionalProperties(String name, Object value) { @Override public String toString() { - return ((((((((((((((((((((((("LogExecStatsParams"+" [userId=")+ userId)+", appModuleName=")+ appModuleName)+", appId=")+ appId)+", funcModuleName=")+ funcModuleName)+", funcName=")+ funcName)+", gitCommitHash=")+ gitCommitHash)+", creationTime=")+ creationTime)+", execStartTime=")+ execStartTime)+", finishTime=")+ finishTime)+", isError=")+ isError)+", additionalProperties=")+ additionalProperties)+"]"); + return ((((((((((((((((((((((((("LogExecStatsParams"+" [userId=")+ userId)+", appModuleName=")+ appModuleName)+", appId=")+ appId)+", funcModuleName=")+ funcModuleName)+", funcName=")+ funcName)+", gitCommitHash=")+ gitCommitHash)+", creationTime=")+ creationTime)+", execStartTime=")+ execStartTime)+", finishTime=")+ finishTime)+", isError=")+ isError)+", jobId=")+ jobId)+", additionalProperties=")+ additionalProperties)+"]"); } } diff --git a/lib/java/us/kbase/catalog/ModifyHiddenConfigParamsInput.java b/lib/java/us/kbase/catalog/ModifyHiddenConfigParamsInput.java new file mode 100644 index 0000000..934de4d --- /dev/null +++ b/lib/java/us/kbase/catalog/ModifyHiddenConfigParamsInput.java @@ -0,0 +1,61 @@ + +package us.kbase.catalog; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + *

Original spec-file type: ModifyHiddenConfigParamsInput

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("com.googlecode.jsonschema2pojo") +@JsonPropertyOrder({ + "data" +}) +public class ModifyHiddenConfigParamsInput { + + @JsonProperty("data") + private List data; + private Map additionalProperties = new HashMap(); + + @JsonProperty("data") + public List getData() { + return data; + } + + @JsonProperty("data") + public void setData(List data) { + this.data = data; + } + + public ModifyHiddenConfigParamsInput withData(List data) { + this.data = data; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperties(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return ((((("ModifyHiddenConfigParamsInput"+" [data=")+ data)+", additionalProperties=")+ additionalProperties)+"]"); + } + +} diff --git a/lib/javascript/Client.js b/lib/javascript/Client.js index 9c7cd40..5f36504 100644 --- a/lib/javascript/Client.js +++ b/lib/javascript/Client.js @@ -610,6 +610,45 @@ function Catalog(url, auth, auth_cb, timeout, async_job_check_time_ms, service_v return json_call_ajax(_url, "Catalog.is_admin", [username], 1, _callback, _errorCallback); }; + + this.set_hidden_config_params = function (params, _callback, _errorCallback) { + if (typeof params === 'function') + throw 'Argument params can not be a function'; + if (_callback && typeof _callback !== 'function') + throw 'Argument _callback must be a function if defined'; + if (_errorCallback && typeof _errorCallback !== 'function') + throw 'Argument _errorCallback must be a function if defined'; + if (typeof arguments === 'function' && arguments.length > 1+2) + throw 'Too many arguments ('+arguments.length+' instead of '+(1+2)+')'; + return json_call_ajax(_url, "Catalog.set_hidden_config_params", + [params], 0, _callback, _errorCallback); + }; + + this.remove_hidden_config_params = function (params, _callback, _errorCallback) { + if (typeof params === 'function') + throw 'Argument params can not be a function'; + if (_callback && typeof _callback !== 'function') + throw 'Argument _callback must be a function if defined'; + if (_errorCallback && typeof _errorCallback !== 'function') + throw 'Argument _errorCallback must be a function if defined'; + if (typeof arguments === 'function' && arguments.length > 1+2) + throw 'Too many arguments ('+arguments.length+' instead of '+(1+2)+')'; + return json_call_ajax(_url, "Catalog.remove_hidden_config_params", + [params], 0, _callback, _errorCallback); + }; + + this.get_hidden_config_params = function (params, _callback, _errorCallback) { + if (typeof params === 'function') + throw 'Argument params can not be a function'; + if (_callback && typeof _callback !== 'function') + throw 'Argument _callback must be a function if defined'; + if (_errorCallback && typeof _errorCallback !== 'function') + throw 'Argument _errorCallback must be a function if defined'; + if (typeof arguments === 'function' && arguments.length > 1+2) + throw 'Too many arguments ('+arguments.length+' instead of '+(1+2)+')'; + return json_call_ajax(_url, "Catalog.get_hidden_config_params", + [params], 1, _callback, _errorCallback); + }; this.status = function (_callback, _errorCallback) { if (_callback && typeof _callback !== 'function') diff --git a/test/basic_catalog_test.py b/test/basic_catalog_test.py index b5d2318..453a519 100644 --- a/test/basic_catalog_test.py +++ b/test/basic_catalog_test.py @@ -14,7 +14,7 @@ class BasicCatalogTest(unittest.TestCase): def test_version(self): - self.assertEqual(self.catalog.version(self.cUtil.anonymous_ctx()),['2.0.6']) + self.assertEqual(self.catalog.version(self.cUtil.anonymous_ctx()),['2.0.7']) def test_is_registered(self): diff --git a/test/execution_stats_test.py b/test/execution_stats_test.py index bcbfa5e..400fde3 100644 --- a/test/execution_stats_test.py +++ b/test/execution_stats_test.py @@ -105,8 +105,9 @@ def test_stats(self): start_delay = 50 end_delay = 500 - total_success = 0; - total_error = 0; + total_success = 0 + total_error = 0 + weird_job_id = "test_job_12345" for s in stats_to_add: #typedef structure { # string user_id; @@ -134,6 +135,8 @@ def test_stats(self): record['creation_time'] = random.randint(s['s'], s['e']) record['exec_start_time'] = record['creation_time'] + start_delay record['finish_time'] = record['exec_start_time'] + end_delay + if s['s'] > 1461169999 and s['s'] < 1461170101: + record['job_id'] = weird_job_id self.catalog.log_exec_stats(adminCtx, record) total_error += s['n_error'] for n in range(0,s['n_error']): @@ -163,6 +166,9 @@ def test_stats(self): restricted_stats = self.catalog.get_exec_raw_stats(adminCtx, {'begin': 1461169999, 'end': 1461170101})[0] self.assertEquals(len(restricted_stats), 20) + for row in restricted_stats: + self.assertTrue('job_id' in row) + self.assertEqual(row['job_id'], weird_job_id) # make sure we can get aggregations of things diff --git a/test/hidden_config_params_test.py b/test/hidden_config_params_test.py new file mode 100644 index 0000000..0afd9bb --- /dev/null +++ b/test/hidden_config_params_test.py @@ -0,0 +1,133 @@ +import unittest + +from catalog_test_util import CatalogTestUtil +from biokbase.catalog.Impl import Catalog + + +class HiddenConfigParamsTest(unittest.TestCase): + + + # assumes no client groups exist + def test_permissions(self): + + userCtx = self.cUtil.user_ctx() + adminCtx = self.cUtil.admin_ctx() + + with self.assertRaises(ValueError) as e: + self.catalog.get_hidden_config_params(userCtx, {}) + self.assertEqual(str(e.exception), 'You do not have permission to work with hidden ' + + 'configuration parameters.'); + + with self.assertRaises(ValueError) as e: + self.catalog.set_hidden_config_params(adminCtx, {}) + self.assertEqual(str(e.exception), + 'data parameter field is required'); + + with self.assertRaises(ValueError) as e: + self.catalog.remove_hidden_config_params(adminCtx, {}) + self.assertEqual(str(e.exception), + 'data parameter field is required'); + + with self.assertRaises(ValueError) as e: + self.catalog.get_hidden_config_params(adminCtx, {}) + self.assertEqual(str(e.exception), + 'module_name parameter field is required'); + + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test0'}) + self.assertEqual(len(params), 0) + + + def test_set_parameters(self): + adminCtx = self.cUtil.admin_ctx() + self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test1', + 'param_name': 'param0', + 'param_value': 'value0'}]}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test1'}) + self.assertEqual(len(params), 1) + self.assertEqual(params[0]['module_name'], 'Test1') + self.assertEqual(params[0]['param_name'], 'param0') + self.assertEqual(params[0]['param_value'], 'value0') + self.assertEqual(params[0]['version_tag'], '') + + self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test1', + 'param_name': 'param0', + 'param_value': 'value1'}]}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'Test1'}) + self.assertEqual(len(params), 1) + self.assertEqual(params[0]['param_value'], 'value1') + + self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test1', + 'param_name': 'param2', + 'param_value': 'value2'}]}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test1'}) + self.assertEqual(len(params), 2) + + + def test_remove_parameters(self): + adminCtx = self.cUtil.admin_ctx() + self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test2', + 'param_name': 'param0', + 'param_value': 'value0'}, + {'module_name': 'Test2', + 'param_name': 'param1', + 'param_value': 'value1'}]}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test2'}) + self.assertEqual(len(params), 2) + + self.catalog.remove_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test2', + 'param_name': 'param1'}]}) + + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test2'}) + self.assertEqual(len(params), 1) + self.assertEqual(params[0]['param_name'], 'param0') + self.assertEqual(params[0]['param_value'], 'value0') + + + def test_versions(self): + adminCtx = self.cUtil.admin_ctx() + self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3', + 'param_name': 'param0', + 'param_value': 'value0'}]}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'}) + self.assertEqual(len(params), 1) + + self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3', + 'param_name': 'param0', + 'version_tag': 'special_version', + 'param_value': 'value1'}]}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'}) + self.assertEqual(len(params), 2) + + self.catalog.remove_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3', + 'param_name': 'param0'}]}) + + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'}) + self.assertEqual(len(params), 1) + self.assertEqual(params[0]['param_name'], 'param0') + self.assertEqual(params[0]['param_value'], 'value0') + self.assertEqual(params[0]['version_tag'], 'special_version') + + self.catalog.remove_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3', + 'param_name': 'param0', + 'version_tag': 'special_version'}]}) + + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'}) + self.assertEqual(len(params), 0) + + + + @classmethod + def setUpClass(cls): + print('++++++++++++ RUNNING client_group_test.py +++++++++++') + cls.cUtil = CatalogTestUtil('.') # TODO: pass in test directory from outside + cls.cUtil.setUp() + cls.catalog = Catalog(cls.cUtil.getCatalogConfig()) + print('ready') + + @classmethod + def tearDownClass(cls): + cls.cUtil.tearDown() + + + + From e8ff5f3f424f000b325a8e2597856ba6cfd0c4d2 Mon Sep 17 00:00:00 2001 From: Roman Sutormin Date: Tue, 28 Mar 2017 16:05:42 -0700 Subject: [PATCH 03/13] Fix for typo in field name. --- lib/biokbase/catalog/controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/biokbase/catalog/controller.py b/lib/biokbase/catalog/controller.py index 36fd7b9..cfab931 100644 --- a/lib/biokbase/catalog/controller.py +++ b/lib/biokbase/catalog/controller.py @@ -1475,8 +1475,8 @@ def get_hidden_config_params(self, username, params): raise ValueError('You do not have permission to work with hidden configuration ' + 'parameters.') - if 'function_name' not in params: - raise ValueError('function_name parameter field is required') + if 'module_name' not in params: + raise ValueError('module_name parameter field is required') if not isinstance(params['module_name'], basestring): raise ValueError('module_name parameter field must be a string') module_name = params['module_name'] From 0f72650848040b29e1a42bfa8287f98a6dc94abe Mon Sep 17 00:00:00 2001 From: Roman Sutormin Date: Tue, 28 Mar 2017 16:27:21 -0700 Subject: [PATCH 04/13] One more typo in tests. --- test/hidden_config_params_test.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/hidden_config_params_test.py b/test/hidden_config_params_test.py index 0afd9bb..53ef93b 100644 --- a/test/hidden_config_params_test.py +++ b/test/hidden_config_params_test.py @@ -33,7 +33,7 @@ def test_permissions(self): self.assertEqual(str(e.exception), 'module_name parameter field is required'); - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test0'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test0'})[0] self.assertEqual(len(params), 0) @@ -42,7 +42,7 @@ def test_set_parameters(self): self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test1', 'param_name': 'param0', 'param_value': 'value0'}]}) - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test1'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test1'})[0] self.assertEqual(len(params), 1) self.assertEqual(params[0]['module_name'], 'Test1') self.assertEqual(params[0]['param_name'], 'param0') @@ -52,14 +52,14 @@ def test_set_parameters(self): self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test1', 'param_name': 'param0', 'param_value': 'value1'}]}) - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'Test1'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'Test1'})[0] self.assertEqual(len(params), 1) self.assertEqual(params[0]['param_value'], 'value1') self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test1', 'param_name': 'param2', 'param_value': 'value2'}]}) - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test1'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test1'})[0] self.assertEqual(len(params), 2) @@ -71,13 +71,13 @@ def test_remove_parameters(self): {'module_name': 'Test2', 'param_name': 'param1', 'param_value': 'value1'}]}) - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test2'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test2'})[0] self.assertEqual(len(params), 2) self.catalog.remove_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test2', 'param_name': 'param1'}]}) - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test2'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test2'})[0] self.assertEqual(len(params), 1) self.assertEqual(params[0]['param_name'], 'param0') self.assertEqual(params[0]['param_value'], 'value0') @@ -88,20 +88,20 @@ def test_versions(self): self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3', 'param_name': 'param0', 'param_value': 'value0'}]}) - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'})[0] self.assertEqual(len(params), 1) self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3', 'param_name': 'param0', 'version_tag': 'special_version', 'param_value': 'value1'}]}) - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'})[0] self.assertEqual(len(params), 2) self.catalog.remove_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3', 'param_name': 'param0'}]}) - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'})[0] self.assertEqual(len(params), 1) self.assertEqual(params[0]['param_name'], 'param0') self.assertEqual(params[0]['param_value'], 'value0') @@ -111,7 +111,7 @@ def test_versions(self): 'param_name': 'param0', 'version_tag': 'special_version'}]}) - params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'}) + params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'})[0] self.assertEqual(len(params), 0) From c0c8c6aa8cd443634e0908e264b237a373aeef34 Mon Sep 17 00:00:00 2001 From: Roman Sutormin Date: Tue, 28 Mar 2017 16:57:56 -0700 Subject: [PATCH 05/13] Methods were renamed. --- catalog.spec | 16 +-- lib/Bio/KBase/Catalog/Client.pm | 124 +++++++++--------- lib/biokbase/catalog/Client.py | 24 ++-- lib/biokbase/catalog/Impl.py | 40 +++--- lib/biokbase/catalog/Server.py | 18 +-- lib/biokbase/catalog/controller.py | 12 +- lib/biokbase/catalog/db.py | 24 ++-- lib/java/us/kbase/catalog/CatalogClient.java | 28 ++-- ...t.java => GetSecureConfigParamsInput.java} | 8 +- ...ava => ModifySecureConfigParamsInput.java} | 14 +- ...ameter.java => SecureConfigParameter.java} | 16 +-- lib/javascript/Client.js | 12 +- test/hidden_config_params_test.py | 46 +++---- 13 files changed, 191 insertions(+), 191 deletions(-) rename lib/java/us/kbase/catalog/{GetHiddenConfigParamsInput.java => GetSecureConfigParamsInput.java} (85%) rename lib/java/us/kbase/catalog/{ModifyHiddenConfigParamsInput.java => ModifySecureConfigParamsInput.java} (75%) rename lib/java/us/kbase/catalog/{HiddenConfigParameter.java => SecureConfigParameter.java} (87%) diff --git a/catalog.spec b/catalog.spec index 408bb11..ea01889 100644 --- a/catalog.spec +++ b/catalog.spec @@ -795,32 +795,32 @@ module Catalog { string param_name; boolean is_password; string param_value; - } HiddenConfigParameter; + } SecureConfigParameter; typedef structure { - list data; - } ModifyHiddenConfigParamsInput; + list data; + } ModifySecureConfigParamsInput; /* Only admins can use this function. */ - funcdef set_hidden_config_params(ModifyHiddenConfigParamsInput params) + funcdef set_secure_config_params(ModifySecureConfigParamsInput params) returns () authentication required; /* Only admins can use this function. */ - funcdef remove_hidden_config_params(ModifyHiddenConfigParamsInput params) + funcdef remove_secure_config_params(ModifySecureConfigParamsInput params) returns () authentication required; typedef structure { string module_name; - } GetHiddenConfigParamsInput; + } GetSecureConfigParamsInput; /* Only admins can use this function. */ - funcdef get_hidden_config_params(GetHiddenConfigParamsInput params) - returns (list) authentication required; + funcdef get_secure_config_params(GetSecureConfigParamsInput params) + returns (list) authentication required; }; diff --git a/lib/Bio/KBase/Catalog/Client.pm b/lib/Bio/KBase/Catalog/Client.pm index 67e010d..b41f916 100644 --- a/lib/Bio/KBase/Catalog/Client.pm +++ b/lib/Bio/KBase/Catalog/Client.pm @@ -4740,9 +4740,9 @@ returns true (1) if the user is an admin, false (0) otherwise -=head2 set_hidden_config_params +=head2 set_secure_config_params - $obj->set_hidden_config_params($params) + $obj->set_secure_config_params($params) =over 4 @@ -4751,10 +4751,10 @@ returns true (1) if the user is an admin, false (0) otherwise =begin html
-$params is a Catalog.ModifyHiddenConfigParamsInput
-ModifyHiddenConfigParamsInput is a reference to a hash where the following keys are defined:
-	data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter
-HiddenConfigParameter is a reference to a hash where the following keys are defined:
+$params is a Catalog.ModifySecureConfigParamsInput
+ModifySecureConfigParamsInput is a reference to a hash where the following keys are defined:
+	data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter
+SecureConfigParameter is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
 	version_tag has a value which is a string
 	param_name has a value which is a string
@@ -4768,10 +4768,10 @@ boolean is an int
 
 =begin text
 
-$params is a Catalog.ModifyHiddenConfigParamsInput
-ModifyHiddenConfigParamsInput is a reference to a hash where the following keys are defined:
-	data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter
-HiddenConfigParameter is a reference to a hash where the following keys are defined:
+$params is a Catalog.ModifySecureConfigParamsInput
+ModifySecureConfigParamsInput is a reference to a hash where the following keys are defined:
+	data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter
+SecureConfigParameter is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
 	version_tag has a value which is a string
 	param_name has a value which is a string
@@ -4790,7 +4790,7 @@ Only admins can use this function.
 
 =cut
 
- sub set_hidden_config_params
+ sub set_secure_config_params
 {
     my($self, @args) = @_;
 
@@ -4799,7 +4799,7 @@ Only admins can use this function.
     if ((my $n = @args) != 1)
     {
 	Bio::KBase::Exceptions::ArgumentValidationError->throw(error =>
-							       "Invalid argument count for function set_hidden_config_params (received $n, expecting 1)");
+							       "Invalid argument count for function set_secure_config_params (received $n, expecting 1)");
     }
     {
 	my($params) = @args;
@@ -4807,40 +4807,40 @@ Only admins can use this function.
 	my @_bad_arguments;
         (ref($params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"params\" (value was \"$params\")");
         if (@_bad_arguments) {
-	    my $msg = "Invalid arguments passed to set_hidden_config_params:\n" . join("", map { "\t$_\n" } @_bad_arguments);
+	    my $msg = "Invalid arguments passed to set_secure_config_params:\n" . join("", map { "\t$_\n" } @_bad_arguments);
 	    Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg,
-								   method_name => 'set_hidden_config_params');
+								   method_name => 'set_secure_config_params');
 	}
     }
 
     my $url = $self->{url};
     my $result = $self->{client}->call($url, $self->{headers}, {
-	    method => "Catalog.set_hidden_config_params",
+	    method => "Catalog.set_secure_config_params",
 	    params => \@args,
     });
     if ($result) {
 	if ($result->is_error) {
 	    Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message,
 					       code => $result->content->{error}->{code},
-					       method_name => 'set_hidden_config_params',
+					       method_name => 'set_secure_config_params',
 					       data => $result->content->{error}->{error} # JSON::RPC::ReturnObject only supports JSONRPC 1.1 or 1.O
 					      );
 	} else {
 	    return;
 	}
     } else {
-        Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method set_hidden_config_params",
+        Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method set_secure_config_params",
 					    status_line => $self->{client}->status_line,
-					    method_name => 'set_hidden_config_params',
+					    method_name => 'set_secure_config_params',
 				       );
     }
 }
  
 
 
-=head2 remove_hidden_config_params
+=head2 remove_secure_config_params
 
-  $obj->remove_hidden_config_params($params)
+  $obj->remove_secure_config_params($params)
 
 =over 4
 
@@ -4849,10 +4849,10 @@ Only admins can use this function.
 =begin html
 
 
-$params is a Catalog.ModifyHiddenConfigParamsInput
-ModifyHiddenConfigParamsInput is a reference to a hash where the following keys are defined:
-	data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter
-HiddenConfigParameter is a reference to a hash where the following keys are defined:
+$params is a Catalog.ModifySecureConfigParamsInput
+ModifySecureConfigParamsInput is a reference to a hash where the following keys are defined:
+	data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter
+SecureConfigParameter is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
 	version_tag has a value which is a string
 	param_name has a value which is a string
@@ -4866,10 +4866,10 @@ boolean is an int
 
 =begin text
 
-$params is a Catalog.ModifyHiddenConfigParamsInput
-ModifyHiddenConfigParamsInput is a reference to a hash where the following keys are defined:
-	data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter
-HiddenConfigParameter is a reference to a hash where the following keys are defined:
+$params is a Catalog.ModifySecureConfigParamsInput
+ModifySecureConfigParamsInput is a reference to a hash where the following keys are defined:
+	data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter
+SecureConfigParameter is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
 	version_tag has a value which is a string
 	param_name has a value which is a string
@@ -4888,7 +4888,7 @@ Only admins can use this function.
 
 =cut
 
- sub remove_hidden_config_params
+ sub remove_secure_config_params
 {
     my($self, @args) = @_;
 
@@ -4897,7 +4897,7 @@ Only admins can use this function.
     if ((my $n = @args) != 1)
     {
 	Bio::KBase::Exceptions::ArgumentValidationError->throw(error =>
-							       "Invalid argument count for function remove_hidden_config_params (received $n, expecting 1)");
+							       "Invalid argument count for function remove_secure_config_params (received $n, expecting 1)");
     }
     {
 	my($params) = @args;
@@ -4905,40 +4905,40 @@ Only admins can use this function.
 	my @_bad_arguments;
         (ref($params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"params\" (value was \"$params\")");
         if (@_bad_arguments) {
-	    my $msg = "Invalid arguments passed to remove_hidden_config_params:\n" . join("", map { "\t$_\n" } @_bad_arguments);
+	    my $msg = "Invalid arguments passed to remove_secure_config_params:\n" . join("", map { "\t$_\n" } @_bad_arguments);
 	    Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg,
-								   method_name => 'remove_hidden_config_params');
+								   method_name => 'remove_secure_config_params');
 	}
     }
 
     my $url = $self->{url};
     my $result = $self->{client}->call($url, $self->{headers}, {
-	    method => "Catalog.remove_hidden_config_params",
+	    method => "Catalog.remove_secure_config_params",
 	    params => \@args,
     });
     if ($result) {
 	if ($result->is_error) {
 	    Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message,
 					       code => $result->content->{error}->{code},
-					       method_name => 'remove_hidden_config_params',
+					       method_name => 'remove_secure_config_params',
 					       data => $result->content->{error}->{error} # JSON::RPC::ReturnObject only supports JSONRPC 1.1 or 1.O
 					      );
 	} else {
 	    return;
 	}
     } else {
-        Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method remove_hidden_config_params",
+        Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method remove_secure_config_params",
 					    status_line => $self->{client}->status_line,
-					    method_name => 'remove_hidden_config_params',
+					    method_name => 'remove_secure_config_params',
 				       );
     }
 }
  
 
 
-=head2 get_hidden_config_params
+=head2 get_secure_config_params
 
-  $return = $obj->get_hidden_config_params($params)
+  $return = $obj->get_secure_config_params($params)
 
 =over 4
 
@@ -4947,11 +4947,11 @@ Only admins can use this function.
 =begin html
 
 
-$params is a Catalog.GetHiddenConfigParamsInput
-$return is a reference to a list where each element is a Catalog.HiddenConfigParameter
-GetHiddenConfigParamsInput is a reference to a hash where the following keys are defined:
+$params is a Catalog.GetSecureConfigParamsInput
+$return is a reference to a list where each element is a Catalog.SecureConfigParameter
+GetSecureConfigParamsInput is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
-HiddenConfigParameter is a reference to a hash where the following keys are defined:
+SecureConfigParameter is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
 	version_tag has a value which is a string
 	param_name has a value which is a string
@@ -4965,11 +4965,11 @@ boolean is an int
 
 =begin text
 
-$params is a Catalog.GetHiddenConfigParamsInput
-$return is a reference to a list where each element is a Catalog.HiddenConfigParameter
-GetHiddenConfigParamsInput is a reference to a hash where the following keys are defined:
+$params is a Catalog.GetSecureConfigParamsInput
+$return is a reference to a list where each element is a Catalog.SecureConfigParameter
+GetSecureConfigParamsInput is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
-HiddenConfigParameter is a reference to a hash where the following keys are defined:
+SecureConfigParameter is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
 	version_tag has a value which is a string
 	param_name has a value which is a string
@@ -4988,7 +4988,7 @@ Only admins can use this function.
 
 =cut
 
- sub get_hidden_config_params
+ sub get_secure_config_params
 {
     my($self, @args) = @_;
 
@@ -4997,7 +4997,7 @@ Only admins can use this function.
     if ((my $n = @args) != 1)
     {
 	Bio::KBase::Exceptions::ArgumentValidationError->throw(error =>
-							       "Invalid argument count for function get_hidden_config_params (received $n, expecting 1)");
+							       "Invalid argument count for function get_secure_config_params (received $n, expecting 1)");
     }
     {
 	my($params) = @args;
@@ -5005,31 +5005,31 @@ Only admins can use this function.
 	my @_bad_arguments;
         (ref($params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"params\" (value was \"$params\")");
         if (@_bad_arguments) {
-	    my $msg = "Invalid arguments passed to get_hidden_config_params:\n" . join("", map { "\t$_\n" } @_bad_arguments);
+	    my $msg = "Invalid arguments passed to get_secure_config_params:\n" . join("", map { "\t$_\n" } @_bad_arguments);
 	    Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg,
-								   method_name => 'get_hidden_config_params');
+								   method_name => 'get_secure_config_params');
 	}
     }
 
     my $url = $self->{url};
     my $result = $self->{client}->call($url, $self->{headers}, {
-	    method => "Catalog.get_hidden_config_params",
+	    method => "Catalog.get_secure_config_params",
 	    params => \@args,
     });
     if ($result) {
 	if ($result->is_error) {
 	    Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message,
 					       code => $result->content->{error}->{code},
-					       method_name => 'get_hidden_config_params',
+					       method_name => 'get_secure_config_params',
 					       data => $result->content->{error}->{error} # JSON::RPC::ReturnObject only supports JSONRPC 1.1 or 1.O
 					      );
 	} else {
 	    return wantarray ? @{$result->result} : $result->result->[0];
 	}
     } else {
-        Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method get_hidden_config_params",
+        Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method get_secure_config_params",
 					    status_line => $self->{client}->status_line,
-					    method_name => 'get_hidden_config_params',
+					    method_name => 'get_secure_config_params',
 				       );
     }
 }
@@ -5077,16 +5077,16 @@ sub version {
             Bio::KBase::Exceptions::JSONRPC->throw(
                 error => $result->error_message,
                 code => $result->content->{code},
-                method_name => 'get_hidden_config_params',
+                method_name => 'get_secure_config_params',
             );
         } else {
             return wantarray ? @{$result->result} : $result->result->[0];
         }
     } else {
         Bio::KBase::Exceptions::HTTP->throw(
-            error => "Error invoking method get_hidden_config_params",
+            error => "Error invoking method get_secure_config_params",
             status_line => $self->{client}->status_line,
-            method_name => 'get_hidden_config_params',
+            method_name => 'get_secure_config_params',
         );
     }
 }
@@ -7301,7 +7301,7 @@ client_group has a value which is a string
 
 
 
-=head2 HiddenConfigParameter
+=head2 SecureConfigParameter
 
 =over 4
 
@@ -7346,7 +7346,7 @@ param_value has a value which is a string
 
 
 
-=head2 ModifyHiddenConfigParamsInput
+=head2 ModifySecureConfigParamsInput
 
 =over 4
 
@@ -7358,7 +7358,7 @@ param_value has a value which is a string
 
 
 a reference to a hash where the following keys are defined:
-data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter
+data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter
 
 
@@ -7367,7 +7367,7 @@ data has a value which is a reference to a list where each element is a Catalog. =begin text a reference to a hash where the following keys are defined: -data has a value which is a reference to a list where each element is a Catalog.HiddenConfigParameter +data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter =end text @@ -7376,7 +7376,7 @@ data has a value which is a reference to a list where each element is a Catalog. -=head2 GetHiddenConfigParamsInput +=head2 GetSecureConfigParamsInput =over 4 diff --git a/lib/biokbase/catalog/Client.py b/lib/biokbase/catalog/Client.py index 37d7d32..94a4271 100644 --- a/lib/biokbase/catalog/Client.py +++ b/lib/biokbase/catalog/Client.py @@ -1009,12 +1009,12 @@ def is_admin(self, username, context=None): 'Catalog.is_admin', [username], self._service_ver, context) - def set_hidden_config_params(self, params, context=None): + def set_secure_config_params(self, params, context=None): """ Only admins can use this function. - :param params: instance of type "ModifyHiddenConfigParamsInput" -> + :param params: instance of type "ModifySecureConfigParamsInput" -> structure: parameter "data" of list of type - "HiddenConfigParameter" (version_tag - optional version (commit + "SecureConfigParameter" (version_tag - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value @@ -1024,15 +1024,15 @@ def set_hidden_config_params(self, params, context=None): parameter "param_value" of String """ return self._client.call_method( - 'Catalog.set_hidden_config_params', + 'Catalog.set_secure_config_params', [params], self._service_ver, context) - def remove_hidden_config_params(self, params, context=None): + def remove_secure_config_params(self, params, context=None): """ Only admins can use this function. - :param params: instance of type "ModifyHiddenConfigParamsInput" -> + :param params: instance of type "ModifySecureConfigParamsInput" -> structure: parameter "data" of list of type - "HiddenConfigParameter" (version_tag - optional version (commit + "SecureConfigParameter" (version_tag - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value @@ -1042,15 +1042,15 @@ def remove_hidden_config_params(self, params, context=None): parameter "param_value" of String """ return self._client.call_method( - 'Catalog.remove_hidden_config_params', + 'Catalog.remove_secure_config_params', [params], self._service_ver, context) - def get_hidden_config_params(self, params, context=None): + def get_secure_config_params(self, params, context=None): """ Only admins can use this function. - :param params: instance of type "GetHiddenConfigParamsInput" -> + :param params: instance of type "GetSecureConfigParamsInput" -> structure: parameter "module_name" of String - :returns: instance of list of type "HiddenConfigParameter" + :returns: instance of list of type "SecureConfigParameter" (version_tag - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means parameter is applied to any version; is_password - optional flag @@ -1060,7 +1060,7 @@ def get_hidden_config_params(self, params, context=None): of type "boolean" (@range [0,1]), parameter "param_value" of String """ return self._client.call_method( - 'Catalog.get_hidden_config_params', + 'Catalog.get_secure_config_params', [params], self._service_ver, context) def status(self, context=None): diff --git a/lib/biokbase/catalog/Impl.py b/lib/biokbase/catalog/Impl.py index 1485587..c4d5ce0 100644 --- a/lib/biokbase/catalog/Impl.py +++ b/lib/biokbase/catalog/Impl.py @@ -22,7 +22,7 @@ class Catalog: ######################################### noqa VERSION = "0.0.1" GIT_URL = "https://github.com/kbase/catalog" - GIT_COMMIT_HASH = "6858eb635ce51972b6e3b6dc6f8c367be6a79b75" + GIT_COMMIT_HASH = "0f72650848040b29e1a42bfa8287f98a6dc94abe" #BEGIN_CLASS_HEADER #END_CLASS_HEADER @@ -1361,12 +1361,12 @@ def is_admin(self, ctx, username): # return the results return [returnVal] - def set_hidden_config_params(self, ctx, params): + def set_secure_config_params(self, ctx, params): """ Only admins can use this function. - :param params: instance of type "ModifyHiddenConfigParamsInput" -> + :param params: instance of type "ModifySecureConfigParamsInput" -> structure: parameter "data" of list of type - "HiddenConfigParameter" (version_tag - optional version (commit + "SecureConfigParameter" (version_tag - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value @@ -1376,17 +1376,17 @@ def set_hidden_config_params(self, ctx, params): parameter "param_value" of String """ # ctx is the context object - #BEGIN set_hidden_config_params - self.cc.set_hidden_config_params(ctx['user_id'], params) - #END set_hidden_config_params + #BEGIN set_secure_config_params + self.cc.set_secure_config_params(ctx['user_id'], params) + #END set_secure_config_params pass - def remove_hidden_config_params(self, ctx, params): + def remove_secure_config_params(self, ctx, params): """ Only admins can use this function. - :param params: instance of type "ModifyHiddenConfigParamsInput" -> + :param params: instance of type "ModifySecureConfigParamsInput" -> structure: parameter "data" of list of type - "HiddenConfigParameter" (version_tag - optional version (commit + "SecureConfigParameter" (version_tag - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value @@ -1396,17 +1396,17 @@ def remove_hidden_config_params(self, ctx, params): parameter "param_value" of String """ # ctx is the context object - #BEGIN remove_hidden_config_params - self.cc.remove_hidden_config_params(ctx['user_id'], params) - #END remove_hidden_config_params + #BEGIN remove_secure_config_params + self.cc.remove_secure_config_params(ctx['user_id'], params) + #END remove_secure_config_params pass - def get_hidden_config_params(self, ctx, params): + def get_secure_config_params(self, ctx, params): """ Only admins can use this function. - :param params: instance of type "GetHiddenConfigParamsInput" -> + :param params: instance of type "GetSecureConfigParamsInput" -> structure: parameter "module_name" of String - :returns: instance of list of type "HiddenConfigParameter" + :returns: instance of list of type "SecureConfigParameter" (version_tag - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means parameter is applied to any version; is_password - optional flag @@ -1417,13 +1417,13 @@ def get_hidden_config_params(self, ctx, params): """ # ctx is the context object # return variables are: returnVal - #BEGIN get_hidden_config_params - returnVal = self.cc.get_hidden_config_params(ctx['user_id'], params) - #END get_hidden_config_params + #BEGIN get_secure_config_params + returnVal = self.cc.get_secure_config_params(ctx['user_id'], params) + #END get_secure_config_params # At some point might do deeper type checking... if not isinstance(returnVal, list): - raise ValueError('Method get_hidden_config_params return value ' + + raise ValueError('Method get_secure_config_params return value ' + 'returnVal is not type list as required.') # return the results return [returnVal] diff --git a/lib/biokbase/catalog/Server.py b/lib/biokbase/catalog/Server.py index 5d38e50..c2f5952 100644 --- a/lib/biokbase/catalog/Server.py +++ b/lib/biokbase/catalog/Server.py @@ -517,18 +517,18 @@ def __init__(self): name='Catalog.is_admin', types=[basestring]) self.method_authentication['Catalog.is_admin'] = 'none' # noqa - self.rpc_service.add(impl_Catalog.set_hidden_config_params, - name='Catalog.set_hidden_config_params', + self.rpc_service.add(impl_Catalog.set_secure_config_params, + name='Catalog.set_secure_config_params', types=[dict]) - self.method_authentication['Catalog.set_hidden_config_params'] = 'required' # noqa - self.rpc_service.add(impl_Catalog.remove_hidden_config_params, - name='Catalog.remove_hidden_config_params', + self.method_authentication['Catalog.set_secure_config_params'] = 'required' # noqa + self.rpc_service.add(impl_Catalog.remove_secure_config_params, + name='Catalog.remove_secure_config_params', types=[dict]) - self.method_authentication['Catalog.remove_hidden_config_params'] = 'required' # noqa - self.rpc_service.add(impl_Catalog.get_hidden_config_params, - name='Catalog.get_hidden_config_params', + self.method_authentication['Catalog.remove_secure_config_params'] = 'required' # noqa + self.rpc_service.add(impl_Catalog.get_secure_config_params, + name='Catalog.get_secure_config_params', types=[dict]) - self.method_authentication['Catalog.get_hidden_config_params'] = 'required' # noqa + self.method_authentication['Catalog.get_secure_config_params'] = 'required' # noqa self.rpc_service.add(impl_Catalog.status, name='Catalog.status', types=[dict]) diff --git a/lib/biokbase/catalog/controller.py b/lib/biokbase/catalog/controller.py index cfab931..89685ed 100644 --- a/lib/biokbase/catalog/controller.py +++ b/lib/biokbase/catalog/controller.py @@ -1444,7 +1444,7 @@ def list_volume_mounts(self, username, filter): return self.db.list_volume_mounts(processed_filter) - def set_hidden_config_params(self, username, params): + def set_secure_config_params(self, username, params): if not self.is_admin(username): raise ValueError('You do not have permission to work with hidden configuration ' + 'parameters.') @@ -1454,10 +1454,10 @@ def set_hidden_config_params(self, username, params): if not isinstance(params['data'], list): raise ValueError('data parameter field must be a list') data_list = params['data'] - self.db.set_hidden_config_params(data_list) + self.db.set_secure_config_params(data_list) - def remove_hidden_config_params(self, username, params): + def remove_secure_config_params(self, username, params): if not self.is_admin(username): raise ValueError('You do not have permission to work with hidden configuration ' + 'parameters.') @@ -1467,10 +1467,10 @@ def remove_hidden_config_params(self, username, params): if not isinstance(params['data'], list): raise ValueError('data parameter field must be a list') data_list = params['data'] - self.db.remove_hidden_config_params(data_list) + self.db.remove_secure_config_params(data_list) - def get_hidden_config_params(self, username, params): + def get_secure_config_params(self, username, params): if not self.is_admin(username): raise ValueError('You do not have permission to work with hidden configuration ' + 'parameters.') @@ -1480,7 +1480,7 @@ def get_hidden_config_params(self, username, params): if not isinstance(params['module_name'], basestring): raise ValueError('module_name parameter field must be a string') module_name = params['module_name'] - return self.db.get_hidden_config_params(module_name) + return self.db.get_secure_config_params(module_name) diff --git a/lib/biokbase/catalog/db.py b/lib/biokbase/catalog/db.py index 819cf60..c3f8b32 100644 --- a/lib/biokbase/catalog/db.py +++ b/lib/biokbase/catalog/db.py @@ -125,7 +125,7 @@ class MongoCatalogDBI: _EXEC_STATS_RAW='exec_stats_raw' _EXEC_STATS_APPS='exec_stats_apps' _EXEC_STATS_USERS='exec_stats_users' - _HIDDEN_CONFIG_PARAMS='hidden_config_params' + _SECURE_CONFIG_PARAMS='secure_config_params' def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): @@ -152,7 +152,7 @@ def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): self.exec_stats_apps = self.db[MongoCatalogDBI._EXEC_STATS_APPS] self.exec_stats_users = self.db[MongoCatalogDBI._EXEC_STATS_USERS] - self.hidden_config_params = self.db[MongoCatalogDBI._HIDDEN_CONFIG_PARAMS] + self.secure_config_params = self.db[MongoCatalogDBI._SECURE_CONFIG_PARAMS] # check the db schema self.check_db_schema() @@ -245,8 +245,8 @@ def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): unique=True, sparse=False) # hidden configuration parameters - self.local_functions.ensure_index('module_name_lc') - self.local_functions.ensure_index([ + self.secure_config_params.ensure_index('module_name_lc') + self.secure_config_params.ensure_index([ ('module_name_lc',ASCENDING), ('version_tag',ASCENDING), ('param_name',ASCENDING)], @@ -1238,11 +1238,11 @@ def get_exec_raw_stats(self, minTime, maxTime): - def set_hidden_config_params(self, data_list): + def set_secure_config_params(self, data_list): for param_data in data_list: - param_data['module_name_lc'] = param_data['module_name'] + param_data['module_name_lc'] = param_data['module_name'].lower() param_data['version_tag'] = param_data.get('version_tag', '') - self.hidden_config_params.update( + self.secure_config_params.update( { 'module_name_lc':param_data['module_name_lc'], 'version_tag':param_data['version_tag'], @@ -1251,21 +1251,21 @@ def set_hidden_config_params(self, data_list): param_data, upsert=True) - def remove_hidden_config_params(self, data_list): + def remove_secure_config_params(self, data_list): for param_data in data_list: - param_data['module_name_lc'] = param_data['module_name'] + param_data['module_name_lc'] = param_data['module_name'].lower() param_data['version_tag'] = param_data.get('version_tag', '') - self.hidden_config_params.remove( + self.secure_config_params.remove( { 'module_name_lc':param_data['module_name_lc'], 'version_tag':param_data['version_tag'], 'param_name':param_data['param_name'] }) - def get_hidden_config_params(self, module_name): + def get_secure_config_params(self, module_name): selection = { "_id": 0, "module_name_lc": 0 } filter = { "module_name_lc": module_name.lower() } - return list(self.hidden_config_params.find(filter, selection)) + return list(self.secure_config_params.find(filter, selection)) diff --git a/lib/java/us/kbase/catalog/CatalogClient.java b/lib/java/us/kbase/catalog/CatalogClient.java index 5d9b98e..21beab0 100644 --- a/lib/java/us/kbase/catalog/CatalogClient.java +++ b/lib/java/us/kbase/catalog/CatalogClient.java @@ -933,52 +933,52 @@ public Long isAdmin(String username, RpcContext... jsonRpcContext) throws IOExce } /** - *

Original spec-file function name: set_hidden_config_params

+ *

Original spec-file function name: set_secure_config_params

*
      * Only admins can use this function.
      * 
- * @param params instance of type {@link us.kbase.catalog.ModifyHiddenConfigParamsInput ModifyHiddenConfigParamsInput} + * @param params instance of type {@link us.kbase.catalog.ModifySecureConfigParamsInput ModifySecureConfigParamsInput} * @throws IOException if an IO exception occurs * @throws JsonClientException if a JSON RPC exception occurs */ - public void setHiddenConfigParams(ModifyHiddenConfigParamsInput params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + public void setSecureConfigParams(ModifySecureConfigParamsInput params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { List args = new ArrayList(); args.add(params); TypeReference retType = new TypeReference() {}; - caller.jsonrpcCall("Catalog.set_hidden_config_params", args, retType, false, true, jsonRpcContext, this.serviceVersion); + caller.jsonrpcCall("Catalog.set_secure_config_params", args, retType, false, true, jsonRpcContext, this.serviceVersion); } /** - *

Original spec-file function name: remove_hidden_config_params

+ *

Original spec-file function name: remove_secure_config_params

*
      * Only admins can use this function.
      * 
- * @param params instance of type {@link us.kbase.catalog.ModifyHiddenConfigParamsInput ModifyHiddenConfigParamsInput} + * @param params instance of type {@link us.kbase.catalog.ModifySecureConfigParamsInput ModifySecureConfigParamsInput} * @throws IOException if an IO exception occurs * @throws JsonClientException if a JSON RPC exception occurs */ - public void removeHiddenConfigParams(ModifyHiddenConfigParamsInput params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + public void removeSecureConfigParams(ModifySecureConfigParamsInput params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { List args = new ArrayList(); args.add(params); TypeReference retType = new TypeReference() {}; - caller.jsonrpcCall("Catalog.remove_hidden_config_params", args, retType, false, true, jsonRpcContext, this.serviceVersion); + caller.jsonrpcCall("Catalog.remove_secure_config_params", args, retType, false, true, jsonRpcContext, this.serviceVersion); } /** - *

Original spec-file function name: get_hidden_config_params

+ *

Original spec-file function name: get_secure_config_params

*
      * Only admins can use this function.
      * 
- * @param params instance of type {@link us.kbase.catalog.GetHiddenConfigParamsInput GetHiddenConfigParamsInput} - * @return instance of list of type {@link us.kbase.catalog.HiddenConfigParameter HiddenConfigParameter} + * @param params instance of type {@link us.kbase.catalog.GetSecureConfigParamsInput GetSecureConfigParamsInput} + * @return instance of list of type {@link us.kbase.catalog.SecureConfigParameter SecureConfigParameter} * @throws IOException if an IO exception occurs * @throws JsonClientException if a JSON RPC exception occurs */ - public List getHiddenConfigParams(GetHiddenConfigParamsInput params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + public List getSecureConfigParams(GetSecureConfigParamsInput params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { List args = new ArrayList(); args.add(params); - TypeReference>> retType = new TypeReference>>() {}; - List> res = caller.jsonrpcCall("Catalog.get_hidden_config_params", args, retType, true, true, jsonRpcContext, this.serviceVersion); + TypeReference>> retType = new TypeReference>>() {}; + List> res = caller.jsonrpcCall("Catalog.get_secure_config_params", args, retType, true, true, jsonRpcContext, this.serviceVersion); return res.get(0); } diff --git a/lib/java/us/kbase/catalog/GetHiddenConfigParamsInput.java b/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java similarity index 85% rename from lib/java/us/kbase/catalog/GetHiddenConfigParamsInput.java rename to lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java index a68d4ae..267f040 100644 --- a/lib/java/us/kbase/catalog/GetHiddenConfigParamsInput.java +++ b/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java @@ -12,7 +12,7 @@ /** - *

Original spec-file type: GetHiddenConfigParamsInput

+ *

Original spec-file type: GetSecureConfigParamsInput

* * */ @@ -21,7 +21,7 @@ @JsonPropertyOrder({ "module_name" }) -public class GetHiddenConfigParamsInput { +public class GetSecureConfigParamsInput { @JsonProperty("module_name") private String moduleName; @@ -37,7 +37,7 @@ public void setModuleName(String moduleName) { this.moduleName = moduleName; } - public GetHiddenConfigParamsInput withModuleName(String moduleName) { + public GetSecureConfigParamsInput withModuleName(String moduleName) { this.moduleName = moduleName; return this; } @@ -54,7 +54,7 @@ public void setAdditionalProperties(String name, Object value) { @Override public String toString() { - return ((((("GetHiddenConfigParamsInput"+" [moduleName=")+ moduleName)+", additionalProperties=")+ additionalProperties)+"]"); + return ((((("GetSecureConfigParamsInput"+" [moduleName=")+ moduleName)+", additionalProperties=")+ additionalProperties)+"]"); } } diff --git a/lib/java/us/kbase/catalog/ModifyHiddenConfigParamsInput.java b/lib/java/us/kbase/catalog/ModifySecureConfigParamsInput.java similarity index 75% rename from lib/java/us/kbase/catalog/ModifyHiddenConfigParamsInput.java rename to lib/java/us/kbase/catalog/ModifySecureConfigParamsInput.java index 934de4d..563a4c6 100644 --- a/lib/java/us/kbase/catalog/ModifyHiddenConfigParamsInput.java +++ b/lib/java/us/kbase/catalog/ModifySecureConfigParamsInput.java @@ -13,7 +13,7 @@ /** - *

Original spec-file type: ModifyHiddenConfigParamsInput

+ *

Original spec-file type: ModifySecureConfigParamsInput

* * */ @@ -22,23 +22,23 @@ @JsonPropertyOrder({ "data" }) -public class ModifyHiddenConfigParamsInput { +public class ModifySecureConfigParamsInput { @JsonProperty("data") - private List data; + private List data; private Map additionalProperties = new HashMap(); @JsonProperty("data") - public List getData() { + public List getData() { return data; } @JsonProperty("data") - public void setData(List data) { + public void setData(List data) { this.data = data; } - public ModifyHiddenConfigParamsInput withData(List data) { + public ModifySecureConfigParamsInput withData(List data) { this.data = data; return this; } @@ -55,7 +55,7 @@ public void setAdditionalProperties(String name, Object value) { @Override public String toString() { - return ((((("ModifyHiddenConfigParamsInput"+" [data=")+ data)+", additionalProperties=")+ additionalProperties)+"]"); + return ((((("ModifySecureConfigParamsInput"+" [data=")+ data)+", additionalProperties=")+ additionalProperties)+"]"); } } diff --git a/lib/java/us/kbase/catalog/HiddenConfigParameter.java b/lib/java/us/kbase/catalog/SecureConfigParameter.java similarity index 87% rename from lib/java/us/kbase/catalog/HiddenConfigParameter.java rename to lib/java/us/kbase/catalog/SecureConfigParameter.java index e5d6807..d0c62ff 100644 --- a/lib/java/us/kbase/catalog/HiddenConfigParameter.java +++ b/lib/java/us/kbase/catalog/SecureConfigParameter.java @@ -12,7 +12,7 @@ /** - *

Original spec-file type: HiddenConfigParameter

+ *

Original spec-file type: SecureConfigParameter

*
  * version_tag - optional version (commit hash, tag or semantic one) of module, if not set
  *     then default "" value is used which means parameter is applied to any version;
@@ -29,7 +29,7 @@
     "is_password",
     "param_value"
 })
-public class HiddenConfigParameter {
+public class SecureConfigParameter {
 
     @JsonProperty("module_name")
     private String moduleName;
@@ -53,7 +53,7 @@ public void setModuleName(String moduleName) {
         this.moduleName = moduleName;
     }
 
-    public HiddenConfigParameter withModuleName(String moduleName) {
+    public SecureConfigParameter withModuleName(String moduleName) {
         this.moduleName = moduleName;
         return this;
     }
@@ -68,7 +68,7 @@ public void setVersionTag(String versionTag) {
         this.versionTag = versionTag;
     }
 
-    public HiddenConfigParameter withVersionTag(String versionTag) {
+    public SecureConfigParameter withVersionTag(String versionTag) {
         this.versionTag = versionTag;
         return this;
     }
@@ -83,7 +83,7 @@ public void setParamName(String paramName) {
         this.paramName = paramName;
     }
 
-    public HiddenConfigParameter withParamName(String paramName) {
+    public SecureConfigParameter withParamName(String paramName) {
         this.paramName = paramName;
         return this;
     }
@@ -98,7 +98,7 @@ public void setIsPassword(Long isPassword) {
         this.isPassword = isPassword;
     }
 
-    public HiddenConfigParameter withIsPassword(Long isPassword) {
+    public SecureConfigParameter withIsPassword(Long isPassword) {
         this.isPassword = isPassword;
         return this;
     }
@@ -113,7 +113,7 @@ public void setParamValue(String paramValue) {
         this.paramValue = paramValue;
     }
 
-    public HiddenConfigParameter withParamValue(String paramValue) {
+    public SecureConfigParameter withParamValue(String paramValue) {
         this.paramValue = paramValue;
         return this;
     }
@@ -130,7 +130,7 @@ public void setAdditionalProperties(String name, Object value) {
 
     @Override
     public String toString() {
-        return ((((((((((((("HiddenConfigParameter"+" [moduleName=")+ moduleName)+", versionTag=")+ versionTag)+", paramName=")+ paramName)+", isPassword=")+ isPassword)+", paramValue=")+ paramValue)+", additionalProperties=")+ additionalProperties)+"]");
+        return ((((((((((((("SecureConfigParameter"+" [moduleName=")+ moduleName)+", versionTag=")+ versionTag)+", paramName=")+ paramName)+", isPassword=")+ isPassword)+", paramValue=")+ paramValue)+", additionalProperties=")+ additionalProperties)+"]");
     }
 
 }
diff --git a/lib/javascript/Client.js b/lib/javascript/Client.js
index 5f36504..88a0d6e 100644
--- a/lib/javascript/Client.js
+++ b/lib/javascript/Client.js
@@ -611,7 +611,7 @@ function Catalog(url, auth, auth_cb, timeout, async_job_check_time_ms, service_v
             [username], 1, _callback, _errorCallback);
     };
  
-     this.set_hidden_config_params = function (params, _callback, _errorCallback) {
+     this.set_secure_config_params = function (params, _callback, _errorCallback) {
         if (typeof params === 'function')
             throw 'Argument params can not be a function';
         if (_callback && typeof _callback !== 'function')
@@ -620,11 +620,11 @@ function Catalog(url, auth, auth_cb, timeout, async_job_check_time_ms, service_v
             throw 'Argument _errorCallback must be a function if defined';
         if (typeof arguments === 'function' && arguments.length > 1+2)
             throw 'Too many arguments ('+arguments.length+' instead of '+(1+2)+')';
-        return json_call_ajax(_url, "Catalog.set_hidden_config_params",
+        return json_call_ajax(_url, "Catalog.set_secure_config_params",
             [params], 0, _callback, _errorCallback);
     };
  
-     this.remove_hidden_config_params = function (params, _callback, _errorCallback) {
+     this.remove_secure_config_params = function (params, _callback, _errorCallback) {
         if (typeof params === 'function')
             throw 'Argument params can not be a function';
         if (_callback && typeof _callback !== 'function')
@@ -633,11 +633,11 @@ function Catalog(url, auth, auth_cb, timeout, async_job_check_time_ms, service_v
             throw 'Argument _errorCallback must be a function if defined';
         if (typeof arguments === 'function' && arguments.length > 1+2)
             throw 'Too many arguments ('+arguments.length+' instead of '+(1+2)+')';
-        return json_call_ajax(_url, "Catalog.remove_hidden_config_params",
+        return json_call_ajax(_url, "Catalog.remove_secure_config_params",
             [params], 0, _callback, _errorCallback);
     };
  
-     this.get_hidden_config_params = function (params, _callback, _errorCallback) {
+     this.get_secure_config_params = function (params, _callback, _errorCallback) {
         if (typeof params === 'function')
             throw 'Argument params can not be a function';
         if (_callback && typeof _callback !== 'function')
@@ -646,7 +646,7 @@ function Catalog(url, auth, auth_cb, timeout, async_job_check_time_ms, service_v
             throw 'Argument _errorCallback must be a function if defined';
         if (typeof arguments === 'function' && arguments.length > 1+2)
             throw 'Too many arguments ('+arguments.length+' instead of '+(1+2)+')';
-        return json_call_ajax(_url, "Catalog.get_hidden_config_params",
+        return json_call_ajax(_url, "Catalog.get_secure_config_params",
             [params], 1, _callback, _errorCallback);
     };
   
diff --git a/test/hidden_config_params_test.py b/test/hidden_config_params_test.py
index 53ef93b..4aee878 100644
--- a/test/hidden_config_params_test.py
+++ b/test/hidden_config_params_test.py
@@ -14,70 +14,70 @@ def test_permissions(self):
         adminCtx = self.cUtil.admin_ctx()
 
         with self.assertRaises(ValueError) as e:
-            self.catalog.get_hidden_config_params(userCtx, {})
+            self.catalog.get_secure_config_params(userCtx, {})
         self.assertEqual(str(e.exception), 'You do not have permission to work with hidden ' + 
                          'configuration parameters.');
 
         with self.assertRaises(ValueError) as e:
-            self.catalog.set_hidden_config_params(adminCtx, {})
+            self.catalog.set_secure_config_params(adminCtx, {})
         self.assertEqual(str(e.exception),
             'data parameter field is required');
 
         with self.assertRaises(ValueError) as e:
-            self.catalog.remove_hidden_config_params(adminCtx, {})
+            self.catalog.remove_secure_config_params(adminCtx, {})
         self.assertEqual(str(e.exception),
             'data parameter field is required');
 
         with self.assertRaises(ValueError) as e:
-            self.catalog.get_hidden_config_params(adminCtx, {})
+            self.catalog.get_secure_config_params(adminCtx, {})
         self.assertEqual(str(e.exception),
             'module_name parameter field is required');
 
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test0'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test0'})[0]
         self.assertEqual(len(params), 0)
         
 
     def test_set_parameters(self):
         adminCtx = self.cUtil.admin_ctx()
-        self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test1',
+        self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test1',
                                                                    'param_name': 'param0',
                                                                    'param_value': 'value0'}]})
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test1'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test1'})[0]
         self.assertEqual(len(params), 1)
         self.assertEqual(params[0]['module_name'], 'Test1')
         self.assertEqual(params[0]['param_name'], 'param0')
         self.assertEqual(params[0]['param_value'], 'value0')
         self.assertEqual(params[0]['version_tag'], '')
 
-        self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test1',
+        self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test1',
                                                                    'param_name': 'param0',
                                                                    'param_value': 'value1'}]})
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'Test1'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'Test1'})[0]
         self.assertEqual(len(params), 1)
         self.assertEqual(params[0]['param_value'], 'value1')
 
-        self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test1',
+        self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test1',
                                                                    'param_name': 'param2',
                                                                    'param_value': 'value2'}]})
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test1'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test1'})[0]
         self.assertEqual(len(params), 2)
 
 
     def test_remove_parameters(self):
         adminCtx = self.cUtil.admin_ctx()
-        self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test2',
+        self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test2',
                                                                    'param_name': 'param0',
                                                                    'param_value': 'value0'},
                                                                   {'module_name': 'Test2',
                                                                    'param_name': 'param1',
                                                                    'param_value': 'value1'}]})
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test2'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test2'})[0]
         self.assertEqual(len(params), 2)
 
-        self.catalog.remove_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test2',
+        self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': 'Test2',
                                                                       'param_name': 'param1'}]})
 
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test2'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test2'})[0]
         self.assertEqual(len(params), 1)
         self.assertEqual(params[0]['param_name'], 'param0')
         self.assertEqual(params[0]['param_value'], 'value0')
@@ -85,33 +85,33 @@ def test_remove_parameters(self):
 
     def test_versions(self):
         adminCtx = self.cUtil.admin_ctx()
-        self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3',
+        self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3',
                                                                    'param_name': 'param0',
                                                                    'param_value': 'value0'}]})
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3'})[0]
         self.assertEqual(len(params), 1)
 
-        self.catalog.set_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3',
+        self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3',
                                                                    'param_name': 'param0',
                                                                    'version_tag': 'special_version',
                                                                    'param_value': 'value1'}]})
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3'})[0]
         self.assertEqual(len(params), 2)
 
-        self.catalog.remove_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3',
+        self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3',
                                                                       'param_name': 'param0'}]})
 
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3'})[0]
         self.assertEqual(len(params), 1)
         self.assertEqual(params[0]['param_name'], 'param0')
         self.assertEqual(params[0]['param_value'], 'value0')
         self.assertEqual(params[0]['version_tag'], 'special_version')
 
-        self.catalog.remove_hidden_config_params(adminCtx, {'data': [{'module_name': 'Test3',
+        self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3',
                                                                       'param_name': 'param0',
                                                                       'version_tag': 'special_version'}]})
 
-        params = self.catalog.get_hidden_config_params(adminCtx, {'module_name': 'test3'})[0]
+        params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3'})[0]
         self.assertEqual(len(params), 0)
 
 

From e5423769a64d67ddcb310169c2a1fd1d4e6bf089 Mon Sep 17 00:00:00 2001
From: Roman Sutormin 
Date: Tue, 28 Mar 2017 17:24:55 -0700
Subject: [PATCH 06/13] And one more fix in tests.

---
 test/hidden_config_params_test.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/hidden_config_params_test.py b/test/hidden_config_params_test.py
index 4aee878..ad421dd 100644
--- a/test/hidden_config_params_test.py
+++ b/test/hidden_config_params_test.py
@@ -104,7 +104,7 @@ def test_versions(self):
         params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3'})[0]
         self.assertEqual(len(params), 1)
         self.assertEqual(params[0]['param_name'], 'param0')
-        self.assertEqual(params[0]['param_value'], 'value0')
+        self.assertEqual(params[0]['param_value'], 'value1')
         self.assertEqual(params[0]['version_tag'], 'special_version')
 
         self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3',

From c50f0fdf683f3c20c831d743bc5b2f6ac3998994 Mon Sep 17 00:00:00 2001
From: Roman Sutormin 
Date: Wed, 29 Mar 2017 16:29:25 -0700
Subject: [PATCH 07/13] Test coverage is improved.

---
 ...s_test.py => secure_config_params_test.py} | 53 ++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)
 rename test/{hidden_config_params_test.py => secure_config_params_test.py} (74%)

diff --git a/test/hidden_config_params_test.py b/test/secure_config_params_test.py
similarity index 74%
rename from test/hidden_config_params_test.py
rename to test/secure_config_params_test.py
index ad421dd..bc977ac 100644
--- a/test/hidden_config_params_test.py
+++ b/test/secure_config_params_test.py
@@ -10,29 +10,80 @@ class HiddenConfigParamsTest(unittest.TestCase):
     # assumes no client groups exist
     def test_permissions(self):
 
+        anonCtx = self.cUtil.anonymous_ctx()
         userCtx = self.cUtil.user_ctx()
-        adminCtx = self.cUtil.admin_ctx()
+
+        # set_secure_config_params
+        with self.assertRaises(ValueError) as e:
+            self.catalog.set_secure_config_params(anonCtx, {})
+        self.assertEqual(str(e.exception), 'You do not have permission to work with hidden ' + 
+                         'configuration parameters.');
+
+        with self.assertRaises(ValueError) as e:
+            self.catalog.set_secure_config_params(userCtx, {})
+        self.assertEqual(str(e.exception), 'You do not have permission to work with hidden ' + 
+                         'configuration parameters.');
+
+        # remove_secure_config_params
+        with self.assertRaises(ValueError) as e:
+            self.catalog.remove_secure_config_params(anonCtx, {})
+        self.assertEqual(str(e.exception), 'You do not have permission to work with hidden ' + 
+                         'configuration parameters.');
+
+        with self.assertRaises(ValueError) as e:
+            self.catalog.remove_secure_config_params(userCtx, {})
+        self.assertEqual(str(e.exception), 'You do not have permission to work with hidden ' + 
+                         'configuration parameters.');
+
+        # get_secure_config_params
+        with self.assertRaises(ValueError) as e:
+            self.catalog.get_secure_config_params(anonCtx, {})
+        self.assertEqual(str(e.exception), 'You do not have permission to work with hidden ' + 
+                         'configuration parameters.');
 
         with self.assertRaises(ValueError) as e:
             self.catalog.get_secure_config_params(userCtx, {})
         self.assertEqual(str(e.exception), 'You do not have permission to work with hidden ' + 
                          'configuration parameters.');
 
+
+    def test_errors(self):
+        adminCtx = self.cUtil.admin_ctx()
+
         with self.assertRaises(ValueError) as e:
             self.catalog.set_secure_config_params(adminCtx, {})
         self.assertEqual(str(e.exception),
             'data parameter field is required');
 
+        with self.assertRaises(ValueError) as e:
+            self.catalog.set_secure_config_params(adminCtx, {'data': "test"})
+        self.assertEqual(str(e.exception),
+            'data parameter field must be a list');
+
         with self.assertRaises(ValueError) as e:
             self.catalog.remove_secure_config_params(adminCtx, {})
         self.assertEqual(str(e.exception),
             'data parameter field is required');
 
+        with self.assertRaises(ValueError) as e:
+            self.catalog.remove_secure_config_params(adminCtx, {'data': "test"})
+        self.assertEqual(str(e.exception),
+            'data parameter field must be a list');
+
         with self.assertRaises(ValueError) as e:
             self.catalog.get_secure_config_params(adminCtx, {})
         self.assertEqual(str(e.exception),
             'module_name parameter field is required');
 
+        with self.assertRaises(ValueError) as e:
+            self.catalog.get_secure_config_params(adminCtx, {'module_name': [1, 2, 3]})
+        self.assertEqual(str(e.exception),
+            'module_name parameter field must be a string');
+
+
+    def test_no_data(self):
+        adminCtx = self.cUtil.admin_ctx()
+
         params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test0'})[0]
         self.assertEqual(len(params), 0)
         

From 9e8629d79b7dce22ca6801d05d75158032fad4fc Mon Sep 17 00:00:00 2001
From: Roman Sutormin 
Date: Wed, 29 Mar 2017 17:04:07 -0700
Subject: [PATCH 08/13] Fix for absent user ID in RPC context (unauthenticated
 calls).

---
 lib/biokbase/catalog/Impl.py       | 6 +++---
 lib/biokbase/catalog/controller.py | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/biokbase/catalog/Impl.py b/lib/biokbase/catalog/Impl.py
index c4d5ce0..dc15807 100644
--- a/lib/biokbase/catalog/Impl.py
+++ b/lib/biokbase/catalog/Impl.py
@@ -1377,7 +1377,7 @@ def set_secure_config_params(self, ctx, params):
         """
         # ctx is the context object
         #BEGIN set_secure_config_params
-        self.cc.set_secure_config_params(ctx['user_id'], params)
+        self.cc.set_secure_config_params(ctx.get('user_id'), params)
         #END set_secure_config_params
         pass
 
@@ -1397,7 +1397,7 @@ def remove_secure_config_params(self, ctx, params):
         """
         # ctx is the context object
         #BEGIN remove_secure_config_params
-        self.cc.remove_secure_config_params(ctx['user_id'], params)
+        self.cc.remove_secure_config_params(ctx.get('user_id'), params)
         #END remove_secure_config_params
         pass
 
@@ -1418,7 +1418,7 @@ def get_secure_config_params(self, ctx, params):
         # ctx is the context object
         # return variables are: returnVal
         #BEGIN get_secure_config_params
-        returnVal = self.cc.get_secure_config_params(ctx['user_id'], params)
+        returnVal = self.cc.get_secure_config_params(ctx.get('user_id'), params)
         #END get_secure_config_params
 
         # At some point might do deeper type checking...
diff --git a/lib/biokbase/catalog/controller.py b/lib/biokbase/catalog/controller.py
index 89685ed..f1091d6 100644
--- a/lib/biokbase/catalog/controller.py
+++ b/lib/biokbase/catalog/controller.py
@@ -1445,7 +1445,7 @@ def list_volume_mounts(self, username, filter):
 
 
     def set_secure_config_params(self, username, params):
-        if not self.is_admin(username):
+        if username is None or not self.is_admin(username):
             raise ValueError('You do not have permission to work with hidden configuration ' +
                              'parameters.')
         
@@ -1458,7 +1458,7 @@ def set_secure_config_params(self, username, params):
 
 
     def remove_secure_config_params(self, username, params):
-        if not self.is_admin(username):
+        if username is None or not self.is_admin(username):
             raise ValueError('You do not have permission to work with hidden configuration ' +
                              'parameters.')
 
@@ -1471,7 +1471,7 @@ def remove_secure_config_params(self, username, params):
 
 
     def get_secure_config_params(self, username, params):
-        if not self.is_admin(username):
+        if username is None or not self.is_admin(username):
             raise ValueError('You do not have permission to work with hidden configuration ' +
                              'parameters.')
 

From 1d3fa708d1642a1988bac99b35ce20f2d730a322 Mon Sep 17 00:00:00 2001
From: Roman Sutormin 
Date: Thu, 30 Mar 2017 12:13:10 -0700
Subject: [PATCH 09/13] Adding logic for filtering secure configuration
 parameters by version.

---
 catalog.spec                                  |  13 ++-
 lib/Bio/KBase/Catalog/Client.pm               |  23 +++-
 lib/biokbase/catalog/Client.py                |  11 +-
 lib/biokbase/catalog/Impl.py                  |  13 ++-
 lib/biokbase/catalog/controller.py            |  27 ++++-
 .../catalog/GetSecureConfigParamsInput.java   |  50 ++++++++-
 test/secure_config_params_test.py             | 101 ++++++++++++++++--
 7 files changed, 214 insertions(+), 24 deletions(-)

diff --git a/catalog.spec b/catalog.spec
index ea01889..2f8c50a 100644
--- a/catalog.spec
+++ b/catalog.spec
@@ -812,9 +812,20 @@ module Catalog {
     */
     funcdef remove_secure_config_params(ModifySecureConfigParamsInput params) 
         returns () authentication required;
-    
+
+    /*
+        version - a lookup string, if empty will get the latest released module
+                    1) version tag = dev | beta | release
+                    2) semantic version match identifiier
+                    not supported yet: 3) exact commit hash
+                    not supported yet: 4) exact timestamp
+        load_all_versions - flag indicating that all parameter versions should be 
+                    loaded (version_lookup filter is not applied)
+    */    
     typedef structure {
         string module_name;
+        string version_lookup;
+        boolean load_all_versions;
     } GetSecureConfigParamsInput;
 
     /*
diff --git a/lib/Bio/KBase/Catalog/Client.pm b/lib/Bio/KBase/Catalog/Client.pm
index b41f916..22fa55f 100644
--- a/lib/Bio/KBase/Catalog/Client.pm
+++ b/lib/Bio/KBase/Catalog/Client.pm
@@ -4951,13 +4951,15 @@ $params is a Catalog.GetSecureConfigParamsInput
 $return is a reference to a list where each element is a Catalog.SecureConfigParameter
 GetSecureConfigParamsInput is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
+	version_lookup has a value which is a string
+	load_all_versions has a value which is a Catalog.boolean
+boolean is an int
 SecureConfigParameter is a reference to a hash where the following keys are defined:
 	module_name has a value which is a string
 	version_tag has a value which is a string
 	param_name has a value which is a string
 	is_password has a value which is a Catalog.boolean
 	param_value has a value which is a string
-boolean is an int
 
 
@@ -4969,13 +4971,15 @@ $params is a Catalog.GetSecureConfigParamsInput $return is a reference to a list where each element is a Catalog.SecureConfigParameter GetSecureConfigParamsInput is a reference to a hash where the following keys are defined: module_name has a value which is a string + version_lookup has a value which is a string + load_all_versions has a value which is a Catalog.boolean +boolean is an int SecureConfigParameter is a reference to a hash where the following keys are defined: module_name has a value which is a string version_tag has a value which is a string param_name has a value which is a string is_password has a value which is a Catalog.boolean param_value has a value which is a string -boolean is an int =end text @@ -7382,6 +7386,17 @@ data has a value which is a reference to a list where each element is a Catalog. +=item Description + +version_lookup - a lookup string, if empty will get the latest released module + 1) version tag = dev | beta | release + 2) semantic version match identifiier + not supported yet: 3) exact commit hash + not supported yet: 4) exact timestamp +load_all_versions - flag indicating that all parameter versions should be + loaded (version_lookup filter is not applied) + + =item Definition =begin html @@ -7389,6 +7404,8 @@ data has a value which is a reference to a list where each element is a Catalog.
 a reference to a hash where the following keys are defined:
 module_name has a value which is a string
+version_lookup has a value which is a string
+load_all_versions has a value which is a Catalog.boolean
 
 
@@ -7398,6 +7415,8 @@ module_name has a value which is a string a reference to a hash where the following keys are defined: module_name has a value which is a string +version_lookup has a value which is a string +load_all_versions has a value which is a Catalog.boolean =end text diff --git a/lib/biokbase/catalog/Client.py b/lib/biokbase/catalog/Client.py index 94a4271..d554944 100644 --- a/lib/biokbase/catalog/Client.py +++ b/lib/biokbase/catalog/Client.py @@ -1048,8 +1048,15 @@ def remove_secure_config_params(self, params, context=None): def get_secure_config_params(self, params, context=None): """ Only admins can use this function. - :param params: instance of type "GetSecureConfigParamsInput" -> - structure: parameter "module_name" of String + :param params: instance of type "GetSecureConfigParamsInput" + (version_lookup - a lookup string, if empty will get the latest + released module 1) version tag = dev | beta | release 2) semantic + version match identifiier not supported yet: 3) exact commit hash + not supported yet: 4) exact timestamp load_all_versions - flag + indicating that all parameter versions should be loaded + (version_lookup filter is not applied)) -> structure: parameter + "module_name" of String, parameter "version_lookup" of String, + parameter "load_all_versions" of type "boolean" (@range [0,1]) :returns: instance of list of type "SecureConfigParameter" (version_tag - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means diff --git a/lib/biokbase/catalog/Impl.py b/lib/biokbase/catalog/Impl.py index dc15807..ee28182 100644 --- a/lib/biokbase/catalog/Impl.py +++ b/lib/biokbase/catalog/Impl.py @@ -22,7 +22,7 @@ class Catalog: ######################################### noqa VERSION = "0.0.1" GIT_URL = "https://github.com/kbase/catalog" - GIT_COMMIT_HASH = "0f72650848040b29e1a42bfa8287f98a6dc94abe" + GIT_COMMIT_HASH = "744fce8634cf56e952bd291fa6b789a618df6b3c" #BEGIN_CLASS_HEADER #END_CLASS_HEADER @@ -1404,8 +1404,15 @@ def remove_secure_config_params(self, ctx, params): def get_secure_config_params(self, ctx, params): """ Only admins can use this function. - :param params: instance of type "GetSecureConfigParamsInput" -> - structure: parameter "module_name" of String + :param params: instance of type "GetSecureConfigParamsInput" + (version_lookup - a lookup string, if empty will get the latest + released module 1) version tag = dev | beta | release 2) semantic + version match identifiier not supported yet: 3) exact commit hash + not supported yet: 4) exact timestamp load_all_versions - flag + indicating that all parameter versions should be loaded + (version_lookup filter is not applied)) -> structure: parameter + "module_name" of String, parameter "version_lookup" of String, + parameter "load_all_versions" of type "boolean" (@range [0,1]) :returns: instance of list of type "SecureConfigParameter" (version_tag - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means diff --git a/lib/biokbase/catalog/controller.py b/lib/biokbase/catalog/controller.py index f1091d6..f7721b4 100644 --- a/lib/biokbase/catalog/controller.py +++ b/lib/biokbase/catalog/controller.py @@ -1477,10 +1477,31 @@ def get_secure_config_params(self, username, params): if 'module_name' not in params: raise ValueError('module_name parameter field is required') - if not isinstance(params['module_name'], basestring): - raise ValueError('module_name parameter field must be a string') module_name = params['module_name'] - return self.db.get_secure_config_params(module_name) + if not isinstance(module_name, basestring): + raise ValueError('module_name parameter field must be a string') + version_lookup = params.get('version_lookup') + if version_lookup and not isinstance(version_lookup, basestring): + raise ValueError('version_lookup parameter field must be a string') + load_all_versions = params.get('load_all_versions') + secure_param_list = self.db.get_secure_config_params(module_name) + if load_all_versions: + return secure_param_list + mv = self.get_module_version({'module_name': module_name, 'version': version}) + param_map = {} + for secure_param in secure_param_list: + param_name = secure_param['param_name'] + version_tag = secure_param.get('version_tag') + # If version_tag is defined and doesn't match any known version we skip it: + if version_tag and not (version_tag == mv['git_commit_hash'] or + version_tag == mv['version'] or + version_tag in mv['release_tags']): + continue + # We may override previous param_name value if it had empty version_tag previously: + if param_name not in param_map or not param_map[param_name].get('version_tag'): + param_map[param_name] = secure_param + return [param_map[param_name] for param_name in param_map] + diff --git a/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java b/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java index 267f040..7aff32e 100644 --- a/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java +++ b/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java @@ -13,18 +13,32 @@ /** *

Original spec-file type: GetSecureConfigParamsInput

- * + *
+ * version_lookup - a lookup string, if empty will get the latest released module
+ *             1) version tag = dev | beta | release
+ *             2) semantic version match identifiier
+ *             not supported yet: 3) exact commit hash
+ *             not supported yet: 4) exact timestamp
+ * load_all_versions - flag indicating that all parameter versions should be 
+ *             loaded (version_lookup filter is not applied)
+ * 
* */ @JsonInclude(JsonInclude.Include.NON_NULL) @Generated("com.googlecode.jsonschema2pojo") @JsonPropertyOrder({ - "module_name" + "module_name", + "version_lookup", + "load_all_versions" }) public class GetSecureConfigParamsInput { @JsonProperty("module_name") private String moduleName; + @JsonProperty("version_lookup") + private String versionLookup; + @JsonProperty("load_all_versions") + private Long loadAllVersions; private Map additionalProperties = new HashMap(); @JsonProperty("module_name") @@ -42,6 +56,36 @@ public GetSecureConfigParamsInput withModuleName(String moduleName) { return this; } + @JsonProperty("version_lookup") + public String getVersionLookup() { + return versionLookup; + } + + @JsonProperty("version_lookup") + public void setVersionLookup(String versionLookup) { + this.versionLookup = versionLookup; + } + + public GetSecureConfigParamsInput withVersionLookup(String versionLookup) { + this.versionLookup = versionLookup; + return this; + } + + @JsonProperty("load_all_versions") + public Long getLoadAllVersions() { + return loadAllVersions; + } + + @JsonProperty("load_all_versions") + public void setLoadAllVersions(Long loadAllVersions) { + this.loadAllVersions = loadAllVersions; + } + + public GetSecureConfigParamsInput withLoadAllVersions(Long loadAllVersions) { + this.loadAllVersions = loadAllVersions; + return this; + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; @@ -54,7 +98,7 @@ public void setAdditionalProperties(String name, Object value) { @Override public String toString() { - return ((((("GetSecureConfigParamsInput"+" [moduleName=")+ moduleName)+", additionalProperties=")+ additionalProperties)+"]"); + return ((((((((("GetSecureConfigParamsInput"+" [moduleName=")+ moduleName)+", versionLookup=")+ versionLookup)+", loadAllVersions=")+ loadAllVersions)+", additionalProperties=")+ additionalProperties)+"]"); } } diff --git a/test/secure_config_params_test.py b/test/secure_config_params_test.py index bc977ac..9926607 100644 --- a/test/secure_config_params_test.py +++ b/test/secure_config_params_test.py @@ -84,7 +84,8 @@ def test_errors(self): def test_no_data(self): adminCtx = self.cUtil.admin_ctx() - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test0'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test0', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 0) @@ -93,7 +94,8 @@ def test_set_parameters(self): self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test1', 'param_name': 'param0', 'param_value': 'value0'}]}) - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test1'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test1', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 1) self.assertEqual(params[0]['module_name'], 'Test1') self.assertEqual(params[0]['param_name'], 'param0') @@ -103,14 +105,16 @@ def test_set_parameters(self): self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test1', 'param_name': 'param0', 'param_value': 'value1'}]}) - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'Test1'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'Test1', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 1) self.assertEqual(params[0]['param_value'], 'value1') self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test1', 'param_name': 'param2', 'param_value': 'value2'}]}) - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test1'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test1', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 2) @@ -122,13 +126,15 @@ def test_remove_parameters(self): {'module_name': 'Test2', 'param_name': 'param1', 'param_value': 'value1'}]}) - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test2'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test2', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 2) self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': 'Test2', 'param_name': 'param1'}]}) - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test2'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test2', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 1) self.assertEqual(params[0]['param_name'], 'param0') self.assertEqual(params[0]['param_value'], 'value0') @@ -139,20 +145,23 @@ def test_versions(self): self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3', 'param_name': 'param0', 'param_value': 'value0'}]}) - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 1) self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3', 'param_name': 'param0', 'version_tag': 'special_version', 'param_value': 'value1'}]}) - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 2) self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3', 'param_name': 'param0'}]}) - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 1) self.assertEqual(params[0]['param_name'], 'param0') self.assertEqual(params[0]['param_value'], 'value1') @@ -162,10 +171,82 @@ def test_versions(self): 'param_name': 'param0', 'version_tag': 'special_version'}]}) - params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3'})[0] + params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3', + 'load_all_versions': 1})[0] self.assertEqual(len(params), 0) + def test_module_versions(self): + adminCtx = self.cUtil.admin_ctx() + module_name = 'onerepotest' + version_tag = 'dev' + mv = self.catalog.get_module_version(adminCtx, {'module_name': module_name, + 'version': version_tag})[0] + git_commit_hash = mv['git_commit_hash'] + semantic_version = mv['version'] + + garbage = 'garbage' + param_name = 'param0' + self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': module_name, + 'param_name': param_name, + 'param_value': 'value0'}, + {'module_name': module_name, + 'param_name': param_name, + 'version_tag': garbage, + 'param_value': 'value1'}]}) + self.check_secure_param_value(module_name, version_tag, 'param0', 'value0') + + self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': module_name, + 'param_name': param_name, + 'version_tag': garbage}]}) + self.check_secure_param_value(module_name, version_tag, 'param0', 'value0') + self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value0') + self.check_secure_param_value(module_name, semantic_version, 'param0', 'value0') + + self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': module_name, + 'param_name': param_name, + 'version_tag': version_tag, + 'param_value': 'value1'}]}) + self.check_secure_param_value(module_name, version_tag, 'param0', 'value1') + self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value1') + self.check_secure_param_value(module_name, semantic_version, 'param0', 'value1') + + self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': module_name, + 'param_name': param_name, + 'version_tag': version_tag}]}) + self.check_secure_param_value(module_name, version_tag, 'param0', 'value0') + + self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': module_name, + 'param_name': param_name, + 'version_tag': git_commit_hash, + 'param_value': 'value2'}]}) + self.check_secure_param_value(module_name, version_tag, 'param0', 'value2') + self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value2') + self.check_secure_param_value(module_name, semantic_version, 'param0', 'value2') + + self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': module_name, + 'param_name': param_name, + 'version_tag': git_commit_hash}]}) + self.check_secure_param_value(module_name, version_tag, 'param0', 'value0') + + self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': module_name, + 'param_name': param_name, + 'version_tag': semantic_version, + 'param_value': 'value3'}]}) + self.check_secure_param_value(module_name, version_tag, 'param0', 'value3') + self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value3') + self.check_secure_param_value(module_name, semantic_version, 'param0', 'value3') + + + + def check_secure_param_value(self, module_name, version_tag, param_name, param_value): + params = self.catalog.get_secure_config_params(self.cUtil.admin_ctx(), + {'module_name': module_name, + 'version_tag': version_tag})[0] + self.assertEqual(len(params), 1) + self.assertEqual(params[0]['param_name'], param_name) + self.assertEqual(params[0]['param_value'], param_value) + @classmethod def setUpClass(cls): From 4cf181a762b9f0cf337a0201b58e213352937957 Mon Sep 17 00:00:00 2001 From: Roman Sutormin Date: Thu, 30 Mar 2017 12:47:25 -0700 Subject: [PATCH 10/13] Small change in KIDL-spec API for version fields in secure parameters. --- catalog.spec | 17 +++--- lib/Bio/KBase/Catalog/Client.pm | 37 ++++++------ lib/biokbase/catalog/Client.py | 57 +++++++++--------- lib/biokbase/catalog/Impl.py | 59 +++++++++---------- lib/biokbase/catalog/controller.py | 22 +++---- lib/biokbase/catalog/db.py | 14 ++--- .../catalog/GetSecureConfigParamsInput.java | 35 +++++------ .../kbase/catalog/SecureConfigParameter.java | 26 ++++---- test/secure_config_params_test.py | 32 ++++++---- 9 files changed, 147 insertions(+), 152 deletions(-) diff --git a/catalog.spec b/catalog.spec index 2f8c50a..b2b958d 100644 --- a/catalog.spec +++ b/catalog.spec @@ -785,13 +785,13 @@ module Catalog { funcdef is_admin(string username) returns (boolean); /* - version_tag - optional version (commit hash, tag or semantic one) of module, if not set + version - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value in UI. */ typedef structure { string module_name; - string version_tag; + string version; string param_name; boolean is_password; string param_value; @@ -814,17 +814,14 @@ module Catalog { returns () authentication required; /* - version - a lookup string, if empty will get the latest released module - 1) version tag = dev | beta | release - 2) semantic version match identifiier - not supported yet: 3) exact commit hash - not supported yet: 4) exact timestamp - load_all_versions - flag indicating that all parameter versions should be - loaded (version_lookup filter is not applied) + version - optional version (commit hash, tag or semantic one) of module, if + not set then default "release" value is used; + load_all_versions - optional flag indicating that all parameter versions + should be loaded (version filter is not applied), default value is 0. */ typedef structure { string module_name; - string version_lookup; + string version; boolean load_all_versions; } GetSecureConfigParamsInput; diff --git a/lib/Bio/KBase/Catalog/Client.pm b/lib/Bio/KBase/Catalog/Client.pm index 22fa55f..f6e531b 100644 --- a/lib/Bio/KBase/Catalog/Client.pm +++ b/lib/Bio/KBase/Catalog/Client.pm @@ -4756,7 +4756,7 @@ ModifySecureConfigParamsInput is a reference to a hash where the following keys data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter SecureConfigParameter is a reference to a hash where the following keys are defined: module_name has a value which is a string - version_tag has a value which is a string + version has a value which is a string param_name has a value which is a string is_password has a value which is a Catalog.boolean param_value has a value which is a string @@ -4773,7 +4773,7 @@ ModifySecureConfigParamsInput is a reference to a hash where the following keys data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter SecureConfigParameter is a reference to a hash where the following keys are defined: module_name has a value which is a string - version_tag has a value which is a string + version has a value which is a string param_name has a value which is a string is_password has a value which is a Catalog.boolean param_value has a value which is a string @@ -4854,7 +4854,7 @@ ModifySecureConfigParamsInput is a reference to a hash where the following keys data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter SecureConfigParameter is a reference to a hash where the following keys are defined: module_name has a value which is a string - version_tag has a value which is a string + version has a value which is a string param_name has a value which is a string is_password has a value which is a Catalog.boolean param_value has a value which is a string @@ -4871,7 +4871,7 @@ ModifySecureConfigParamsInput is a reference to a hash where the following keys data has a value which is a reference to a list where each element is a Catalog.SecureConfigParameter SecureConfigParameter is a reference to a hash where the following keys are defined: module_name has a value which is a string - version_tag has a value which is a string + version has a value which is a string param_name has a value which is a string is_password has a value which is a Catalog.boolean param_value has a value which is a string @@ -4951,12 +4951,12 @@ $params is a Catalog.GetSecureConfigParamsInput $return is a reference to a list where each element is a Catalog.SecureConfigParameter GetSecureConfigParamsInput is a reference to a hash where the following keys are defined: module_name has a value which is a string - version_lookup has a value which is a string + version has a value which is a string load_all_versions has a value which is a Catalog.boolean boolean is an int SecureConfigParameter is a reference to a hash where the following keys are defined: module_name has a value which is a string - version_tag has a value which is a string + version has a value which is a string param_name has a value which is a string is_password has a value which is a Catalog.boolean param_value has a value which is a string @@ -4971,12 +4971,12 @@ $params is a Catalog.GetSecureConfigParamsInput $return is a reference to a list where each element is a Catalog.SecureConfigParameter GetSecureConfigParamsInput is a reference to a hash where the following keys are defined: module_name has a value which is a string - version_lookup has a value which is a string + version has a value which is a string load_all_versions has a value which is a Catalog.boolean boolean is an int SecureConfigParameter is a reference to a hash where the following keys are defined: module_name has a value which is a string - version_tag has a value which is a string + version has a value which is a string param_name has a value which is a string is_password has a value which is a Catalog.boolean param_value has a value which is a string @@ -7313,7 +7313,7 @@ client_group has a value which is a string =item Description -version_tag - optional version (commit hash, tag or semantic one) of module, if not set +version - optional version (commit hash, tag or semantic one) of module, if not set then default "" value is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value in UI. @@ -7325,7 +7325,7 @@ is_password - optional flag meaning to hide this parameter's value in UI.
 a reference to a hash where the following keys are defined:
 module_name has a value which is a string
-version_tag has a value which is a string
+version has a value which is a string
 param_name has a value which is a string
 is_password has a value which is a Catalog.boolean
 param_value has a value which is a string
@@ -7338,7 +7338,7 @@ param_value has a value which is a string
 
 a reference to a hash where the following keys are defined:
 module_name has a value which is a string
-version_tag has a value which is a string
+version has a value which is a string
 param_name has a value which is a string
 is_password has a value which is a Catalog.boolean
 param_value has a value which is a string
@@ -7388,13 +7388,10 @@ data has a value which is a reference to a list where each element is a Catalog.
 
 =item Description
 
-version_lookup - a lookup string, if empty will get the latest released module
-            1) version tag = dev | beta | release
-            2) semantic version match identifiier
-            not supported yet: 3) exact commit hash
-            not supported yet: 4) exact timestamp
-load_all_versions - flag indicating that all parameter versions should be 
-            loaded (version_lookup filter is not applied)
+version - optional version (commit hash, tag or semantic one) of module, if
+    not set then default "release" value is used;
+load_all_versions - optional flag indicating that all parameter versions 
+    should be loaded (version filter is not applied), default value is 0.
 
 
 =item Definition
@@ -7404,7 +7401,7 @@ load_all_versions - flag indicating that all parameter versions should be
 
 a reference to a hash where the following keys are defined:
 module_name has a value which is a string
-version_lookup has a value which is a string
+version has a value which is a string
 load_all_versions has a value which is a Catalog.boolean
 
 
@@ -7415,7 +7412,7 @@ load_all_versions has a value which is a Catalog.boolean a reference to a hash where the following keys are defined: module_name has a value which is a string -version_lookup has a value which is a string +version has a value which is a string load_all_versions has a value which is a Catalog.boolean diff --git a/lib/biokbase/catalog/Client.py b/lib/biokbase/catalog/Client.py index d554944..758c088 100644 --- a/lib/biokbase/catalog/Client.py +++ b/lib/biokbase/catalog/Client.py @@ -1014,14 +1014,14 @@ def set_secure_config_params(self, params, context=None): Only admins can use this function. :param params: instance of type "ModifySecureConfigParamsInput" -> structure: parameter "data" of list of type - "SecureConfigParameter" (version_tag - optional version (commit - hash, tag or semantic one) of module, if not set then default "" - value is used which means parameter is applied to any version; + "SecureConfigParameter" (version - optional version (commit hash, + tag or semantic one) of module, if not set then default "" value + is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value in UI.) -> structure: parameter "module_name" of String, parameter - "version_tag" of String, parameter "param_name" of String, - parameter "is_password" of type "boolean" (@range [0,1]), - parameter "param_value" of String + "version" of String, parameter "param_name" of String, parameter + "is_password" of type "boolean" (@range [0,1]), parameter + "param_value" of String """ return self._client.call_method( 'Catalog.set_secure_config_params', @@ -1032,14 +1032,14 @@ def remove_secure_config_params(self, params, context=None): Only admins can use this function. :param params: instance of type "ModifySecureConfigParamsInput" -> structure: parameter "data" of list of type - "SecureConfigParameter" (version_tag - optional version (commit - hash, tag or semantic one) of module, if not set then default "" - value is used which means parameter is applied to any version; + "SecureConfigParameter" (version - optional version (commit hash, + tag or semantic one) of module, if not set then default "" value + is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value in UI.) -> structure: parameter "module_name" of String, parameter - "version_tag" of String, parameter "param_name" of String, - parameter "is_password" of type "boolean" (@range [0,1]), - parameter "param_value" of String + "version" of String, parameter "param_name" of String, parameter + "is_password" of type "boolean" (@range [0,1]), parameter + "param_value" of String """ return self._client.call_method( 'Catalog.remove_secure_config_params', @@ -1048,23 +1048,22 @@ def remove_secure_config_params(self, params, context=None): def get_secure_config_params(self, params, context=None): """ Only admins can use this function. - :param params: instance of type "GetSecureConfigParamsInput" - (version_lookup - a lookup string, if empty will get the latest - released module 1) version tag = dev | beta | release 2) semantic - version match identifiier not supported yet: 3) exact commit hash - not supported yet: 4) exact timestamp load_all_versions - flag - indicating that all parameter versions should be loaded - (version_lookup filter is not applied)) -> structure: parameter - "module_name" of String, parameter "version_lookup" of String, - parameter "load_all_versions" of type "boolean" (@range [0,1]) - :returns: instance of list of type "SecureConfigParameter" - (version_tag - optional version (commit hash, tag or semantic one) - of module, if not set then default "" value is used which means - parameter is applied to any version; is_password - optional flag - meaning to hide this parameter's value in UI.) -> structure: - parameter "module_name" of String, parameter "version_tag" of - String, parameter "param_name" of String, parameter "is_password" - of type "boolean" (@range [0,1]), parameter "param_value" of String + :param params: instance of type "GetSecureConfigParamsInput" (version + - optional version (commit hash, tag or semantic one) of module, + if not set then default "release" value is used; load_all_versions + - optional flag indicating that all parameter versions should be + loaded (version filter is not applied), default value is 0.) -> + structure: parameter "module_name" of String, parameter "version" + of String, parameter "load_all_versions" of type "boolean" (@range + [0,1]) + :returns: instance of list of type "SecureConfigParameter" (version - + optional version (commit hash, tag or semantic one) of module, if + not set then default "" value is used which means parameter is + applied to any version; is_password - optional flag meaning to + hide this parameter's value in UI.) -> structure: parameter + "module_name" of String, parameter "version" of String, parameter + "param_name" of String, parameter "is_password" of type "boolean" + (@range [0,1]), parameter "param_value" of String """ return self._client.call_method( 'Catalog.get_secure_config_params', diff --git a/lib/biokbase/catalog/Impl.py b/lib/biokbase/catalog/Impl.py index ee28182..8ecae50 100644 --- a/lib/biokbase/catalog/Impl.py +++ b/lib/biokbase/catalog/Impl.py @@ -22,7 +22,7 @@ class Catalog: ######################################### noqa VERSION = "0.0.1" GIT_URL = "https://github.com/kbase/catalog" - GIT_COMMIT_HASH = "744fce8634cf56e952bd291fa6b789a618df6b3c" + GIT_COMMIT_HASH = "1d3fa708d1642a1988bac99b35ce20f2d730a322" #BEGIN_CLASS_HEADER #END_CLASS_HEADER @@ -1366,14 +1366,14 @@ def set_secure_config_params(self, ctx, params): Only admins can use this function. :param params: instance of type "ModifySecureConfigParamsInput" -> structure: parameter "data" of list of type - "SecureConfigParameter" (version_tag - optional version (commit - hash, tag or semantic one) of module, if not set then default "" - value is used which means parameter is applied to any version; + "SecureConfigParameter" (version - optional version (commit hash, + tag or semantic one) of module, if not set then default "" value + is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value in UI.) -> structure: parameter "module_name" of String, parameter - "version_tag" of String, parameter "param_name" of String, - parameter "is_password" of type "boolean" (@range [0,1]), - parameter "param_value" of String + "version" of String, parameter "param_name" of String, parameter + "is_password" of type "boolean" (@range [0,1]), parameter + "param_value" of String """ # ctx is the context object #BEGIN set_secure_config_params @@ -1386,14 +1386,14 @@ def remove_secure_config_params(self, ctx, params): Only admins can use this function. :param params: instance of type "ModifySecureConfigParamsInput" -> structure: parameter "data" of list of type - "SecureConfigParameter" (version_tag - optional version (commit - hash, tag or semantic one) of module, if not set then default "" - value is used which means parameter is applied to any version; + "SecureConfigParameter" (version - optional version (commit hash, + tag or semantic one) of module, if not set then default "" value + is used which means parameter is applied to any version; is_password - optional flag meaning to hide this parameter's value in UI.) -> structure: parameter "module_name" of String, parameter - "version_tag" of String, parameter "param_name" of String, - parameter "is_password" of type "boolean" (@range [0,1]), - parameter "param_value" of String + "version" of String, parameter "param_name" of String, parameter + "is_password" of type "boolean" (@range [0,1]), parameter + "param_value" of String """ # ctx is the context object #BEGIN remove_secure_config_params @@ -1404,23 +1404,22 @@ def remove_secure_config_params(self, ctx, params): def get_secure_config_params(self, ctx, params): """ Only admins can use this function. - :param params: instance of type "GetSecureConfigParamsInput" - (version_lookup - a lookup string, if empty will get the latest - released module 1) version tag = dev | beta | release 2) semantic - version match identifiier not supported yet: 3) exact commit hash - not supported yet: 4) exact timestamp load_all_versions - flag - indicating that all parameter versions should be loaded - (version_lookup filter is not applied)) -> structure: parameter - "module_name" of String, parameter "version_lookup" of String, - parameter "load_all_versions" of type "boolean" (@range [0,1]) - :returns: instance of list of type "SecureConfigParameter" - (version_tag - optional version (commit hash, tag or semantic one) - of module, if not set then default "" value is used which means - parameter is applied to any version; is_password - optional flag - meaning to hide this parameter's value in UI.) -> structure: - parameter "module_name" of String, parameter "version_tag" of - String, parameter "param_name" of String, parameter "is_password" - of type "boolean" (@range [0,1]), parameter "param_value" of String + :param params: instance of type "GetSecureConfigParamsInput" (version + - optional version (commit hash, tag or semantic one) of module, + if not set then default "release" value is used; load_all_versions + - optional flag indicating that all parameter versions should be + loaded (version filter is not applied), default value is 0.) -> + structure: parameter "module_name" of String, parameter "version" + of String, parameter "load_all_versions" of type "boolean" (@range + [0,1]) + :returns: instance of list of type "SecureConfigParameter" (version - + optional version (commit hash, tag or semantic one) of module, if + not set then default "" value is used which means parameter is + applied to any version; is_password - optional flag meaning to + hide this parameter's value in UI.) -> structure: parameter + "module_name" of String, parameter "version" of String, parameter + "param_name" of String, parameter "is_password" of type "boolean" + (@range [0,1]), parameter "param_value" of String """ # ctx is the context object # return variables are: returnVal diff --git a/lib/biokbase/catalog/controller.py b/lib/biokbase/catalog/controller.py index f7721b4..6b69fbb 100644 --- a/lib/biokbase/catalog/controller.py +++ b/lib/biokbase/catalog/controller.py @@ -1480,25 +1480,25 @@ def get_secure_config_params(self, username, params): module_name = params['module_name'] if not isinstance(module_name, basestring): raise ValueError('module_name parameter field must be a string') - version_lookup = params.get('version_lookup') - if version_lookup and not isinstance(version_lookup, basestring): - raise ValueError('version_lookup parameter field must be a string') + version_filter = params.get('version') + if version_filter and not isinstance(version_filter, basestring): + raise ValueError('version parameter field must be a string') load_all_versions = params.get('load_all_versions') secure_param_list = self.db.get_secure_config_params(module_name) if load_all_versions: return secure_param_list - mv = self.get_module_version({'module_name': module_name, 'version': version}) + mv = self.get_module_version({'module_name': module_name, 'version': version_filter}) param_map = {} for secure_param in secure_param_list: param_name = secure_param['param_name'] - version_tag = secure_param.get('version_tag') - # If version_tag is defined and doesn't match any known version we skip it: - if version_tag and not (version_tag == mv['git_commit_hash'] or - version_tag == mv['version'] or - version_tag in mv['release_tags']): + param_version = secure_param.get('version') + # If version is defined and doesn't match any known version we skip it: + if param_version and not (param_version == mv['git_commit_hash'] or + param_version == mv['version'] or + param_version in mv['release_tags']): continue - # We may override previous param_name value if it had empty version_tag previously: - if param_name not in param_map or not param_map[param_name].get('version_tag'): + # We may override previous param_name value if it had empty version previously: + if param_name not in param_map or not param_map[param_name].get('version'): param_map[param_name] = secure_param return [param_map[param_name] for param_name in param_map] diff --git a/lib/biokbase/catalog/db.py b/lib/biokbase/catalog/db.py index c3f8b32..53d92a9 100644 --- a/lib/biokbase/catalog/db.py +++ b/lib/biokbase/catalog/db.py @@ -248,7 +248,7 @@ def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): self.secure_config_params.ensure_index('module_name_lc') self.secure_config_params.ensure_index([ ('module_name_lc',ASCENDING), - ('version_tag',ASCENDING), + ('version',ASCENDING), ('param_name',ASCENDING)], unique=True, sparse=False) @@ -1241,12 +1241,12 @@ def get_exec_raw_stats(self, minTime, maxTime): def set_secure_config_params(self, data_list): for param_data in data_list: param_data['module_name_lc'] = param_data['module_name'].lower() - param_data['version_tag'] = param_data.get('version_tag', '') + param_data['version'] = param_data.get('version', '') self.secure_config_params.update( { - 'module_name_lc':param_data['module_name_lc'], - 'version_tag':param_data['version_tag'], - 'param_name':param_data['param_name'] + 'module_name_lc': param_data['module_name_lc'], + 'version': param_data['version'], + 'param_name': param_data['param_name'] }, param_data, upsert=True) @@ -1254,11 +1254,11 @@ def set_secure_config_params(self, data_list): def remove_secure_config_params(self, data_list): for param_data in data_list: param_data['module_name_lc'] = param_data['module_name'].lower() - param_data['version_tag'] = param_data.get('version_tag', '') + param_data['version'] = param_data.get('version', '') self.secure_config_params.remove( { 'module_name_lc':param_data['module_name_lc'], - 'version_tag':param_data['version_tag'], + 'version':param_data['version'], 'param_name':param_data['param_name'] }) diff --git a/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java b/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java index 7aff32e..401f6f2 100644 --- a/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java +++ b/lib/java/us/kbase/catalog/GetSecureConfigParamsInput.java @@ -14,13 +14,10 @@ /** *

Original spec-file type: GetSecureConfigParamsInput

*
- * version_lookup - a lookup string, if empty will get the latest released module
- *             1) version tag = dev | beta | release
- *             2) semantic version match identifiier
- *             not supported yet: 3) exact commit hash
- *             not supported yet: 4) exact timestamp
- * load_all_versions - flag indicating that all parameter versions should be 
- *             loaded (version_lookup filter is not applied)
+ * version - optional version (commit hash, tag or semantic one) of module, if
+ *     not set then default "release" value is used;
+ * load_all_versions - optional flag indicating that all parameter versions 
+ *     should be loaded (version filter is not applied), default value is 0.
  * 
* */ @@ -28,15 +25,15 @@ @Generated("com.googlecode.jsonschema2pojo") @JsonPropertyOrder({ "module_name", - "version_lookup", + "version", "load_all_versions" }) public class GetSecureConfigParamsInput { @JsonProperty("module_name") private String moduleName; - @JsonProperty("version_lookup") - private String versionLookup; + @JsonProperty("version") + private String version; @JsonProperty("load_all_versions") private Long loadAllVersions; private Map additionalProperties = new HashMap(); @@ -56,18 +53,18 @@ public GetSecureConfigParamsInput withModuleName(String moduleName) { return this; } - @JsonProperty("version_lookup") - public String getVersionLookup() { - return versionLookup; + @JsonProperty("version") + public String getVersion() { + return version; } - @JsonProperty("version_lookup") - public void setVersionLookup(String versionLookup) { - this.versionLookup = versionLookup; + @JsonProperty("version") + public void setVersion(String version) { + this.version = version; } - public GetSecureConfigParamsInput withVersionLookup(String versionLookup) { - this.versionLookup = versionLookup; + public GetSecureConfigParamsInput withVersion(String version) { + this.version = version; return this; } @@ -98,7 +95,7 @@ public void setAdditionalProperties(String name, Object value) { @Override public String toString() { - return ((((((((("GetSecureConfigParamsInput"+" [moduleName=")+ moduleName)+", versionLookup=")+ versionLookup)+", loadAllVersions=")+ loadAllVersions)+", additionalProperties=")+ additionalProperties)+"]"); + return ((((((((("GetSecureConfigParamsInput"+" [moduleName=")+ moduleName)+", version=")+ version)+", loadAllVersions=")+ loadAllVersions)+", additionalProperties=")+ additionalProperties)+"]"); } } diff --git a/lib/java/us/kbase/catalog/SecureConfigParameter.java b/lib/java/us/kbase/catalog/SecureConfigParameter.java index d0c62ff..ac03c38 100644 --- a/lib/java/us/kbase/catalog/SecureConfigParameter.java +++ b/lib/java/us/kbase/catalog/SecureConfigParameter.java @@ -14,7 +14,7 @@ /** *

Original spec-file type: SecureConfigParameter

*
- * version_tag - optional version (commit hash, tag or semantic one) of module, if not set
+ * version - optional version (commit hash, tag or semantic one) of module, if not set
  *     then default "" value is used which means parameter is applied to any version;
  * is_password - optional flag meaning to hide this parameter's value in UI.
  * 
@@ -24,7 +24,7 @@ @Generated("com.googlecode.jsonschema2pojo") @JsonPropertyOrder({ "module_name", - "version_tag", + "version", "param_name", "is_password", "param_value" @@ -33,8 +33,8 @@ public class SecureConfigParameter { @JsonProperty("module_name") private String moduleName; - @JsonProperty("version_tag") - private String versionTag; + @JsonProperty("version") + private String version; @JsonProperty("param_name") private String paramName; @JsonProperty("is_password") @@ -58,18 +58,18 @@ public SecureConfigParameter withModuleName(String moduleName) { return this; } - @JsonProperty("version_tag") - public String getVersionTag() { - return versionTag; + @JsonProperty("version") + public String getVersion() { + return version; } - @JsonProperty("version_tag") - public void setVersionTag(String versionTag) { - this.versionTag = versionTag; + @JsonProperty("version") + public void setVersion(String version) { + this.version = version; } - public SecureConfigParameter withVersionTag(String versionTag) { - this.versionTag = versionTag; + public SecureConfigParameter withVersion(String version) { + this.version = version; return this; } @@ -130,7 +130,7 @@ public void setAdditionalProperties(String name, Object value) { @Override public String toString() { - return ((((((((((((("SecureConfigParameter"+" [moduleName=")+ moduleName)+", versionTag=")+ versionTag)+", paramName=")+ paramName)+", isPassword=")+ isPassword)+", paramValue=")+ paramValue)+", additionalProperties=")+ additionalProperties)+"]"); + return ((((((((((((("SecureConfigParameter"+" [moduleName=")+ moduleName)+", version=")+ version)+", paramName=")+ paramName)+", isPassword=")+ isPassword)+", paramValue=")+ paramValue)+", additionalProperties=")+ additionalProperties)+"]"); } } diff --git a/test/secure_config_params_test.py b/test/secure_config_params_test.py index 9926607..106f239 100644 --- a/test/secure_config_params_test.py +++ b/test/secure_config_params_test.py @@ -80,6 +80,12 @@ def test_errors(self): self.assertEqual(str(e.exception), 'module_name parameter field must be a string'); + with self.assertRaises(ValueError) as e: + self.catalog.get_secure_config_params(adminCtx, {'module_name': 'abc', + 'version': [1, 2, 3]}) + self.assertEqual(str(e.exception), + 'version parameter field must be a string'); + def test_no_data(self): adminCtx = self.cUtil.admin_ctx() @@ -100,7 +106,7 @@ def test_set_parameters(self): self.assertEqual(params[0]['module_name'], 'Test1') self.assertEqual(params[0]['param_name'], 'param0') self.assertEqual(params[0]['param_value'], 'value0') - self.assertEqual(params[0]['version_tag'], '') + self.assertEqual(params[0]['version'], '') self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test1', 'param_name': 'param0', @@ -151,7 +157,7 @@ def test_versions(self): self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3', 'param_name': 'param0', - 'version_tag': 'special_version', + 'version': 'special_version', 'param_value': 'value1'}]}) params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3', 'load_all_versions': 1})[0] @@ -165,11 +171,11 @@ def test_versions(self): self.assertEqual(len(params), 1) self.assertEqual(params[0]['param_name'], 'param0') self.assertEqual(params[0]['param_value'], 'value1') - self.assertEqual(params[0]['version_tag'], 'special_version') + self.assertEqual(params[0]['version'], 'special_version') self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': 'Test3', 'param_name': 'param0', - 'version_tag': 'special_version'}]}) + 'version': 'special_version'}]}) params = self.catalog.get_secure_config_params(adminCtx, {'module_name': 'test3', 'load_all_versions': 1})[0] @@ -192,20 +198,20 @@ def test_module_versions(self): 'param_value': 'value0'}, {'module_name': module_name, 'param_name': param_name, - 'version_tag': garbage, + 'version': garbage, 'param_value': 'value1'}]}) self.check_secure_param_value(module_name, version_tag, 'param0', 'value0') self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': module_name, 'param_name': param_name, - 'version_tag': garbage}]}) + 'version': garbage}]}) self.check_secure_param_value(module_name, version_tag, 'param0', 'value0') self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value0') self.check_secure_param_value(module_name, semantic_version, 'param0', 'value0') self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': module_name, 'param_name': param_name, - 'version_tag': version_tag, + 'version': version_tag, 'param_value': 'value1'}]}) self.check_secure_param_value(module_name, version_tag, 'param0', 'value1') self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value1') @@ -213,12 +219,12 @@ def test_module_versions(self): self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': module_name, 'param_name': param_name, - 'version_tag': version_tag}]}) + 'version': version_tag}]}) self.check_secure_param_value(module_name, version_tag, 'param0', 'value0') self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': module_name, 'param_name': param_name, - 'version_tag': git_commit_hash, + 'version': git_commit_hash, 'param_value': 'value2'}]}) self.check_secure_param_value(module_name, version_tag, 'param0', 'value2') self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value2') @@ -226,12 +232,12 @@ def test_module_versions(self): self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': module_name, 'param_name': param_name, - 'version_tag': git_commit_hash}]}) + 'version': git_commit_hash}]}) self.check_secure_param_value(module_name, version_tag, 'param0', 'value0') self.catalog.set_secure_config_params(adminCtx, {'data': [{'module_name': module_name, 'param_name': param_name, - 'version_tag': semantic_version, + 'version': semantic_version, 'param_value': 'value3'}]}) self.check_secure_param_value(module_name, version_tag, 'param0', 'value3') self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value3') @@ -239,10 +245,10 @@ def test_module_versions(self): - def check_secure_param_value(self, module_name, version_tag, param_name, param_value): + def check_secure_param_value(self, module_name, version, param_name, param_value): params = self.catalog.get_secure_config_params(self.cUtil.admin_ctx(), {'module_name': module_name, - 'version_tag': version_tag})[0] + 'version': version})[0] self.assertEqual(len(params), 1) self.assertEqual(params[0]['param_name'], param_name) self.assertEqual(params[0]['param_value'], param_value) From 16890fecac80f9a933de8f4553a8a6d54ab5c0f9 Mon Sep 17 00:00:00 2001 From: Roman Sutormin Date: Thu, 30 Mar 2017 13:54:22 -0700 Subject: [PATCH 11/13] Debugging error in secure parameter test. --- test/secure_config_params_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/secure_config_params_test.py b/test/secure_config_params_test.py index 106f239..2e18bef 100644 --- a/test/secure_config_params_test.py +++ b/test/secure_config_params_test.py @@ -190,6 +190,10 @@ def test_module_versions(self): 'version': version_tag})[0] git_commit_hash = mv['git_commit_hash'] semantic_version = mv['version'] + print("[DEBUG] Before semantic: " + str(mv)) + mv2 = self.catalog.get_module_version(adminCtx, {'module_name': module_name, + 'version': semantic_version})[0] + print("[DEBUG] After semantic: " + str(mv2)) garbage = 'garbage' param_name = 'param0' @@ -215,7 +219,7 @@ def test_module_versions(self): 'param_value': 'value1'}]}) self.check_secure_param_value(module_name, version_tag, 'param0', 'value1') self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value1') - self.check_secure_param_value(module_name, semantic_version, 'param0', 'value1') + #self.check_secure_param_value(module_name, semantic_version, 'param0', 'value1') self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': module_name, 'param_name': param_name, From f998913b3808019afac1975bb4bf6e81b28b68f6 Mon Sep 17 00:00:00 2001 From: Roman Sutormin Date: Thu, 30 Mar 2017 14:19:30 -0700 Subject: [PATCH 12/13] Fix for bug in secure configuration parameter test. --- test/secure_config_params_test.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/secure_config_params_test.py b/test/secure_config_params_test.py index 2e18bef..e674b3c 100644 --- a/test/secure_config_params_test.py +++ b/test/secure_config_params_test.py @@ -185,15 +185,13 @@ def test_versions(self): def test_module_versions(self): adminCtx = self.cUtil.admin_ctx() module_name = 'onerepotest' - version_tag = 'dev' + version_tag = 'release' mv = self.catalog.get_module_version(adminCtx, {'module_name': module_name, 'version': version_tag})[0] git_commit_hash = mv['git_commit_hash'] semantic_version = mv['version'] - print("[DEBUG] Before semantic: " + str(mv)) mv2 = self.catalog.get_module_version(adminCtx, {'module_name': module_name, 'version': semantic_version})[0] - print("[DEBUG] After semantic: " + str(mv2)) garbage = 'garbage' param_name = 'param0' @@ -219,7 +217,7 @@ def test_module_versions(self): 'param_value': 'value1'}]}) self.check_secure_param_value(module_name, version_tag, 'param0', 'value1') self.check_secure_param_value(module_name, git_commit_hash, 'param0', 'value1') - #self.check_secure_param_value(module_name, semantic_version, 'param0', 'value1') + self.check_secure_param_value(module_name, semantic_version, 'param0', 'value1') self.catalog.remove_secure_config_params(adminCtx, {'data': [{'module_name': module_name, 'param_name': param_name, @@ -260,7 +258,7 @@ def check_secure_param_value(self, module_name, version, param_name, param_value @classmethod def setUpClass(cls): - print('++++++++++++ RUNNING client_group_test.py +++++++++++') + print('++++++++++++ RUNNING secure_config_params.py +++++++++++') cls.cUtil = CatalogTestUtil('.') # TODO: pass in test directory from outside cls.cUtil.setUp() cls.catalog = Catalog(cls.cUtil.getCatalogConfig()) From 592151bf189956f616cbf381adc5871802afdc9b Mon Sep 17 00:00:00 2001 From: msneddon Date: Thu, 13 Apr 2017 15:06:52 -0700 Subject: [PATCH 13/13] version bump to 2.1.0 --- README.md | 4 ++++ lib/biokbase/catalog/version.py | 2 +- test/basic_catalog_test.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31ed98b..053bf8e 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ develop: [![Build Status](https://travis-ci.org/kbase/catalog.svg?branch=develop Code coverage: (develop branch) [![Coverage Status](https://coveralls.io/repos/github/kbase/catalog/badge.svg?branch=develop)](https://coveralls.io/github/kbase/catalog?branch=develop) +#### v2.1.0 - 4/13/17 + - No change from 2.0.7, but upgraded minor version number because many new features + now exist since the initial 2.0.x release. + #### v2.0.7 - 3/28/17 - Added job_id field to raw execution statistics - Support for hidden configuration parameters diff --git a/lib/biokbase/catalog/version.py b/lib/biokbase/catalog/version.py index 5aef087..5a97f02 100644 --- a/lib/biokbase/catalog/version.py +++ b/lib/biokbase/catalog/version.py @@ -1,2 +1,2 @@ # File that simply defines version information -CATALOG_VERSION = '2.0.7' \ No newline at end of file +CATALOG_VERSION = '2.1.0' \ No newline at end of file diff --git a/test/basic_catalog_test.py b/test/basic_catalog_test.py index 453a519..75e2a41 100644 --- a/test/basic_catalog_test.py +++ b/test/basic_catalog_test.py @@ -14,7 +14,7 @@ class BasicCatalogTest(unittest.TestCase): def test_version(self): - self.assertEqual(self.catalog.version(self.cUtil.anonymous_ctx()),['2.0.7']) + self.assertEqual(self.catalog.version(self.cUtil.anonymous_ctx()),['2.1.0']) def test_is_registered(self):