URI¶
CWL example¶
cwlVersion: v1.2
class: CommandLineTool
label: "Echo URI string format"
baseCommand: echo
requirements:
- class: InlineJavascriptRequirement
- class: SchemaDefRequirement
types:
- $import: https://raw.githubusercontent.com/eoap/schemas/main/string_format.yaml
inputs:
product_uri:
type: https://raw.githubusercontent.com/eoap/schemas/main/string_format.yaml#URI
label: "Product URI"
doc: "Product URI in string format"
inputBinding:
valueFrom: |
${
// parse the URI provided in the input
var product_uri = inputs.product_uri.value;
// Validate the URI format
var uriPattern = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i;
if (!uriPattern.test(product_uri)) {
throw "Invalid URI format: " + product_uri;
}
// Return the URI as a string
return "Product URI: " + product_uri;
}
outputs:
echo_output:
type: stdout
stdout: echo_output.txt
Input example¶
product_uri:
class: https://raw.githubusercontent.com/eoap/schemas/main/ogc.yaml#URI
value: "https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2A_10TFK_20210708_0_L2A"
Execute the example¶
Run the example with:
cwltool examples/string-format/uri.cwl examples/string-format/uri.yaml
This produces the output:
INFO /opt/hostedtoolcache/Python/3.13.5/x64/bin/cwltool 3.1.20250110105449
INFO Resolved '../examples/string-format/uri.cwl' to 'file:///home/runner/work/schemas/schemas/examples/string-format/uri.cwl'
INFO [job uri.cwl] /tmp/6so9r2yt$ echo \
'Product URI: https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2A_10TFK_20210708_0_L2A' > /tmp/6so9r2yt/echo_output.txt
INFO [job uri.cwl] completed success
INFO Final process status is success
The content of the echo_output.txt
file is:
Product URI: https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2A_10TFK_20210708_0_L2A