From aa8798808b057633094e0d1b036ed5ec8d951959 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 13 Feb 2024 12:27:27 +0100 Subject: [PATCH] Add documentation for from_url options --- lib/galaxy/tool_util/xsd/galaxy.xsd | 58 ++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/tool_util/xsd/galaxy.xsd b/lib/galaxy/tool_util/xsd/galaxy.xsd index 6ad79a7549a2..f0dee803bb84 100644 --- a/lib/galaxy/tool_util/xsd/galaxy.xsd +++ b/lib/galaxy/tool_util/xsd/galaxy.xsd @@ -4361,6 +4361,62 @@ example below demonstrates (many more examples are present in the ``` +### ``from_url`` + +The following example demonstrates getting options from a third-party server +with server side requests. + +``` + + + + +``` + +Here a GET request is made to https://usegalaxy.org/api/genomes, which returns +an array of arrays, such as + +```json +[ + ["unspecified (?)", "?"], + ["A. ceylanicum Mar. 2014 (WS243/Acey_2013.11.30.genDNA/ancCey1) (ancCey1)", "ancCey1"], + ... +] +``` +Each inner array is a user-selectable option, where the first item in the inner array +is the `name` of the option (as shown in the select field in the user interface), and +the second option is the `value` that is passed on to the tool. An optional third +element can be added to the inner array which corresponds to the `selected` state. +If the third item is `true` then this particular option is pre-selected. + +A more complicated example is shown below, where a POST request is made with a templated +request header and body. The upstream response is then also transformed using an ecma 5.1 +expression: + +```xml + + + + + {"x-api-key": "${__user__.extra_preferences.fake_api_key if $__user__ else "anon"}"} + + + {"name": "value"} + + + [header, header]) + }]]]]> + + +``` + +The header and body templating mechanism can be used to access protected resources, +and the `postprocess_expression` can be used to transform arbitrary JSON responses +to arrays of `name` and `value`, or arrays of `name`, `value` and `selected`. + +For an example tool see [select_from_url.xml](https://github.com/galaxyproject/galaxy/tree/dev/test/functional/tools/select_from_url.xml). + ### ``from_file`` The following example is for Blast databases. In this example users maybe select @@ -4425,7 +4481,7 @@ used to generate dynamic options. - Set the request method to use for options provided using from_url. + Set the request method to use for options provided using 'from_url'.