diff --git a/README.md b/README.md index 03872f5..247fe4a 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,9 @@ 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.4 - TBA +#### v2.0.5 - TBA - Added volume mount configuration + - Modified client group configurations so that functions are specified, not app_ids #### v2.0.3 - 5/31/16 - Major release to support storage of local functions and dynamic services information, diff --git a/catalog.spec b/catalog.spec index 5c3a7fe..8028e80 100644 --- a/catalog.spec +++ b/catalog.spec @@ -87,16 +87,31 @@ module Catalog { boolean include_modules_with_no_name_set; } ListModuleParams; + + typedef structure { + string git_commit_hash; + } VersionCommitInfo; + + /* + git_url is always returned. Every other field + may or may not exist depending on what has been registered or if + certain registrations have failed + */ typedef structure { string module_name; string git_url; - } BasicModuleInfo; - /* - To Add: - string brief_description; + + string language; + boolean dynamic_service; + list owners; - boolean is_released; - */ + + VersionCommitInfo dev; + VersionCommitInfo beta; + VersionCommitInfo release; + + list released_version_list; + } BasicModuleInfo; /* */ funcdef list_basic_module_info(ListModuleParams params) returns (list info_list); @@ -700,17 +715,34 @@ module Catalog { list client_groups; } AppClientGroup; - funcdef set_client_group(AppClientGroup group) returns () authentication required; - /* if app_ids is empty or null, all client groups are returned */ typedef structure { - list app_ids; } GetClientGroupParams; + /* @deprecated list_client_group_configs */ funcdef get_client_groups(GetClientGroupParams params) returns (list groups); + typedef structure { + string module_name; + string function_name; + list client_groups; + } ClientGroupConfig; + + funcdef set_client_group_config(ClientGroupConfig config) returns () authentication required; + + funcdef remove_client_group_config(ClientGroupConfig config) returns () authentication required; + + typedef structure { + string module_name; + string function_name; + } ClientGroupFilter; + + funcdef list_client_group_configs(ClientGroupFilter filter) returns (list groups); + + + typedef structure { string host_dir; string container_dir; diff --git a/lib/Bio/KBase/Catalog/Client.pm b/lib/Bio/KBase/Catalog/Client.pm index fe75914..5625ca7 100644 --- a/lib/Bio/KBase/Catalog/Client.pm +++ b/lib/Bio/KBase/Catalog/Client.pm @@ -716,6 +716,15 @@ boolean is an int BasicModuleInfo is a reference to a hash where the following keys are defined: module_name has a value which is a string git_url has a value which is a string + language has a value which is a string + dynamic_service has a value which is a Catalog.boolean + owners has a value which is a reference to a list where each element is a string + dev has a value which is a Catalog.VersionCommitInfo + beta has a value which is a Catalog.VersionCommitInfo + release has a value which is a Catalog.VersionCommitInfo + released_version_list has a value which is a reference to a list where each element is a Catalog.VersionCommitInfo +VersionCommitInfo is a reference to a hash where the following keys are defined: + git_commit_hash has a value which is a string @@ -735,6 +744,15 @@ boolean is an int BasicModuleInfo is a reference to a hash where the following keys are defined: module_name has a value which is a string git_url has a value which is a string + language has a value which is a string + dynamic_service has a value which is a Catalog.boolean + owners has a value which is a reference to a list where each element is a string + dev has a value which is a Catalog.VersionCommitInfo + beta has a value which is a Catalog.VersionCommitInfo + release has a value which is a Catalog.VersionCommitInfo + released_version_list has a value which is a reference to a list where each element is a Catalog.VersionCommitInfo +VersionCommitInfo is a reference to a hash where the following keys are defined: + git_commit_hash has a value which is a string =end text @@ -3919,9 +3937,9 @@ GetExecRawStatsParams is a reference to a hash where the following keys are defi -=head2 set_client_group +=head2 get_client_groups - $obj->set_client_group($group) + $groups = $obj->get_client_groups($params) =over 4 @@ -3930,7 +3948,9 @@ GetExecRawStatsParams is a reference to a hash where the following keys are defi =begin html
-$group is a Catalog.AppClientGroup
+$params is a Catalog.GetClientGroupParams
+$groups is a reference to a list where each element is a Catalog.AppClientGroup
+GetClientGroupParams is a reference to a hash where the following keys are defined
 AppClientGroup is a reference to a hash where the following keys are defined:
 	app_id has a value which is a string
 	client_groups has a value which is a reference to a list where each element is a string
@@ -3941,7 +3961,9 @@ AppClientGroup is a reference to a hash where the following keys are defined:
 
 =begin text
 
-$group is a Catalog.AppClientGroup
+$params is a Catalog.GetClientGroupParams
+$groups is a reference to a list where each element is a Catalog.AppClientGroup
+GetClientGroupParams is a reference to a hash where the following keys are defined
 AppClientGroup is a reference to a hash where the following keys are defined:
 	app_id has a value which is a string
 	client_groups has a value which is a reference to a list where each element is a string
@@ -3951,13 +3973,100 @@ AppClientGroup is a reference to a hash where the following keys are defined:
 
 =item Description
 
+@deprecated list_client_group_configs
+
+=back
+
+=cut
+
+ sub get_client_groups
+{
+    my($self, @args) = @_;
+
+# Authentication: none
+
+    if ((my $n = @args) != 1)
+    {
+	Bio::KBase::Exceptions::ArgumentValidationError->throw(error =>
+							       "Invalid argument count for function get_client_groups (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_client_groups:\n" . join("", map { "\t$_\n" } @_bad_arguments);
+	    Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg,
+								   method_name => 'get_client_groups');
+	}
+    }
+
+    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
+	method => "Catalog.get_client_groups",
+	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_client_groups',
+					       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_client_groups",
+					    status_line => $self->{client}->status_line,
+					    method_name => 'get_client_groups',
+				       );
+    }
+}
+ 
+
+
+=head2 set_client_group_config
+
+  $obj->set_client_group_config($config)
+
+=over 4
+
+=item Parameter and return types
+
+=begin html
+
+
+$config is a Catalog.ClientGroupConfig
+ClientGroupConfig is a reference to a hash where the following keys are defined:
+	module_name has a value which is a string
+	function_name has a value which is a string
+	client_groups has a value which is a reference to a list where each element is a string
+
+
+ +=end html + +=begin text + +$config is a Catalog.ClientGroupConfig +ClientGroupConfig is a reference to a hash where the following keys are defined: + module_name has a value which is a string + function_name has a value which is a string + client_groups has a value which is a reference to a list where each element is a string + + +=end text + +=item Description + =back =cut - sub set_client_group + sub set_client_group_config { my($self, @args) = @_; @@ -3966,47 +4075,47 @@ AppClientGroup is a reference to a hash where the following keys are defined: if ((my $n = @args) != 1) { Bio::KBase::Exceptions::ArgumentValidationError->throw(error => - "Invalid argument count for function set_client_group (received $n, expecting 1)"); + "Invalid argument count for function set_client_group_config (received $n, expecting 1)"); } { - my($group) = @args; + my($config) = @args; my @_bad_arguments; - (ref($group) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"group\" (value was \"$group\")"); + (ref($config) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"config\" (value was \"$config\")"); if (@_bad_arguments) { - my $msg = "Invalid arguments passed to set_client_group:\n" . join("", map { "\t$_\n" } @_bad_arguments); + my $msg = "Invalid arguments passed to set_client_group_config:\n" . join("", map { "\t$_\n" } @_bad_arguments); Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg, - method_name => 'set_client_group'); + method_name => 'set_client_group_config'); } } my $result = $self->{client}->call($self->{url}, $self->{headers}, { - method => "Catalog.set_client_group", + method => "Catalog.set_client_group_config", 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_client_group', + method_name => 'set_client_group_config', 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_client_group", + Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method set_client_group_config", status_line => $self->{client}->status_line, - method_name => 'set_client_group', + method_name => 'set_client_group_config', ); } } -=head2 get_client_groups +=head2 remove_client_group_config - $groups = $obj->get_client_groups($params) + $obj->remove_client_group_config($config) =over 4 @@ -4015,12 +4124,10 @@ AppClientGroup is a reference to a hash where the following keys are defined: =begin html
-$params is a Catalog.GetClientGroupParams
-$groups is a reference to a list where each element is a Catalog.AppClientGroup
-GetClientGroupParams is a reference to a hash where the following keys are defined:
-	app_ids has a value which is a reference to a list where each element is a string
-AppClientGroup is a reference to a hash where the following keys are defined:
-	app_id has a value which is a string
+$config is a Catalog.ClientGroupConfig
+ClientGroupConfig is a reference to a hash where the following keys are defined:
+	module_name has a value which is a string
+	function_name has a value which is a string
 	client_groups has a value which is a reference to a list where each element is a string
 
 
@@ -4029,12 +4136,10 @@ AppClientGroup is a reference to a hash where the following keys are defined: =begin text -$params is a Catalog.GetClientGroupParams -$groups is a reference to a list where each element is a Catalog.AppClientGroup -GetClientGroupParams is a reference to a hash where the following keys are defined: - app_ids has a value which is a reference to a list where each element is a string -AppClientGroup is a reference to a hash where the following keys are defined: - app_id has a value which is a string +$config is a Catalog.ClientGroupConfig +ClientGroupConfig is a reference to a hash where the following keys are defined: + module_name has a value which is a string + function_name has a value which is a string client_groups has a value which is a reference to a list where each element is a string @@ -4048,7 +4153,102 @@ AppClientGroup is a reference to a hash where the following keys are defined: =cut - sub get_client_groups + sub remove_client_group_config +{ + my($self, @args) = @_; + +# Authentication: required + + if ((my $n = @args) != 1) + { + Bio::KBase::Exceptions::ArgumentValidationError->throw(error => + "Invalid argument count for function remove_client_group_config (received $n, expecting 1)"); + } + { + my($config) = @args; + + my @_bad_arguments; + (ref($config) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"config\" (value was \"$config\")"); + if (@_bad_arguments) { + my $msg = "Invalid arguments passed to remove_client_group_config:\n" . join("", map { "\t$_\n" } @_bad_arguments); + Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg, + method_name => 'remove_client_group_config'); + } + } + + my $result = $self->{client}->call($self->{url}, $self->{headers}, { + method => "Catalog.remove_client_group_config", + 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_client_group_config', + 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_client_group_config", + status_line => $self->{client}->status_line, + method_name => 'remove_client_group_config', + ); + } +} + + + +=head2 list_client_group_configs + + $groups = $obj->list_client_group_configs($filter) + +=over 4 + +=item Parameter and return types + +=begin html + +
+$filter is a Catalog.ClientGroupFilter
+$groups is a reference to a list where each element is a Catalog.ClientGroupConfig
+ClientGroupFilter is a reference to a hash where the following keys are defined:
+	module_name has a value which is a string
+	function_name has a value which is a string
+ClientGroupConfig is a reference to a hash where the following keys are defined:
+	module_name has a value which is a string
+	function_name has a value which is a string
+	client_groups has a value which is a reference to a list where each element is a string
+
+
+ +=end html + +=begin text + +$filter is a Catalog.ClientGroupFilter +$groups is a reference to a list where each element is a Catalog.ClientGroupConfig +ClientGroupFilter is a reference to a hash where the following keys are defined: + module_name has a value which is a string + function_name has a value which is a string +ClientGroupConfig is a reference to a hash where the following keys are defined: + module_name has a value which is a string + function_name has a value which is a string + client_groups has a value which is a reference to a list where each element is a string + + +=end text + +=item Description + + + +=back + +=cut + + sub list_client_group_configs { my($self, @args) = @_; @@ -4057,38 +4257,38 @@ AppClientGroup is a reference to a hash where the following keys are defined: if ((my $n = @args) != 1) { Bio::KBase::Exceptions::ArgumentValidationError->throw(error => - "Invalid argument count for function get_client_groups (received $n, expecting 1)"); + "Invalid argument count for function list_client_group_configs (received $n, expecting 1)"); } { - my($params) = @args; + my($filter) = @args; my @_bad_arguments; - (ref($params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"params\" (value was \"$params\")"); + (ref($filter) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"filter\" (value was \"$filter\")"); if (@_bad_arguments) { - my $msg = "Invalid arguments passed to get_client_groups:\n" . join("", map { "\t$_\n" } @_bad_arguments); + my $msg = "Invalid arguments passed to list_client_group_configs:\n" . join("", map { "\t$_\n" } @_bad_arguments); Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg, - method_name => 'get_client_groups'); + method_name => 'list_client_group_configs'); } } my $result = $self->{client}->call($self->{url}, $self->{headers}, { - method => "Catalog.get_client_groups", + method => "Catalog.list_client_group_configs", 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_client_groups', + method_name => 'list_client_group_configs', 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_client_groups", + Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method list_client_group_configs", status_line => $self->{client}->status_line, - method_name => 'get_client_groups', + method_name => 'list_client_group_configs', ); } } @@ -4775,12 +4975,49 @@ include_modules_with_no_name_set has a value which is a Catalog.boolean +=head2 VersionCommitInfo + +=over 4 + + + +=item Definition + +=begin html + +
+a reference to a hash where the following keys are defined:
+git_commit_hash has a value which is a string
+
+
+ +=end html + +=begin text + +a reference to a hash where the following keys are defined: +git_commit_hash has a value which is a string + + +=end text + +=back + + + =head2 BasicModuleInfo =over 4 +=item Description + +git_url is always returned. Every other field +may or may not exist depending on what has been registered or if +certain registrations have failed + + =item Definition =begin html @@ -4789,6 +5026,13 @@ include_modules_with_no_name_set 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 git_url has a value which is a string +language has a value which is a string +dynamic_service has a value which is a Catalog.boolean +owners has a value which is a reference to a list where each element is a string +dev has a value which is a Catalog.VersionCommitInfo +beta has a value which is a Catalog.VersionCommitInfo +release has a value which is a Catalog.VersionCommitInfo +released_version_list has a value which is a reference to a list where each element is a Catalog.VersionCommitInfo
@@ -4799,6 +5043,13 @@ git_url 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 git_url has a value which is a string +language has a value which is a string +dynamic_service has a value which is a Catalog.boolean +owners has a value which is a reference to a list where each element is a string +dev has a value which is a Catalog.VersionCommitInfo +beta has a value which is a Catalog.VersionCommitInfo +release has a value which is a Catalog.VersionCommitInfo +released_version_list has a value which is a reference to a list where each element is a Catalog.VersionCommitInfo =end text @@ -6463,13 +6714,41 @@ client_groups has a value which is a reference to a list where each element is a if app_ids is empty or null, all client groups are returned +=item Definition + +=begin html + +
+a reference to a hash where the following keys are defined
+
+ +=end html + +=begin text + +a reference to a hash where the following keys are defined + +=end text + +=back + + + +=head2 ClientGroupConfig + +=over 4 + + + =item Definition =begin html
 a reference to a hash where the following keys are defined:
-app_ids has a value which is a reference to a list where each element is a string
+module_name has a value which is a string
+function_name has a value which is a string
+client_groups has a value which is a reference to a list where each element is a string
 
 
@@ -6478,7 +6757,41 @@ app_ids has a value which is a reference to a list where each element is a strin =begin text a reference to a hash where the following keys are defined: -app_ids has a value which is a reference to a list where each element is a string +module_name has a value which is a string +function_name has a value which is a string +client_groups has a value which is a reference to a list where each element is a string + + +=end text + +=back + + + +=head2 ClientGroupFilter + +=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
+function_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 +function_name has a value which is a string =end text diff --git a/lib/biokbase/catalog/Client.py b/lib/biokbase/catalog/Client.py index fab55bc..071222b 100644 --- a/lib/biokbase/catalog/Client.py +++ b/lib/biokbase/catalog/Client.py @@ -140,8 +140,20 @@ def list_basic_module_info(self, params, context=None): parameter "include_disabled" of type "boolean" (@range [0,1]), parameter "include_modules_with_no_name_set" of type "boolean" (@range [0,1]) - :returns: instance of list of type "BasicModuleInfo" -> structure: - parameter "module_name" of String, parameter "git_url" of String + :returns: instance of list of type "BasicModuleInfo" (git_url is + always returned. Every other field may or may not exist depending + on what has been registered or if certain registrations have + failed) -> structure: parameter "module_name" of String, parameter + "git_url" of String, parameter "language" of String, parameter + "dynamic_service" of type "boolean" (@range [0,1]), parameter + "owners" of list of String, parameter "dev" of type + "VersionCommitInfo" -> structure: parameter "git_commit_hash" of + String, parameter "beta" of type "VersionCommitInfo" -> structure: + parameter "git_commit_hash" of String, parameter "release" of type + "VersionCommitInfo" -> structure: parameter "git_commit_hash" of + String, parameter "released_version_list" of list of type + "VersionCommitInfo" -> structure: parameter "git_commit_hash" of + String """ return self._client.call_method( 'Catalog.list_basic_module_info', @@ -881,24 +893,11 @@ def get_exec_raw_stats(self, params, context=None): 'Catalog.get_exec_raw_stats', [params], self._service_ver, context) - def set_client_group(self, group, context=None): - """ - :param group: instance of type "AppClientGroup" (app_id = full app - id; if module name is used it will be case insensitive this will - overwrite all existing client groups (it won't just push what's on - the list) If client_groups is empty or set to null, then the - client_group mapping will be removed.) -> structure: parameter - "app_id" of String, parameter "client_groups" of list of String - """ - return self._client.call_method( - 'Catalog.set_client_group', - [group], self._service_ver, context) - def get_client_groups(self, params, context=None): """ + @deprecated list_client_group_configs :param params: instance of type "GetClientGroupParams" (if app_ids is empty or null, all client groups are returned) -> structure: - parameter "app_ids" of list of String :returns: instance of list of type "AppClientGroup" (app_id = full app id; if module name is used it will be case insensitive this will overwrite all existing client groups (it won't just push @@ -910,6 +909,39 @@ def get_client_groups(self, params, context=None): 'Catalog.get_client_groups', [params], self._service_ver, context) + def set_client_group_config(self, config, context=None): + """ + :param config: instance of type "ClientGroupConfig" -> structure: + parameter "module_name" of String, parameter "function_name" of + String, parameter "client_groups" of list of String + """ + return self._client.call_method( + 'Catalog.set_client_group_config', + [config], self._service_ver, context) + + def remove_client_group_config(self, config, context=None): + """ + :param config: instance of type "ClientGroupConfig" -> structure: + parameter "module_name" of String, parameter "function_name" of + String, parameter "client_groups" of list of String + """ + return self._client.call_method( + 'Catalog.remove_client_group_config', + [config], self._service_ver, context) + + def list_client_group_configs(self, filter, context=None): + """ + :param filter: instance of type "ClientGroupFilter" -> structure: + parameter "module_name" of String, parameter "function_name" of + String + :returns: instance of list of type "ClientGroupConfig" -> structure: + parameter "module_name" of String, parameter "function_name" of + String, parameter "client_groups" of list of String + """ + return self._client.call_method( + 'Catalog.list_client_group_configs', + [filter], self._service_ver, context) + def set_volume_mount(self, config, context=None): """ must specify all properties of the VolumeMountConfig diff --git a/lib/biokbase/catalog/Impl.py b/lib/biokbase/catalog/Impl.py index 38a4188..020c9c9 100644 --- a/lib/biokbase/catalog/Impl.py +++ b/lib/biokbase/catalog/Impl.py @@ -21,7 +21,7 @@ class Catalog: ######################################### VERSION = "0.0.1" GIT_URL = "git@github.com:kbase/catalog.git" - GIT_COMMIT_HASH = "a99ebfc9805890197fee193c5ed859ba796c3d63" + GIT_COMMIT_HASH = "52464b1e02762e4ffa5b6f4a0d8e50f71e5c57d0" #BEGIN_CLASS_HEADER #END_CLASS_HEADER @@ -196,8 +196,20 @@ def list_basic_module_info(self, ctx, params): parameter "include_disabled" of type "boolean" (@range [0,1]), parameter "include_modules_with_no_name_set" of type "boolean" (@range [0,1]) - :returns: instance of list of type "BasicModuleInfo" -> structure: - parameter "module_name" of String, parameter "git_url" of String + :returns: instance of list of type "BasicModuleInfo" (git_url is + always returned. Every other field may or may not exist depending + on what has been registered or if certain registrations have + failed) -> structure: parameter "module_name" of String, parameter + "git_url" of String, parameter "language" of String, parameter + "dynamic_service" of type "boolean" (@range [0,1]), parameter + "owners" of list of String, parameter "dev" of type + "VersionCommitInfo" -> structure: parameter "git_commit_hash" of + String, parameter "beta" of type "VersionCommitInfo" -> structure: + parameter "git_commit_hash" of String, parameter "release" of type + "VersionCommitInfo" -> structure: parameter "git_commit_hash" of + String, parameter "released_version_list" of list of type + "VersionCommitInfo" -> structure: parameter "git_commit_hash" of + String """ # ctx is the context object # return variables are: info_list @@ -1185,26 +1197,11 @@ def get_exec_raw_stats(self, ctx, params): # return the results return [records] - def set_client_group(self, ctx, group): - """ - :param group: instance of type "AppClientGroup" (app_id = full app - id; if module name is used it will be case insensitive this will - overwrite all existing client groups (it won't just push what's on - the list) If client_groups is empty or set to null, then the - client_group mapping will be removed.) -> structure: parameter - "app_id" of String, parameter "client_groups" of list of String - """ - # ctx is the context object - #BEGIN set_client_group - self.cc.set_client_group(ctx['user_id'], group) - #END set_client_group - pass - def get_client_groups(self, ctx, params): """ + @deprecated list_client_group_configs :param params: instance of type "GetClientGroupParams" (if app_ids is empty or null, all client groups are returned) -> structure: - parameter "app_ids" of list of String :returns: instance of list of type "AppClientGroup" (app_id = full app id; if module name is used it will be case insensitive this will overwrite all existing client groups (it won't just push @@ -1225,6 +1222,52 @@ def get_client_groups(self, ctx, params): # return the results return [groups] + def set_client_group_config(self, ctx, config): + """ + :param config: instance of type "ClientGroupConfig" -> structure: + parameter "module_name" of String, parameter "function_name" of + String, parameter "client_groups" of list of String + """ + # ctx is the context object + #BEGIN set_client_group_config + self.cc.set_client_group_config(ctx['user_id'], config) + #END set_client_group_config + pass + + def remove_client_group_config(self, ctx, config): + """ + :param config: instance of type "ClientGroupConfig" -> structure: + parameter "module_name" of String, parameter "function_name" of + String, parameter "client_groups" of list of String + """ + # ctx is the context object + #BEGIN remove_client_group_config + self.cc.remove_client_group_config(ctx['user_id'], config) + #END remove_client_group_config + pass + + def list_client_group_configs(self, ctx, filter): + """ + :param filter: instance of type "ClientGroupFilter" -> structure: + parameter "module_name" of String, parameter "function_name" of + String + :returns: instance of list of type "ClientGroupConfig" -> structure: + parameter "module_name" of String, parameter "function_name" of + String, parameter "client_groups" of list of String + """ + # ctx is the context object + # return variables are: groups + #BEGIN list_client_group_configs + groups = self.cc.list_client_group_configs(filter) + #END list_client_group_configs + + # At some point might do deeper type checking... + if not isinstance(groups, list): + raise ValueError('Method list_client_group_configs return value ' + + 'groups is not type list as required.') + # return the results + return [groups] + def set_volume_mount(self, ctx, config): """ must specify all properties of the VolumeMountConfig diff --git a/lib/biokbase/catalog/Server.py b/lib/biokbase/catalog/Server.py index 0a1c12f..af09871 100644 --- a/lib/biokbase/catalog/Server.py +++ b/lib/biokbase/catalog/Server.py @@ -479,14 +479,22 @@ def __init__(self): name='Catalog.get_exec_raw_stats', types=[dict]) self.method_authentication['Catalog.get_exec_raw_stats'] = 'required' - self.rpc_service.add(impl_Catalog.set_client_group, - name='Catalog.set_client_group', - types=[dict]) - self.method_authentication['Catalog.set_client_group'] = 'required' 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.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.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.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.rpc_service.add(impl_Catalog.set_volume_mount, name='Catalog.set_volume_mount', types=[dict]) diff --git a/lib/biokbase/catalog/controller.py b/lib/biokbase/catalog/controller.py index 882a9b8..02dcd0a 100644 --- a/lib/biokbase/catalog/controller.py +++ b/lib/biokbase/catalog/controller.py @@ -656,7 +656,33 @@ def list_basic_module_info(self,params): if params['owners']: # might want to filter out empty strings in the future query['owners.kb_username']={'$in':params['owners']} - return self.db.find_basic_module_info(query) + modList = self.db.find_basic_module_info(query) + + # now massage data into a nice format for the API + final_modList = [] + for m in modList: + if 'owners' in m: + owner_list = [] + for o in m['owners']: + owner_list.append(o['kb_username']) + m['owners']=owner_list + else: + continue + if 'current_versions' in m: + for tag in ['dev', 'beta', 'release']: + m[tag] = None + if tag in m['current_versions']: + m[tag] = m['current_versions'][tag] + del(m['current_versions']) + if 'info' in m: + if 'language' in m['info']: + m['language'] = m['info']['language'] + if 'dynamic_service' in m['info']: + m['dynamic_service'] = m['info']['dynamic_service'] + del(m['info']) + final_modList.append(m) + + return final_modList @@ -1185,29 +1211,78 @@ def get_exec_raw_stats(self, requesting_user, params): - - def set_client_group(self, username, params): + def set_client_group_config(self, username, config): if not self.is_admin(username): raise ValueError('You do not have permission to set execution client groups.') - if not 'app_id' in params: - raise ValueError('You must set the "app_id" parameter to [module_name]/[app_id]') + record = {} - client_groups = [] - if 'client_groups' in params: - if not isinstance(params['client_groups'], list): - raise ValueError('client_groups parameter must be a list') - for c in params['client_groups']: - #if not isinstance(c, str): - # raise ValueError('client_groups parameter must be a list of strings') - # other client group checks should go here if needed - client_groups.append(c) + if 'module_name' not in config: + raise ValueError('module_name parameter field is required') + if not isinstance(config['module_name'],basestring): + raise ValueError('module_name parameter field must be a string') + record['module_name'] = config['module_name'].strip() - error = self.db.set_client_group(params['app_id'], client_groups) + if 'function_name' not in config: + raise ValueError('function_name parameter field is required') + if not isinstance(config['function_name'],basestring): + raise ValueError('function_name parameter field must be a string') + record['function_name'] = config['function_name'].strip() + + if 'client_groups' not in config: + config['client_groups'] = [] + if not isinstance(config['client_groups'],list): + raise ValueError('client_groups parameter field must be a list') + + for c in config['client_groups']: + if not isinstance(c,basestring): + raise ValueError('client_groups must be a list of strings') + record['client_groups'] = config['client_groups'] + + error = self.db.set_client_group_config(record) if error is not None: raise ValueError('Update probably failed, blame mongo: update operation returned: '+error) + def remove_client_group_config(self, username, config): + # do some parameter checks + if not self.is_admin(username): + raise ValueError('You do not have permission to remove volume mounts.') + + selection = {} + + if 'module_name' not in config: + raise ValueError('module_name parameter field is required') + if not isinstance(config['module_name'],basestring): + raise ValueError('module_name parameter field must be a string') + selection['module_name'] = config['module_name'].strip() + + if 'function_name' not in config: + raise ValueError('function_name parameter field is required') + if not isinstance(config['function_name'],basestring): + raise ValueError('function_name parameter field must be a string') + selection['function_name'] = config['function_name'].strip() + + error = self.db.remove_client_group_config(selection) + if error is not None: + raise ValueError('Removal probably failed, blame mongo: remove operation returned: '+error) + + def list_client_group_configs(self, filter): + processed_filter = {} + if filter: + if 'module_name' in filter: + if not isinstance(filter['module_name'],basestring): + raise ValueError('module_name parameter field must be a string') + processed_filter['module_name'] = filter['module_name'].strip() + + if 'function_name' in filter: + if not isinstance(filter['function_name'],basestring): + raise ValueError('function_name parameter field must be a string') + processed_filter['function_name'] = filter['function_name'].strip() + + return self.db.list_client_group_configs(processed_filter) + + def get_client_groups(self, params): app_ids = None if 'app_ids' in params: @@ -1221,7 +1296,12 @@ def get_client_groups(self, params): app_ids.append(a) if len(app_ids) == 0 : app_ids = None - return self.db.list_client_groups(app_ids) + groups = self.db.list_client_groups(app_ids) + # we have to munge the group data to the old structure + for g in groups: + g['app_id'] = g['module_name'].lower() + '/' + g['function_name'] + + return groups def set_volume_mount(self, username, config): diff --git a/lib/biokbase/catalog/db.py b/lib/biokbase/catalog/db.py index 3b7bb6e..54640d3 100644 --- a/lib/biokbase/catalog/db.py +++ b/lib/biokbase/catalog/db.py @@ -151,6 +151,9 @@ 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] + # check the db schema + self.check_db_schema() + # Make sure we have an index on module and git_repo_url self.module_versions.ensure_index('module_name_lc', sparse=False) self.module_versions.ensure_index('git_commit_hash', sparse=False) @@ -178,7 +181,6 @@ def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): unique=True, sparse=False) # developers indecies - self.developers.ensure_index('kb_username', unique=True) self.build_logs.ensure_index('registration_id',unique=True) @@ -228,10 +230,11 @@ def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): ('time_range', ASCENDING)], unique=True, sparse=False) - # client group - # app_id = [lower case module name]/[app id] - self.client_groups.ensure_index('app_id', unique=True, sparse=False) - + + # client groups and volume mounts + self.client_groups.ensure_index([('module_name_lc', ASCENDING), + ('function_name', ASCENDING)], + unique=True, sparse=False) self.volume_mounts.ensure_index([('client_group', ASCENDING), ('module_name_lc', ASCENDING), @@ -239,11 +242,6 @@ def __init__(self, mongo_host, mongo_db, mongo_user, mongo_psswd): unique=True, sparse=False) - - self.check_db_schema() - - - def is_registered(self,module_name='',git_url=''): if not module_name and not git_url: return False @@ -727,7 +725,16 @@ def get_module_full_details(self, module_name='', git_url='', substitute_version #### LIST / SEARCH methods def find_basic_module_info(self, query): - return list(self.modules.find(query,{'module_name':1,'git_url':1,'_id':0})) + selection = { + '_id':0, + 'module_name':1, + 'git_url':1, + 'info':1, + 'current_versions':1, + 'release_version_list':1, + 'owners':1 + } + return list(self.modules.find(query,selection)) def find_current_versions_and_owners(self, query): result = list(self.modules.find(query,{'module_name':1,'module_name_lc':1,'git_url':1,'current_versions':1,'owners':1,'_id':0})) @@ -966,37 +973,60 @@ def aggregate_favorites_over_apps(self, module_names_lc): }) return counts + # DEPRECATED! temporary function until everything is migrated to new client group structure + def list_client_groups(self, app_ids): + if app_ids is not None: + selection = { + '_id': 0, + 'function_name': 1, + 'client_groups': 1, + 'module_name':1, + 'module_name_lc':1 + } + gList = list(self.client_groups.find({}, selection)) + filteredGList = [] + for g in gList: + for a in app_ids: + if g['module_name_lc'] + '/' + g['function_name'] == a: + filteredGList.append(g); + for g in filteredGList: + del[g['module_name_lc']] + return filteredGList + + selection = { + '_id': 0, + 'function_name': 1, + 'client_groups': 1, + 'module_name':1 + } + return list(self.client_groups.find({}, selection)) - # assumes module names in app_ids are already lower - def set_client_group(self, app_id, client_groups): - if not app_id: - return - - if not client_groups: - client_groups = [] - - # lower case the module name on insert - tokens = app_id.strip().split('/') - if len(tokens)==2 : - app_id = tokens[0].lower() + '/' + tokens[1]; + def set_client_group_config(self, config): + config['module_name_lc'] = config['module_name'].lower() return self._check_update_result(self.client_groups.update( - {'app_id':app_id}, - {'app_id':app_id, 'client_groups': client_groups }, + { + 'module_name_lc':config['module_name_lc'], + 'function_name':config['function_name'] + }, + config, upsert=True )) + def remove_client_group_config(self, config): + config['module_name_lc'] = config['module_name'].lower() + return self._check_update_result(self.client_groups.remove( + { + 'module_name_lc':config['module_name_lc'], + 'function_name':config['function_name'] + } + )) - def list_client_groups(self, app_ids): - query = {} - selection = { - "_id": 0, - "app_id": 1, - "client_groups": 1 - } - if app_ids: - query['app_id'] = { '$in':app_ids } - - return list(self.client_groups.find(query, selection)) + def list_client_group_configs(self, filter): + selection = { "_id": 0, "module_name_lc":0 } + if 'module_name' in filter: + filter['module_name_lc'] = filter['module_name'].lower() + del(filter['module_name']) + return list(self.client_groups.find(filter, selection)) def set_volume_mount(self, volume_mount): @@ -1218,6 +1248,12 @@ def check_db_schema(self): self.update_db_version(3) print('done.') + if db_version<4: + print('Updating DB schema to V4...') + self.update_db_3_to_4() + self.update_db_version(4) + print('done.') + def get_db_version(self): # version is a collection that should only have a single @@ -1298,6 +1334,13 @@ def update_db_1_to_2(self): # a separate module versions collection. def update_db_2_to_3(self): + self.module_versions.ensure_index('module_name_lc', sparse=False) + self.module_versions.ensure_index('git_commit_hash', sparse=False) + self.module_versions.ensure_index([ + ('module_name_lc',ASCENDING), + ('git_commit_hash',ASCENDING)], + unique=True, sparse=False) + # update all module versions for m in self.modules.find({}): @@ -1366,6 +1409,35 @@ def prepare_version_doc_for_db_2_to_3_update(self, version, module): else: version['release_timestamp'] = None + # version 4 performs a small modification to the client group structure and volume_mounts structure + def update_db_3_to_4(self): + + # make sure we don't have any indecies on the collections + self.volume_mounts.drop_indexes() + self.client_groups.drop_indexes() + + # update the volume_mounts, just need to rename app_id to function_name + for vm in self.volume_mounts.find({}): + if 'app_id' in vm and 'function_name' not in vm: + self.volume_mounts.update( + {'_id':vm['_id']}, + {'$set':{ 'function_name':vm['app_id'] }, '$unset':{ 'app_id':1 } } + ) + + for cg in self.client_groups.find({}): + if 'app_id' in cg: + self.client_groups.remove({'_id':cg['_id']}) + tokens = cg['app_id'].split('/') + if(len(tokens) != 2): + print(' When updating client groups, bad app_id found. Record will be lost:') + pprint.pprint(cg) + new_cg = { + 'module_name' : tokens[0], + 'module_name_lc' : tokens[0].lower(), + 'function_name' : tokens[1], + 'client_groups' : cg['client_groups'] + } + self.client_groups.insert(new_cg) diff --git a/lib/biokbase/catalog/version.py b/lib/biokbase/catalog/version.py index 9bf7cae..d33c393 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.4' \ No newline at end of file +CATALOG_VERSION = '2.0.5' \ No newline at end of file diff --git a/lib/java/us/kbase/catalog/BasicModuleInfo.java b/lib/java/us/kbase/catalog/BasicModuleInfo.java index f40e601..2eaba82 100644 --- a/lib/java/us/kbase/catalog/BasicModuleInfo.java +++ b/lib/java/us/kbase/catalog/BasicModuleInfo.java @@ -2,6 +2,7 @@ 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; @@ -13,66 +14,241 @@ /** *

Original spec-file type: BasicModuleInfo

- * + *
+ * git_url is always returned.  Every other field
+ * may or may not exist depending on what has been registered or if
+ * certain registrations have failed
+ * 
* */ @JsonInclude(JsonInclude.Include.NON_NULL) @Generated("com.googlecode.jsonschema2pojo") @JsonPropertyOrder({ "module_name", - "git_url" + "git_url", + "language", + "dynamic_service", + "owners", + "dev", + "beta", + "release", + "released_version_list" }) public class BasicModuleInfo { @JsonProperty("module_name") - private String moduleName; + private java.lang.String moduleName; @JsonProperty("git_url") - private String gitUrl; - private Map additionalProperties = new HashMap(); + private java.lang.String gitUrl; + @JsonProperty("language") + private java.lang.String language; + @JsonProperty("dynamic_service") + private Long dynamicService; + @JsonProperty("owners") + private List owners; + /** + *

Original spec-file type: VersionCommitInfo

+ * + * + */ + @JsonProperty("dev") + private us.kbase.catalog.VersionCommitInfo dev; + /** + *

Original spec-file type: VersionCommitInfo

+ * + * + */ + @JsonProperty("beta") + private us.kbase.catalog.VersionCommitInfo beta; + /** + *

Original spec-file type: VersionCommitInfo

+ * + * + */ + @JsonProperty("release") + private us.kbase.catalog.VersionCommitInfo release; + @JsonProperty("released_version_list") + private List releasedVersionList; + private Map additionalProperties = new HashMap(); @JsonProperty("module_name") - public String getModuleName() { + public java.lang.String getModuleName() { return moduleName; } @JsonProperty("module_name") - public void setModuleName(String moduleName) { + public void setModuleName(java.lang.String moduleName) { this.moduleName = moduleName; } - public BasicModuleInfo withModuleName(String moduleName) { + public BasicModuleInfo withModuleName(java.lang.String moduleName) { this.moduleName = moduleName; return this; } @JsonProperty("git_url") - public String getGitUrl() { + public java.lang.String getGitUrl() { return gitUrl; } @JsonProperty("git_url") - public void setGitUrl(String gitUrl) { + public void setGitUrl(java.lang.String gitUrl) { this.gitUrl = gitUrl; } - public BasicModuleInfo withGitUrl(String gitUrl) { + public BasicModuleInfo withGitUrl(java.lang.String gitUrl) { this.gitUrl = gitUrl; return this; } + @JsonProperty("language") + public java.lang.String getLanguage() { + return language; + } + + @JsonProperty("language") + public void setLanguage(java.lang.String language) { + this.language = language; + } + + public BasicModuleInfo withLanguage(java.lang.String language) { + this.language = language; + return this; + } + + @JsonProperty("dynamic_service") + public Long getDynamicService() { + return dynamicService; + } + + @JsonProperty("dynamic_service") + public void setDynamicService(Long dynamicService) { + this.dynamicService = dynamicService; + } + + public BasicModuleInfo withDynamicService(Long dynamicService) { + this.dynamicService = dynamicService; + return this; + } + + @JsonProperty("owners") + public List getOwners() { + return owners; + } + + @JsonProperty("owners") + public void setOwners(List owners) { + this.owners = owners; + } + + public BasicModuleInfo withOwners(List owners) { + this.owners = owners; + return this; + } + + /** + *

Original spec-file type: VersionCommitInfo

+ * + * + */ + @JsonProperty("dev") + public us.kbase.catalog.VersionCommitInfo getDev() { + return dev; + } + + /** + *

Original spec-file type: VersionCommitInfo

+ * + * + */ + @JsonProperty("dev") + public void setDev(us.kbase.catalog.VersionCommitInfo dev) { + this.dev = dev; + } + + public BasicModuleInfo withDev(us.kbase.catalog.VersionCommitInfo dev) { + this.dev = dev; + return this; + } + + /** + *

Original spec-file type: VersionCommitInfo

+ * + * + */ + @JsonProperty("beta") + public us.kbase.catalog.VersionCommitInfo getBeta() { + return beta; + } + + /** + *

Original spec-file type: VersionCommitInfo

+ * + * + */ + @JsonProperty("beta") + public void setBeta(us.kbase.catalog.VersionCommitInfo beta) { + this.beta = beta; + } + + public BasicModuleInfo withBeta(us.kbase.catalog.VersionCommitInfo beta) { + this.beta = beta; + return this; + } + + /** + *

Original spec-file type: VersionCommitInfo

+ * + * + */ + @JsonProperty("release") + public us.kbase.catalog.VersionCommitInfo getRelease() { + return release; + } + + /** + *

Original spec-file type: VersionCommitInfo

+ * + * + */ + @JsonProperty("release") + public void setRelease(us.kbase.catalog.VersionCommitInfo release) { + this.release = release; + } + + public BasicModuleInfo withRelease(us.kbase.catalog.VersionCommitInfo release) { + this.release = release; + return this; + } + + @JsonProperty("released_version_list") + public List getReleasedVersionList() { + return releasedVersionList; + } + + @JsonProperty("released_version_list") + public void setReleasedVersionList(List releasedVersionList) { + this.releasedVersionList = releasedVersionList; + } + + public BasicModuleInfo withReleasedVersionList(List releasedVersionList) { + this.releasedVersionList = releasedVersionList; + return this; + } + @JsonAnyGetter - public Map getAdditionalProperties() { + public Map getAdditionalProperties() { return this.additionalProperties; } @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { + public void setAdditionalProperties(java.lang.String name, Object value) { this.additionalProperties.put(name, value); } @Override - public String toString() { - return ((((((("BasicModuleInfo"+" [moduleName=")+ moduleName)+", gitUrl=")+ gitUrl)+", additionalProperties=")+ additionalProperties)+"]"); + public java.lang.String toString() { + return ((((((((((((((((((((("BasicModuleInfo"+" [moduleName=")+ moduleName)+", gitUrl=")+ gitUrl)+", language=")+ language)+", dynamicService=")+ dynamicService)+", owners=")+ owners)+", dev=")+ dev)+", beta=")+ beta)+", release=")+ release)+", releasedVersionList=")+ releasedVersionList)+", additionalProperties=")+ additionalProperties)+"]"); } } diff --git a/lib/java/us/kbase/catalog/CatalogClient.java b/lib/java/us/kbase/catalog/CatalogClient.java index 7de2943..76e6c3e 100644 --- a/lib/java/us/kbase/catalog/CatalogClient.java +++ b/lib/java/us/kbase/catalog/CatalogClient.java @@ -777,34 +777,67 @@ public List getExecRawStats(GetExecRawStatsParams params, RpcContext... } /** - *

Original spec-file function name: set_client_group

+ *

Original spec-file function name: get_client_groups

*
+     * @deprecated list_client_group_configs
      * 
- * @param group instance of type {@link us.kbase.catalog.AppClientGroup AppClientGroup} + * @param params instance of type {@link us.kbase.catalog.GetClientGroupParams GetClientGroupParams} + * @return parameter "groups" of list of type {@link us.kbase.catalog.AppClientGroup AppClientGroup} * @throws IOException if an IO exception occurs * @throws JsonClientException if a JSON RPC exception occurs */ - public void setClientGroup(AppClientGroup group, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + public List getClientGroups(GetClientGroupParams params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { List args = new ArrayList(); - args.add(group); + args.add(params); + TypeReference>> retType = new TypeReference>>() {}; + List> res = caller.jsonrpcCall("Catalog.get_client_groups", args, retType, true, false, jsonRpcContext); + return res.get(0); + } + + /** + *

Original spec-file function name: set_client_group_config

+ *
+     * 
+ * @param config instance of type {@link us.kbase.catalog.ClientGroupConfig ClientGroupConfig} + * @throws IOException if an IO exception occurs + * @throws JsonClientException if a JSON RPC exception occurs + */ + public void setClientGroupConfig(ClientGroupConfig config, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + List args = new ArrayList(); + args.add(config); TypeReference retType = new TypeReference() {}; - caller.jsonrpcCall("Catalog.set_client_group", args, retType, false, true, jsonRpcContext); + caller.jsonrpcCall("Catalog.set_client_group_config", args, retType, false, true, jsonRpcContext); } /** - *

Original spec-file function name: get_client_groups

+ *

Original spec-file function name: remove_client_group_config

*
      * 
- * @param params instance of type {@link us.kbase.catalog.GetClientGroupParams GetClientGroupParams} - * @return parameter "groups" of list of type {@link us.kbase.catalog.AppClientGroup AppClientGroup} + * @param config instance of type {@link us.kbase.catalog.ClientGroupConfig ClientGroupConfig} * @throws IOException if an IO exception occurs * @throws JsonClientException if a JSON RPC exception occurs */ - public List getClientGroups(GetClientGroupParams params, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + public void removeClientGroupConfig(ClientGroupConfig config, RpcContext... jsonRpcContext) throws IOException, JsonClientException { List args = new ArrayList(); - args.add(params); - TypeReference>> retType = new TypeReference>>() {}; - List> res = caller.jsonrpcCall("Catalog.get_client_groups", args, retType, true, false, jsonRpcContext); + args.add(config); + TypeReference retType = new TypeReference() {}; + caller.jsonrpcCall("Catalog.remove_client_group_config", args, retType, false, true, jsonRpcContext); + } + + /** + *

Original spec-file function name: list_client_group_configs

+ *
+     * 
+ * @param filter instance of type {@link us.kbase.catalog.ClientGroupFilter ClientGroupFilter} + * @return parameter "groups" of list of type {@link us.kbase.catalog.ClientGroupConfig ClientGroupConfig} + * @throws IOException if an IO exception occurs + * @throws JsonClientException if a JSON RPC exception occurs + */ + public List listClientGroupConfigs(ClientGroupFilter filter, RpcContext... jsonRpcContext) throws IOException, JsonClientException { + List args = new ArrayList(); + args.add(filter); + TypeReference>> retType = new TypeReference>>() {}; + List> res = caller.jsonrpcCall("Catalog.list_client_group_configs", args, retType, true, false, jsonRpcContext); return res.get(0); } diff --git a/lib/java/us/kbase/catalog/ClientGroupConfig.java b/lib/java/us/kbase/catalog/ClientGroupConfig.java new file mode 100644 index 0000000..b116dd1 --- /dev/null +++ b/lib/java/us/kbase/catalog/ClientGroupConfig.java @@ -0,0 +1,97 @@ + +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: ClientGroupConfig

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("com.googlecode.jsonschema2pojo") +@JsonPropertyOrder({ + "module_name", + "function_name", + "client_groups" +}) +public class ClientGroupConfig { + + @JsonProperty("module_name") + private java.lang.String moduleName; + @JsonProperty("function_name") + private java.lang.String functionName; + @JsonProperty("client_groups") + private List clientGroups; + private Map additionalProperties = new HashMap(); + + @JsonProperty("module_name") + public java.lang.String getModuleName() { + return moduleName; + } + + @JsonProperty("module_name") + public void setModuleName(java.lang.String moduleName) { + this.moduleName = moduleName; + } + + public ClientGroupConfig withModuleName(java.lang.String moduleName) { + this.moduleName = moduleName; + return this; + } + + @JsonProperty("function_name") + public java.lang.String getFunctionName() { + return functionName; + } + + @JsonProperty("function_name") + public void setFunctionName(java.lang.String functionName) { + this.functionName = functionName; + } + + public ClientGroupConfig withFunctionName(java.lang.String functionName) { + this.functionName = functionName; + return this; + } + + @JsonProperty("client_groups") + public List getClientGroups() { + return clientGroups; + } + + @JsonProperty("client_groups") + public void setClientGroups(List clientGroups) { + this.clientGroups = clientGroups; + } + + public ClientGroupConfig withClientGroups(List clientGroups) { + this.clientGroups = clientGroups; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperties(java.lang.String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public java.lang.String toString() { + return ((((((((("ClientGroupConfig"+" [moduleName=")+ moduleName)+", functionName=")+ functionName)+", clientGroups=")+ clientGroups)+", additionalProperties=")+ additionalProperties)+"]"); + } + +} diff --git a/lib/java/us/kbase/catalog/ClientGroupFilter.java b/lib/java/us/kbase/catalog/ClientGroupFilter.java new file mode 100644 index 0000000..bf245a3 --- /dev/null +++ b/lib/java/us/kbase/catalog/ClientGroupFilter.java @@ -0,0 +1,78 @@ + +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: ClientGroupFilter

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("com.googlecode.jsonschema2pojo") +@JsonPropertyOrder({ + "module_name", + "function_name" +}) +public class ClientGroupFilter { + + @JsonProperty("module_name") + private String moduleName; + @JsonProperty("function_name") + private String functionName; + 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 ClientGroupFilter withModuleName(String moduleName) { + this.moduleName = moduleName; + return this; + } + + @JsonProperty("function_name") + public String getFunctionName() { + return functionName; + } + + @JsonProperty("function_name") + public void setFunctionName(String functionName) { + this.functionName = functionName; + } + + public ClientGroupFilter withFunctionName(String functionName) { + this.functionName = functionName; + 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 ((((((("ClientGroupFilter"+" [moduleName=")+ moduleName)+", functionName=")+ functionName)+", additionalProperties=")+ additionalProperties)+"]"); + } + +} diff --git a/lib/java/us/kbase/catalog/GetClientGroupParams.java b/lib/java/us/kbase/catalog/GetClientGroupParams.java index aa164a8..f883b09 100644 --- a/lib/java/us/kbase/catalog/GetClientGroupParams.java +++ b/lib/java/us/kbase/catalog/GetClientGroupParams.java @@ -2,13 +2,11 @@ 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; @@ -22,42 +20,25 @@ @JsonInclude(JsonInclude.Include.NON_NULL) @Generated("com.googlecode.jsonschema2pojo") @JsonPropertyOrder({ - "app_ids" + }) public class GetClientGroupParams { - @JsonProperty("app_ids") - private List appIds; - private Map additionalProperties = new HashMap(); - - @JsonProperty("app_ids") - public List getAppIds() { - return appIds; - } - - @JsonProperty("app_ids") - public void setAppIds(List appIds) { - this.appIds = appIds; - } - - public GetClientGroupParams withAppIds(List appIds) { - this.appIds = appIds; - return this; - } + private Map additionalProperties = new HashMap(); @JsonAnyGetter - public Map getAdditionalProperties() { + public Map getAdditionalProperties() { return this.additionalProperties; } @JsonAnySetter - public void setAdditionalProperties(java.lang.String name, Object value) { + public void setAdditionalProperties(String name, Object value) { this.additionalProperties.put(name, value); } @Override - public java.lang.String toString() { - return ((((("GetClientGroupParams"+" [appIds=")+ appIds)+", additionalProperties=")+ additionalProperties)+"]"); + public String toString() { + return ((("GetClientGroupParams"+" [additionalProperties=")+ additionalProperties)+"]"); } } diff --git a/lib/java/us/kbase/catalog/VersionCommitInfo.java b/lib/java/us/kbase/catalog/VersionCommitInfo.java new file mode 100644 index 0000000..b3d3a62 --- /dev/null +++ b/lib/java/us/kbase/catalog/VersionCommitInfo.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: VersionCommitInfo

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@Generated("com.googlecode.jsonschema2pojo") +@JsonPropertyOrder({ + "git_commit_hash" +}) +public class VersionCommitInfo { + + @JsonProperty("git_commit_hash") + private String gitCommitHash; + private Map additionalProperties = new HashMap(); + + @JsonProperty("git_commit_hash") + public String getGitCommitHash() { + return gitCommitHash; + } + + @JsonProperty("git_commit_hash") + public void setGitCommitHash(String gitCommitHash) { + this.gitCommitHash = gitCommitHash; + } + + public VersionCommitInfo withGitCommitHash(String gitCommitHash) { + this.gitCommitHash = gitCommitHash; + 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 ((((("VersionCommitInfo"+" [gitCommitHash=")+ gitCommitHash)+", additionalProperties=")+ additionalProperties)+"]"); + } + +} diff --git a/lib/javascript/Client.js b/lib/javascript/Client.js index 9d8370e..3de7cc4 100644 --- a/lib/javascript/Client.js +++ b/lib/javascript/Client.js @@ -519,30 +519,56 @@ function Catalog(url, auth, auth_cb, timeout, async_job_check_time_ms, async_ver [params], 1, _callback, _errorCallback); }; - this.set_client_group = function (group, _callback, _errorCallback) { - if (typeof group === 'function') - throw 'Argument group can not be a function'; + this.get_client_groups = 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("Catalog.set_client_group", - [group], 0, _callback, _errorCallback); + return json_call_ajax("Catalog.get_client_groups", + [params], 1, _callback, _errorCallback); }; - this.get_client_groups = function (params, _callback, _errorCallback) { - if (typeof params === 'function') - throw 'Argument params can not be a function'; + this.set_client_group_config = function (config, _callback, _errorCallback) { + if (typeof config === 'function') + throw 'Argument config 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("Catalog.get_client_groups", - [params], 1, _callback, _errorCallback); + return json_call_ajax("Catalog.set_client_group_config", + [config], 0, _callback, _errorCallback); + }; + + this.remove_client_group_config = function (config, _callback, _errorCallback) { + if (typeof config === 'function') + throw 'Argument config 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("Catalog.remove_client_group_config", + [config], 0, _callback, _errorCallback); + }; + + this.list_client_group_configs = function (filter, _callback, _errorCallback) { + if (typeof filter === 'function') + throw 'Argument filter 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("Catalog.list_client_group_configs", + [filter], 1, _callback, _errorCallback); }; this.set_volume_mount = function (config, _callback, _errorCallback) { diff --git a/test/basic_catalog_test.py b/test/basic_catalog_test.py index aa741e2..e1d7a12 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.4']) + self.assertEqual(self.catalog.version(self.cUtil.anonymous_ctx()),['2.0.5']) def test_is_registered(self): @@ -77,8 +77,20 @@ def test_list_basic_module_info(self): default = self.catalog.list_basic_module_info(self.cUtil.anonymous_ctx(), {})[0] module_names = [] + found_dynamic_service = False; for m in default: module_names.append(m['module_name']) + if m['module_name'] == 'DynamicService': + self.assertEquals(m['dev'],{'git_commit_hash':'b06c5f9daf603a4d206071787c3f6184000bf128'}) + self.assertEquals(m['beta'],{'git_commit_hash':'b843888e962642d665a3b0bd701ee630c01835e6'}) + self.assertEquals(m['release'],{'git_commit_hash':'49dc505febb8f4cccb2078c58ded0de3320534d7'}) + self.assertEquals(sorted(m['owners']),['rsutormin','wstester2']) + self.assertEquals(m['language'],'python') + self.assertEquals(m['dynamic_service'],1) + self.assertEquals(len(m['release_version_list']),4) + found_dynamic_service = True + + self.assertTrue(found_dynamic_service) self.assertEqual( ",".join(sorted(module_names)), ",".join(['DynamicService','DynamicService2','onerepotest','pending_second_release','release_history']) diff --git a/test/catalog_test_util.py b/test/catalog_test_util.py index 2fa094b..1df5e5a 100644 --- a/test/catalog_test_util.py +++ b/test/catalog_test_util.py @@ -158,6 +158,21 @@ def initialize_mongo(self): self.volume_mounts.insert(parsed_document) load_count+=1 + client_groups_dir = os.path.join(self.test_dir, 'initial_mongo_state', MongoCatalogDBI._CLIENT_GROUPS) + for document_name in os.listdir(client_groups_dir): + document_path = os.path.join(client_groups_dir,document_name) + if os.path.isfile(document_path): + with open(document_path) as document_file: + document = document_file.read() + parsed_document = json.loads(document) + if isinstance(parsed_document,list): + for p in parsed_document: + self.client_groups.insert(p) + load_count+=1 + else: + self.client_groups.insert(parsed_document) + load_count+=1 + self.log(str(load_count)+" documents loaded") diff --git a/test/client_group_test.py b/test/client_group_test.py index d0a6947..ef2d599 100644 --- a/test/client_group_test.py +++ b/test/client_group_test.py @@ -19,39 +19,37 @@ def test_basics(self): adminCtx = self.cUtil.admin_ctx() anonCtx = self.cUtil.anonymous_ctx() - # list should be empty + # list should have 5, for these tests groups = self.catalog.get_client_groups(anonCtx, {})[0] - self.assertEqual(groups,[]) + self.assertEqual(len(groups),5) # error if user attempts to set the context with self.assertRaises(ValueError) as e: - self.catalog.set_client_group(userCtx, - {'app_id':'mEgaHit/run_Megahit', 'client_groups':['g1']}) + self.catalog.set_client_group_config(userCtx, + {'module_name':'mEgaHit', 'function_name':'run_Megahit', 'client_groups':['g1']}) self.assertEqual(str(e.exception), 'You do not have permission to set execution client groups.'); # try adding one - self.catalog.set_client_group(adminCtx, - {'app_id':'mEgaHit/run_Megahit', 'client_groups':['g1']}) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'mEgaHit','function_name':'run_Megahit', 'client_groups':['g1']}) groups = self.catalog.get_client_groups(anonCtx, {})[0] - self.assertEqual(len(groups),1) - self.assertEqual(groups[0]['app_id'],'megahit/run_Megahit') - self.assertEqual(groups[0]['client_groups'],['g1']) + self.assertEqual(len(groups),6) # try adding a few more - self.catalog.set_client_group(adminCtx, - {'app_id':'rna/run_something', 'client_groups':['g1']}) - self.catalog.set_client_group(adminCtx, - {'app_id':'rna/run_something2', 'client_groups':['g1','g2']}) - self.catalog.set_client_group(adminCtx, - {'app_id':'rna/run_something3', 'client_groups':['g3']}) - self.catalog.set_client_group(adminCtx, - {'app_id':'DNA/run_something', 'client_groups':['g2']}) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'rna', 'function_name':'run_something', 'client_groups':['g1']}) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'rna', 'function_name':'run_something2', 'client_groups':['g1','g2']}) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'rna', 'function_name':'run_something3', 'client_groups':['g3']}) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'DNA', 'function_name':'run_something', 'client_groups':['g2']}) # check em groups = self.catalog.get_client_groups(anonCtx, {})[0] - self.assertEqual(len(groups),5) + self.assertEqual(len(groups),10) found_megahit = False found_rna = False found_dna = False @@ -100,39 +98,138 @@ def test_basics(self): # should give everything groups = self.catalog.get_client_groups(anonCtx, {'app_ids':[]})[0] - self.assertEqual(len(groups),5) + self.assertEqual(len(groups),10) + + # check some error cases + group_config = {} + with self.assertRaises(ValueError) as e: + self.catalog.set_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'module_name parameter field is required'); + + group_config['module_name'] = [] + with self.assertRaises(ValueError) as e: + self.catalog.set_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'module_name parameter field must be a string'); + group_config['module_name'] = 'Tester2' + + with self.assertRaises(ValueError) as e: + self.catalog.set_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'function_name parameter field is required'); + + group_config['function_name'] = [] + with self.assertRaises(ValueError) as e: + self.catalog.set_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'function_name parameter field must be a string'); + group_config['function_name'] = 'my_app' + + group_config['client_groups'] = {} + with self.assertRaises(ValueError) as e: + self.catalog.set_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'client_groups parameter field must be a list'); + + group_config['client_groups'] = [['asdf']] + with self.assertRaises(ValueError) as e: + self.catalog.set_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'client_groups must be a list of strings'); + + group_config = {} + with self.assertRaises(ValueError) as e: + self.catalog.remove_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'module_name parameter field is required'); + + group_config['module_name'] = [] + with self.assertRaises(ValueError) as e: + self.catalog.remove_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'module_name parameter field must be a string'); + group_config['module_name'] = 'Tester2' + + with self.assertRaises(ValueError) as e: + self.catalog.remove_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'function_name parameter field is required'); + + group_config['function_name'] = [] + with self.assertRaises(ValueError) as e: + self.catalog.remove_client_group_config(adminCtx, group_config) + self.assertEqual(str(e.exception), + 'function_name parameter field must be a string'); + + group_filter = {'module_name':[]} + with self.assertRaises(ValueError) as e: + self.catalog.list_client_group_configs(adminCtx, group_filter) + self.assertEqual(str(e.exception), + 'module_name parameter field must be a string'); + + group_filter = {'function_name':[]} + with self.assertRaises(ValueError) as e: + self.catalog.list_client_group_configs(adminCtx, group_filter) + self.assertEqual(str(e.exception), + 'function_name parameter field must be a string'); # finally check that we can update something a few times - self.catalog.set_client_group(adminCtx, - {'app_id':'DNA/run_something', 'client_groups':['new_group']}) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'DNA', 'function_name':'run_something', 'client_groups':['new_group']}) groups = self.catalog.get_client_groups(anonCtx, {'app_ids':['dna/run_something']})[0] self.assertEqual(len(groups),1) self.assertEqual(groups[0]['app_id'],'dna/run_something') self.assertEqual(groups[0]['client_groups'],['new_group']) - self.catalog.set_client_group(adminCtx, - {'app_id':'DNA/run_something', 'client_groups':['*']}) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'DNA','function_name':'run_something', 'client_groups':['*']}) groups = self.catalog.get_client_groups(anonCtx, {'app_ids':['dna/run_something']})[0] self.assertEqual(len(groups),1) self.assertEqual(groups[0]['app_id'],'dna/run_something') self.assertEqual(groups[0]['client_groups'],['*']) - self.catalog.set_client_group(adminCtx, - {'app_id':'DNA/run_something', 'client_groups':[]}) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'DNA','function_name':'run_something', 'client_groups':[]}) groups = self.catalog.get_client_groups(anonCtx, {'app_ids':['dna/run_something']})[0] self.assertEqual(len(groups),1) self.assertEqual(groups[0]['app_id'],'dna/run_something') self.assertEqual(groups[0]['client_groups'],[]) - - self.catalog.set_client_group(adminCtx, - {'app_id':'DNA/run_something', 'client_groups':['new_g1', 'new_g2', 'new_g3']}) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'DNA','function_name':'run_something', 'client_groups':['new_g1', 'new_g2', 'new_g3']}) groups = self.catalog.get_client_groups(anonCtx, {'app_ids':['dna/run_something']})[0] self.assertEqual(len(groups),1) self.assertEqual(groups[0]['app_id'],'dna/run_something') self.assertEqual(groups[0]['client_groups'],['new_g1', 'new_g2', 'new_g3']) + self.catalog.set_client_group_config(adminCtx, + {'module_name':'DNA','function_name':'run_something'}) + groups = self.catalog.get_client_groups(anonCtx, {'app_ids':['dna/run_something']})[0] + self.assertEqual(len(groups),1) + self.assertEqual(groups[0]['app_id'],'dna/run_something') + self.assertEqual(groups[0]['client_groups'],[]) + + groups = self.catalog.list_client_group_configs(anonCtx,{})[0] + self.assertEqual(len(groups),10) + groups = self.catalog.list_client_group_configs(anonCtx,{'module_name':'DNA'})[0] + self.assertEqual(len(groups),1) + groups = self.catalog.list_client_group_configs(anonCtx,{'function_name':'run_something'})[0] + self.assertEqual(len(groups),2) + + self.catalog.remove_client_group_config(adminCtx, + {'module_name':'DNA','function_name':'run_something'}) + groups = self.catalog.get_client_groups(anonCtx, {'app_ids':['dna/run_something']})[0] + self.assertEqual(len(groups),0) + + groups = self.catalog.list_client_group_configs(anonCtx,{})[0] + self.assertEqual(len(groups),9) + groups = self.catalog.list_client_group_configs(anonCtx,{'module_name':'DNA'})[0] + self.assertEqual(len(groups),0) + groups = self.catalog.list_client_group_configs(anonCtx,{'function_name':'run_something'})[0] + self.assertEqual(len(groups),1) + def test_volume_mount_configs(self): diff --git a/test/initial_mongo_state/client_groups/client_groups.json b/test/initial_mongo_state/client_groups/client_groups.json new file mode 100644 index 0000000..2f16e77 --- /dev/null +++ b/test/initial_mongo_state/client_groups/client_groups.json @@ -0,0 +1,26 @@ +[ +{ + "module_name" : "CGTest1", + "module_name_lc" : "cgtest1", + "function_name" : "func1", + "client_groups" : ["G1"] +}, +{ + "module_name" : "CGTest1", + "module_name_lc" : "cgtest1", + "function_name" : "func2", + "client_groups" : ["G1", "G2"] +}, +{ + "app_id" : "module1234/app", + "client_groups" : ["G1", "G2"] +}, +{ + "app_id" : "module421/app2", + "client_groups" : ["G2"] +}, +{ + "app_id" : "module4/app2312", + "client_groups" : [] +} +] \ No newline at end of file diff --git a/test/initial_mongo_state/volume_mounts/volumes.json b/test/initial_mongo_state/volume_mounts/volumes.json index 4b677e3..e3dc8db 100644 --- a/test/initial_mongo_state/volume_mounts/volumes.json +++ b/test/initial_mongo_state/volume_mounts/volumes.json @@ -21,7 +21,7 @@ "module_name" : "VolMountModTest2", "module_name_lc" : "volmountmodtest2", "client_group" : "G2", - "function_name": "func1", + "app_id": "func1", "volume_mounts" : [ { "host_dir" : "/home/wstester1", @@ -34,7 +34,7 @@ "module_name" : "VolMountModTest2", "module_name_lc" : "volmountmodtest2", "client_group" : "G3", - "function_name": "func1", + "app_id": "func1", "volume_mounts" : [ { "host_dir" : "/home/2/wstester1",