Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-4917 - Error generating opencga clients #2332

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions opencga-app/app/misc/clients/rest_client_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ def get_method_name(self, endpoint, category):
# /{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/{interpretationId}/merge
elif self.all_arg([items[0], items[2]]) and not self.any_arg([items[1], items[3]]):
method_name = '_'.join([items[3], items[1]])
# /{apiVersion}/admin/users/{user}/groups/update
elif self.all_arg([items[1]]) and not self.any_arg([items[0], items[2], items[3]]):
method_name = '_'.join([items[0], items[3], items[2]])
elif len(items) == 5:
# e.g. /{apiVersion}/files/{file}/annotationSets/{annotationSet}/annotations/update
if self.all_arg([items[0], items[2]]) and not self.any_arg([items[1], items[3], items[4]]):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023-04-18 OpenCB
* Copyright 2015-2023-08-30 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,7 +70,7 @@ public abstract class OpenCgaCompleter implements Completer {
.map(Candidate::new)
.collect(toList());

private List<Candidate> adminList = asList( "audit-group-by","catalog-index-stats","catalog-install","catalog-jwt","users-create","users-import","users-search","users-sync")
private List<Candidate> adminList = asList( "audit-group-by","catalog-index-stats","catalog-install","catalog-jwt","users-create","users-import","users-search","users-sync","update-groups-users")
.stream()
.map(Candidate::new)
.collect(toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023-04-18 OpenCB
* Copyright 2015-2023-08-30 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -188,6 +188,7 @@ public OpencgaCliOptionsParser() {
adminSubCommands.addCommand("users-import", adminCommandOptions.importUsersCommandOptions);
adminSubCommands.addCommand("users-search", adminCommandOptions.searchUsersCommandOptions);
adminSubCommands.addCommand("users-sync", adminCommandOptions.syncUsersCommandOptions);
adminSubCommands.addCommand("update-groups-users", adminCommandOptions.usersUpdateGroupsCommandOptions);

individualsCommandOptions = new IndividualsCommandOptions(commonCommandOptions, jCommander);
jCommander.addCommand("individuals", individualsCommandOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import org.opencb.opencga.app.cli.main.options.AdminCommandOptions;

import java.util.Map;
import org.opencb.opencga.catalog.utils.ParamUtils.AddRemoveAction;
import org.opencb.opencga.core.models.admin.GroupSyncParams;
import org.opencb.opencga.core.models.admin.InstallationParams;
import org.opencb.opencga.core.models.admin.JWTParams;
import org.opencb.opencga.core.models.admin.UserCreateParams;
import org.opencb.opencga.core.models.admin.UserImportParams;
import org.opencb.opencga.core.models.admin.UserUpdateGroup;
import org.opencb.opencga.core.models.common.Enums.Resource;
import org.opencb.opencga.core.models.sample.Sample;
import org.opencb.opencga.core.models.study.Group;
Expand Down Expand Up @@ -87,6 +89,9 @@ public void execute() throws Exception {
case "users-sync":
queryResponse = syncUsers();
break;
case "update-groups-users":
queryResponse = usersUpdateGroups();
break;
default:
logger.error("Subcommand not valid");
break;
Expand Down Expand Up @@ -288,4 +293,35 @@ private RestResponse<Group> syncUsers() throws Exception {
}
return openCGAClient.getAdminClient().syncUsers(groupSyncParams);
}

private RestResponse<Group> usersUpdateGroups() throws Exception {
logger.debug("Executing usersUpdateGroups in Admin command line");

AdminCommandOptions.UsersUpdateGroupsCommandOptions commandOptions = adminCommandOptions.usersUpdateGroupsCommandOptions;

ObjectMap queryParams = new ObjectMap();
queryParams.putIfNotNull("action", commandOptions.action);


UserUpdateGroup userUpdateGroup = null;
if (commandOptions.jsonDataModel) {
userUpdateGroup = new UserUpdateGroup();
RestResponse<Group> res = new RestResponse<>();
res.setType(QueryType.VOID);
PrintUtils.println(getObjectAsJSON(userUpdateGroup));
return res;
} else if (commandOptions.jsonFile != null) {
userUpdateGroup = JacksonUtils.getDefaultObjectMapper()
.readValue(new java.io.File(commandOptions.jsonFile), UserUpdateGroup.class);
} else {
ObjectMap beanParams = new ObjectMap();
putNestedIfNotNull(beanParams, "studyIds",commandOptions.studyIds, true);
putNestedIfNotNull(beanParams, "groupIds",commandOptions.groupIds, true);

userUpdateGroup = JacksonUtils.getDefaultObjectMapper().copy()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
.readValue(beanParams.toJson(), UserUpdateGroup.class);
}
return openCGAClient.getAdminClient().usersUpdateGroups(commandOptions.user, userUpdateGroup, queryParams);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class AdminCommandOptions {
public ImportUsersCommandOptions importUsersCommandOptions;
public SearchUsersCommandOptions searchUsersCommandOptions;
public SyncUsersCommandOptions syncUsersCommandOptions;
public UsersUpdateGroupsCommandOptions usersUpdateGroupsCommandOptions;


public AdminCommandOptions(CommonCommandOptions commonCommandOptions, JCommander jCommander) {
Expand All @@ -55,6 +56,7 @@ public AdminCommandOptions(CommonCommandOptions commonCommandOptions, JCommander
this.importUsersCommandOptions = new ImportUsersCommandOptions();
this.searchUsersCommandOptions = new SearchUsersCommandOptions();
this.syncUsersCommandOptions = new SyncUsersCommandOptions();
this.usersUpdateGroupsCommandOptions = new UsersUpdateGroupsCommandOptions();

}

Expand Down Expand Up @@ -278,4 +280,30 @@ public class SyncUsersCommandOptions {

}

@Parameters(commandNames = {"update-groups-users"}, commandDescription ="Add or remove users from existing groups")
public class UsersUpdateGroupsCommandOptions {

@ParametersDelegate
public CommonCommandOptions commonOptions = commonCommandOptions;

@Parameter(names = {"--json-file"}, description = "File with the body data in JSON format. Note, that using this parameter will ignore all the other parameters.", required = false, arity = 1)
public String jsonFile;

@Parameter(names = {"--json-data-model"}, description = "Show example of file structure for body data.", help = true, arity = 0)
public Boolean jsonDataModel = false;

@Parameter(names = {"--user", "-u"}, description = "User ID", required = true, arity = 1)
public String user;

@Parameter(names = {"--action"}, description = "Action to be performed: ADD or REMOVE user to/from groups", required = false, arity = 1)
public String action = "ADD";

@Parameter(names = {"--study-ids"}, description = "The body web service studyIds parameter", required = false, arity = 1)
public String studyIds;

@Parameter(names = {"--group-ids"}, description = "The body web service groupIds parameter", required = false, arity = 1)
public String groupIds;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,8 @@ public class RunGwasCommandOptions {
@Parameter(names = {"--phenotype"}, description = "The body web service phenotype parameter", required = false, arity = 1)
public String phenotype;

@Parameter(names = {"--index"}, description = "The body web service index parameter", required = false, arity = 1)
public Boolean index;
@Parameter(names = {"--index"}, description = "The body web service index parameter", required = false, help = true, arity = 0)
public boolean index = false;

@Parameter(names = {"--index-score-id"}, description = "The body web service indexScoreId parameter", required = false, arity = 1)
public String indexScoreId;
Expand Down
13 changes: 11 additions & 2 deletions opencga-client/src/main/R/R/Admin-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-04-18
# Autogenerated on: 2023-08-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand All @@ -28,14 +28,15 @@
#' | importUsers | /{apiVersion}/admin/users/import | body[*] |
#' | searchUsers | /{apiVersion}/admin/users/search | include, exclude, limit, skip, count, user, account, authenticationId |
#' | syncUsers | /{apiVersion}/admin/users/sync | body[*] |
#' | usersUpdateGroups | /{apiVersion}/admin/users/{user}/groups/update | user[*], action, body[*] |
#'
#' @md
#' @seealso \url{http://docs.opencb.org/display/opencga/Using+OpenCGA} and the RESTful API documentation
#' \url{http://bioinfo.hpc.cam.ac.uk/opencga-prod/webservices/}
#' [*]: Required parameter
#' @export

setMethod("adminClient", "OpencgaR", function(OpencgaR, endpointName, params=NULL, ...) {
setMethod("adminClient", "OpencgaR", function(OpencgaR, user, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/admin/audit/groupBy:
Expand Down Expand Up @@ -100,5 +101,13 @@ setMethod("adminClient", "OpencgaR", function(OpencgaR, endpointName, params=NUL
#' @param data JSON containing the parameters.
syncUsers=fetchOpenCGA(object=OpencgaR, category="admin", categoryId=NULL, subcategory="users",
subcategoryId=NULL, action="sync", params=params, httpMethod="POST", as.queryParam=NULL, ...),

#' @section Endpoint /{apiVersion}/admin/users/{user}/groups/update:
#' Add or remove users from existing groups.
#' @param user User ID.
#' @param action Action to be performed: ADD or REMOVE user to/from groups. Allowed values: ['ADD REMOVE']
#' @param data JSON containing the parameters.
usersUpdateGroups=fetchOpenCGA(object=OpencgaR, category="admin/users", categoryId=user, subcategory="groups",
subcategoryId=NULL, action="update", params=params, httpMethod="POST", as.queryParam=NULL, ...),
)
})
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/Alignment-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-04-18
# Autogenerated on: 2023-08-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
18 changes: 9 additions & 9 deletions opencga-client/src/main/R/R/AllGenerics.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ##############################################################################
## UserClient
setGeneric("userClient", function(OpencgaR, filterId, users, user, endpointName, params=NULL, ...)
setGeneric("userClient", function(OpencgaR, user, filterId, users, endpointName, params=NULL, ...)
standardGeneric("userClient"))

# ##############################################################################
Expand All @@ -10,17 +10,17 @@ setGeneric("projectClient", function(OpencgaR, projects, project, endpointName,

# ##############################################################################
## StudyClient
setGeneric("studyClient", function(OpencgaR, members, templateId, studies, variableSet, group, study, endpointName, params=NULL, ...)
setGeneric("studyClient", function(OpencgaR, members, variableSet, studies, group, study, templateId, endpointName, params=NULL, ...)
standardGeneric("studyClient"))

# ##############################################################################
## FileClient
setGeneric("fileClient", function(OpencgaR, folder, file, members, files, annotationSet, endpointName, params=NULL, ...)
setGeneric("fileClient", function(OpencgaR, files, members, file, annotationSet, folder, endpointName, params=NULL, ...)
standardGeneric("fileClient"))

# ##############################################################################
## JobClient
setGeneric("jobClient", function(OpencgaR, members, jobs, job, endpointName, params=NULL, ...)
setGeneric("jobClient", function(OpencgaR, members, job, jobs, endpointName, params=NULL, ...)
standardGeneric("jobClient"))

# ##############################################################################
Expand All @@ -30,17 +30,17 @@ setGeneric("sampleClient", function(OpencgaR, members, sample, samples, annotati

# ##############################################################################
## IndividualClient
setGeneric("individualClient", function(OpencgaR, members, individual, annotationSet, individuals, endpointName, params=NULL, ...)
setGeneric("individualClient", function(OpencgaR, members, individuals, annotationSet, individual, endpointName, params=NULL, ...)
standardGeneric("individualClient"))

# ##############################################################################
## FamilyClient
setGeneric("familyClient", function(OpencgaR, members, families, family, annotationSet, endpointName, params=NULL, ...)
setGeneric("familyClient", function(OpencgaR, members, family, annotationSet, families, endpointName, params=NULL, ...)
standardGeneric("familyClient"))

# ##############################################################################
## CohortClient
setGeneric("cohortClient", function(OpencgaR, members, cohort, annotationSet, cohorts, endpointName, params=NULL, ...)
setGeneric("cohortClient", function(OpencgaR, members, annotationSet, cohort, cohorts, endpointName, params=NULL, ...)
standardGeneric("cohortClient"))

# ##############################################################################
Expand All @@ -60,7 +60,7 @@ setGeneric("variantClient", function(OpencgaR, endpointName, params=NULL, ...)

# ##############################################################################
## ClinicalClient
setGeneric("clinicalClient", function(OpencgaR, clinicalAnalysis, members, interpretation, clinicalAnalyses, interpretations, endpointName, params=NULL, ...)
setGeneric("clinicalClient", function(OpencgaR, interpretations, members, interpretation, clinicalAnalysis, clinicalAnalyses, endpointName, params=NULL, ...)
standardGeneric("clinicalClient"))

# ##############################################################################
Expand All @@ -80,6 +80,6 @@ setGeneric("ga4ghClient", function(OpencgaR, file, study, endpointName, params=N

# ##############################################################################
## AdminClient
setGeneric("adminClient", function(OpencgaR, endpointName, params=NULL, ...)
setGeneric("adminClient", function(OpencgaR, user, endpointName, params=NULL, ...)
standardGeneric("adminClient"))

4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Clinical-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-04-18
# Autogenerated on: 2023-08-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -58,7 +58,7 @@
#' [*]: Required parameter
#' @export

setMethod("clinicalClient", "OpencgaR", function(OpencgaR, clinicalAnalysis, members, interpretation, clinicalAnalyses, interpretations, endpointName, params=NULL, ...) {
setMethod("clinicalClient", "OpencgaR", function(OpencgaR, interpretations, members, interpretation, clinicalAnalysis, clinicalAnalyses, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/analysis/clinical/acl/{members}/update:
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Cohort-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-04-18
# Autogenerated on: 2023-08-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -39,7 +39,7 @@
#' [*]: Required parameter
#' @export

setMethod("cohortClient", "OpencgaR", function(OpencgaR, members, cohort, annotationSet, cohorts, endpointName, params=NULL, ...) {
setMethod("cohortClient", "OpencgaR", function(OpencgaR, members, annotationSet, cohort, cohorts, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/cohorts/acl/{members}/update:
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Family-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-04-18
# Autogenerated on: 2023-08-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -38,7 +38,7 @@
#' [*]: Required parameter
#' @export

setMethod("familyClient", "OpencgaR", function(OpencgaR, members, families, family, annotationSet, endpointName, params=NULL, ...) {
setMethod("familyClient", "OpencgaR", function(OpencgaR, members, family, annotationSet, families, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/families/acl/{members}/update:
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/File-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-04-18
# Autogenerated on: 2023-08-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -54,7 +54,7 @@
#' [*]: Required parameter
#' @export

setMethod("fileClient", "OpencgaR", function(OpencgaR, folder, file, members, files, annotationSet, endpointName, params=NULL, ...) {
setMethod("fileClient", "OpencgaR", function(OpencgaR, files, members, file, annotationSet, folder, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/files/acl/{members}/update:
Expand Down
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/GA4GH-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-04-18
# Autogenerated on: 2023-08-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Individual-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-04-18
# Autogenerated on: 2023-08-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -39,7 +39,7 @@
#' [*]: Required parameter
#' @export

setMethod("individualClient", "OpencgaR", function(OpencgaR, members, individual, annotationSet, individuals, endpointName, params=NULL, ...) {
setMethod("individualClient", "OpencgaR", function(OpencgaR, members, individuals, annotationSet, individual, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/individuals/acl/{members}/update:
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Job-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-04-18
# Autogenerated on: 2023-08-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -40,7 +40,7 @@
#' [*]: Required parameter
#' @export

setMethod("jobClient", "OpencgaR", function(OpencgaR, members, jobs, job, endpointName, params=NULL, ...) {
setMethod("jobClient", "OpencgaR", function(OpencgaR, members, job, jobs, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/jobs/acl/{members}/update:
Expand Down
Loading
Loading