Mercurial > repos > yating-l > gonramp_apollo_tools
comparison apolloUserManager.xml @ 0:1da8b9042af4 draft
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
| author | yating-l |
|---|---|
| date | Mon, 27 Nov 2017 14:47:03 -0500 |
| parents | |
| children | 78af01d73add |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1da8b9042af4 |
|---|---|
| 1 <tool id="apollo_user_manager" name="Apollo User Manager" version="1.0.0"> | |
| 2 <description> | |
| 3 This Galaxy tool is used to manage Apollo users. | |
| 4 </description> | |
| 5 <macros> | |
| 6 <import>macros.xml</import> | |
| 7 </macros> | |
| 8 | |
| 9 <requirements> | |
| 10 <requirement type="package" version="3.0.3">apollo_api</requirement> | |
| 11 </requirements> | |
| 12 | |
| 13 <stdio> | |
| 14 </stdio> | |
| 15 | |
| 16 <command detect_errors="exit_code"><![CDATA[ | |
| 17 | |
| 18 ## Dump the tool parameters into a JSON file | |
| 19 python $json_file parameters.json; | |
| 20 python $__tool_directory__/apolloUserManager.py --data_json parameters.json -o $output | |
| 21 ]]></command> | |
| 22 <configfiles> | |
| 23 <configfile name="json_file"> | |
| 24 import json | |
| 25 import sys | |
| 26 | |
| 27 file_path = sys.argv[1] | |
| 28 #set global data_parameter_dict = {"operations": dict()} | |
| 29 ## Function to retrieve the data of the inputs | |
| 30 #def prepare_json($operation_type, $data_dict, $batch) | |
| 31 #silent $data_dict.update({"batch": str($batch)}) | |
| 32 #if $operation_type in $data_parameter_dict["operations"] | |
| 33 #silent $data_parameter_dict["operations"][$operation_type].append($data_dict) | |
| 34 #else | |
| 35 #set array_inputs = [] | |
| 36 #silent $array_inputs.append($data_dict) | |
| 37 #silent $data_parameter_dict["operations"].update({$operation_type: $array_inputs}) | |
| 38 #end if | |
| 39 #end def | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 #for $i, $f in enumerate($operation) | |
| 45 #if $f.operation_type_selector.operation_type == "create" | |
| 46 #set batch = $f.operation_type_selector.batch_selector.batch | |
| 47 #if $batch == "false" | |
| 48 #set data_dict = {"useremail": str($f.operation_type_selector.batch_selector.user_email), | |
| 49 "firstname": str($f.operation_type_selector.batch_selector.firstname), | |
| 50 "lastname": str($f.operation_type_selector.batch_selector.lastname), | |
| 51 "password": str($f.operation_type_selector.batch_selector.password)} | |
| 52 | |
| 53 #else | |
| 54 #set data_dict = {"format": str($f.operation_type_selector.batch_selector.format), | |
| 55 "false_path": str($f.operation_type_selector.batch_selector.user_info_file)} | |
| 56 #end if | |
| 57 #silent $prepare_json("create", $data_dict, $batch) | |
| 58 | |
| 59 #elif $f.operation_type_selector.operation_type == "delete" | |
| 60 #set batch = $f.operation_type_selector.batch_selector.batch | |
| 61 #if $batch == "false" | |
| 62 #set data_dict = {"useremail": str($f.operation_type_selector.batch_selector.user_email)} | |
| 63 #else | |
| 64 #set data_dict = {"format": str($f.operation_type_selector.batch_selector.format), | |
| 65 "false_path": str($f.operation_type_selector.batch_selector.user_info_file)} | |
| 66 #end if | |
| 67 #silent $prepare_json("delete", $data_dict, $batch) | |
| 68 #elif $f.operation_type_selector.operation_type == "add" | |
| 69 #set batch = $f.operation_type_selector.batch_selector.batch | |
| 70 #if $batch == "false" | |
| 71 #set data_dict = {"useremail": str($f.operation_type_selector.batch_selector.user_email), | |
| 72 "group": str($f.operation_type_selector.batch_selector.group_name)} | |
| 73 #else | |
| 74 #set data_dict = {"format": str($f.operation_type_selector.batch_selector.format), | |
| 75 "false_path": str($f.operation_type_selector.batch_selector.user_info_file)} | |
| 76 #end if | |
| 77 #silent $prepare_json("add", $data_dict, $batch) | |
| 78 #elif $f.operation_type_selector.operation_type == "remove" | |
| 79 #set batch = $f.operation_type_selector.batch_selector.batch | |
| 80 #if $batch == "false" | |
| 81 #set data_dict = {"useremail": str($f.operation_type_selector.batch_selector.user_email), | |
| 82 "group": str($f.operation_type_selector.batch_selector.group_name)} | |
| 83 #else | |
| 84 #set data_dict = {"format": str($f.operation_type_selector.batch_selector.format), | |
| 85 "false_path": str($f.operation_type_selector.batch_selector.user_info_file)} | |
| 86 #end if | |
| 87 #silent $prepare_json("remove", $data_dict, $batch) | |
| 88 #end if | |
| 89 #end for | |
| 90 | |
| 91 | |
| 92 #set apollo_admin = {"user_email": str($admin_username), "password": str($admin_password)} | |
| 93 #silent $data_parameter_dict.update({"apollo_admin": $apollo_admin}) | |
| 94 #silent $data_parameter_dict.update({"tool_directory": str($__tool_directory__)}) | |
| 95 #silent $data_parameter_dict.update({"port": str($advanced_options.port)}) | |
| 96 #silent $data_parameter_dict.update({"debug_mode": str($advanced_options.debug_mode)}) | |
| 97 with open(file_path, 'w') as f: | |
| 98 json.dump($data_parameter_dict, f) | |
| 99 </configfile> | |
| 100 </configfiles> | |
| 101 | |
| 102 | |
| 103 <inputs> | |
| 104 <param name="admin_username" type="text" label="Admin username" help="Login in with Apollo admin account"> | |
| 105 <sanitizer> | |
| 106 <valid initial="string.letters,string.digits"> | |
| 107 <add value="@-=_.()/+*^,:?!"/> | |
| 108 </valid> | |
| 109 </sanitizer> | |
| 110 </param> | |
| 111 | |
| 112 <param | |
| 113 name="admin_password" | |
| 114 type="text" | |
| 115 label="Admin password" | |
| 116 /> | |
| 117 | |
| 118 <repeat name="operation" title="New operation"> | |
| 119 <conditional name="operation_type_selector" > | |
| 120 <param name="operation_type" type="select" label="Create a user, delete a user, add a user to a group or remove a user from a group"> | |
| 121 <option value="create">Create a user</option> | |
| 122 <option value="delete">Delete a users</option> | |
| 123 <option value="add">Add a user to a group</option> | |
| 124 <option value="remove">Remove a user from a group</option> | |
| 125 </param> | |
| 126 <when value="create"> | |
| 127 <conditional name="batch_selector"> | |
| 128 <param name="batch" type="select" label="Manipulate a single user or multiple users"> | |
| 129 <option value="false" selected="true">Single user</option> | |
| 130 <option value="true">Multiple users</option> | |
| 131 </param> | |
| 132 <when value="false"> | |
| 133 <param name="user_email" type="text" label="User email" help="Specify the user email"> | |
| 134 <sanitizer> | |
| 135 <valid initial="string.letters,string.digits"> | |
| 136 <add value="@-=_.()/+*^,:?!"/> | |
| 137 </valid> | |
| 138 </sanitizer> | |
| 139 </param> | |
| 140 <param name="firstname" type="text" label="First name" /> | |
| 141 <param name="lastname" type="text" label="Last name" /> | |
| 142 <param name="password" type="text" label="Password" /> | |
| 143 </when> | |
| 144 <when value="true"> | |
| 145 <expand macro="upload_text_file" /> | |
| 146 </when> | |
| 147 </conditional> | |
| 148 </when> | |
| 149 <when value="delete"> | |
| 150 <conditional name="batch_selector"> | |
| 151 <param name="batch" type="select" label="Manipulate a single user or multiple users"> | |
| 152 <option value="false" selected="true">Single user</option> | |
| 153 <option value="true">Multiple users</option> | |
| 154 </param> | |
| 155 <when value="false"> | |
| 156 <param name="user_email" type="text" label="User email" help="Specify the user email"> | |
| 157 <sanitizer> | |
| 158 <valid initial="string.letters,string.digits"> | |
| 159 <add value="@-=_.()/+*^,:?!"/> | |
| 160 </valid> | |
| 161 </sanitizer> | |
| 162 </param> | |
| 163 </when> | |
| 164 <when value="true"> | |
| 165 <expand macro="upload_text_file" /> | |
| 166 </when> | |
| 167 </conditional> | |
| 168 </when> | |
| 169 <when value="add"> | |
| 170 <conditional name="batch_selector"> | |
| 171 <param name="batch" type="select" label="Manipulate a single user or multiple users"> | |
| 172 <option value="false" selected="true">Single user</option> | |
| 173 <option value="true">Multiple users</option> | |
| 174 </param> | |
| 175 <when value="false"> | |
| 176 <param name="user_email" type="text" label="User email" help="Specify the user email"> | |
| 177 <sanitizer> | |
| 178 <valid initial="string.letters,string.digits"> | |
| 179 <add value="@-=_.()/+*^,:?!"/> | |
| 180 </valid> | |
| 181 </sanitizer> | |
| 182 </param> | |
| 183 <param type="text" name="group_name" size="30" value="unknown" label="Group name" /> | |
| 184 </when> | |
| 185 <when value="true"> | |
| 186 <expand macro="upload_text_file" /> | |
| 187 </when> | |
| 188 </conditional> | |
| 189 </when> | |
| 190 <when value="remove"> | |
| 191 <conditional name="batch_selector"> | |
| 192 <param name="batch" type="select" label="Manipulate a single user or multiple users"> | |
| 193 <option value="false" selected="true">Single user</option> | |
| 194 <option value="true">Multiple users</option> | |
| 195 </param> | |
| 196 <when value="false"> | |
| 197 <param name="user_email" type="text" label="User email" help="Specify the user email"> | |
| 198 <sanitizer> | |
| 199 <valid initial="string.letters,string.digits"> | |
| 200 <add value="@-=_.()/+*^,:?!"/> | |
| 201 </valid> | |
| 202 </sanitizer> | |
| 203 </param> | |
| 204 <param type="text" name="group_name" size="30" value="unknown" label="Group name" /> | |
| 205 </when> | |
| 206 <when value="true"> | |
| 207 <expand macro="upload_text_file" /> | |
| 208 </when> | |
| 209 </conditional> | |
| 210 </when> | |
| 211 </conditional> | |
| 212 </repeat> | |
| 213 | |
| 214 <conditional name="advanced_options"> | |
| 215 <param name="advanced_options_selector" type="select" label="Advanced options"> | |
| 216 <option value="off" selected="true">Hide advanced options</option> | |
| 217 <option value="on">Display advanced options</option> | |
| 218 </param> | |
| 219 <!-- TODO: Avoid redundancy here --> | |
| 220 <when value="on"> | |
| 221 <param name="port" type="integer" min="8000" max="8888" value="8080" label="Port number of Apollo" /> | |
| 222 <param name="debug_mode" type="select" label="Activate debug mode"> | |
| 223 <option value="false" selected="true">No</option> | |
| 224 <option value="true">Yes</option> | |
| 225 <help> | |
| 226 Use this option if you are a G-OnRamp developer | |
| 227 </help> | |
| 228 </param> | |
| 229 </when> | |
| 230 <when value="off"> | |
| 231 <param name="port" type="hidden" value="8080" /> | |
| 232 <param name="debug_mode" type="hidden" | |
| 233 value="false"> | |
| 234 </param> | |
| 235 </when> | |
| 236 </conditional> | |
| 237 </inputs> | |
| 238 <outputs> | |
| 239 <data format="html" name="output" label="${tool.name}" /> | |
| 240 </outputs> | |
| 241 | |
| 242 <help> | |
| 243 This Galaxy tool is used to manage Apollo users.The currently supported operation including: | |
| 244 | |
| 245 - Create a new user | |
| 246 - Delete a user | |
| 247 - Add a user to a group (If the group doesn't exist, create the group) | |
| 248 - Remove a user to a group | |
| 249 | |
| 250 The tool can do these operations on one student at a time. It can also do the operations on multiple students at a time by uploading a text file, which including students information. | |
| 251 | |
| 252 The text file can be either CSV (comma-delimited) or Tabular (tab-delimited). It should have a header line, including names for each column. Example text files: | |
| 253 | |
| 254 Text file for creating multiple users: | |
| 255 | |
| 256 .. csv-table:: | |
| 257 :header: "useremail", "firstname", "lastname", "password" | |
| 258 :widths: 20, 10, 10, 10 | |
| 259 | |
| 260 "test1@demo.com", "test1", "demo", "1234" | |
| 261 "test2@demo.com", "test2", "demo", "1234" | |
| 262 "test3@demo.com", "test3", "demo", "1234" | |
| 263 | |
| 264 | |
| 265 Text file for deleting multiple users: | |
| 266 | |
| 267 .. csv-table:: | |
| 268 :header: "useremail" | |
| 269 :widths: 20 | |
| 270 | |
| 271 "test1@demo.com" | |
| 272 "test2@demo.com" | |
| 273 "test3@demo.com" | |
| 274 | |
| 275 | |
| 276 Text file for adding / removing multiple users from a group: | |
| 277 | |
| 278 .. csv-table:: | |
| 279 :header: "useremail", "group" | |
| 280 :widths: 20, 20 | |
| 281 | |
| 282 "test1@demo.com", "annotation_group1" | |
| 283 "test2@demo.com", "annotation_group1" | |
| 284 "test3@demo.com", "annotation_group1" | |
| 285 | |
| 286 </help> | |
| 287 <citations> | |
| 288 </citations> | |
| 289 </tool> |
