WhereScape RED provides a command line interface called WslMetadataService.exe that allows users to startup a REST based WhereScape Metadata Service.  This is the is the underlying REST service which feeds the WhereScape RED Template Engine whenever a template operation is performed. The tool is available in the RED Windows installation directory.

Endpoints

The REST service has the following endpoints:

  • jobsById
  • jobsByName
  • jobsExportByName
  • changedJobs
  • tasksById
  • objectIds
  • objectsById
  • objectsByName
  • objectsExportByName
  • sourcemappingsById
  • viewaliasesById
  • targetsById
  • metadataConnection
  • types
  • options
  • usersById


Command Arguments

Options for connecting to the metadata server:

Command

Description

Metadata connection options
--meta-dsnSet metadata DSN
--meta-dsn-archThe architecture of the ODBC DSN. Valid values are 32 and 64. Defaults to 32 if not specified.
--meta-con-stringSset metadata Connection String (if specified, username, password, dsn can be optional)
--red-profileSet Red Profile path
--meta-userSet metadata login username (use OS authentication if omitted)
--meta-passwordSet metadata login password (use OS authentication if omitted)
--meta-schemaSet metadata schema (including trailing dot)
--meta-databaseSet metadata database
 --meta-db-type

Set to '14' for PostgreSQL

--ws-userSet metadata user name
HTTP options
--insecureAllow connections without authorization
--listen-portPort number to listen on (defaults to first unused from 8080)
General options
--helpProduce help message and exit
--versionReport version information and exit
--log-levelSet log level (0 is very quiet, 9 is very noisy)


Example script to invoke and query the service 

If you add this script as a RED Host Script of type PowerShell (64-bit) to RED, then execute it from RED it will start the metadata service in a separate PowerShell window, one this windows is launched you can then start a cmd window and query the service with curl, as described in the script itself.

The following example script mentions curl examples with port 8080, however you will need to view the opened Metadata Service PowerShell window to see the actual port the service is listening on and use that when querying it.

$ENV:RED_META_DSN=$ENV:WSL_META_DSN
$ENV:RED_META_USER=$ENV:WSL_META_USER
$ENV:RED_META_PWD=$ENV:WSL_META_PWD
$ENV:RED_META_SCHEMA=$ENV:WSL_META_SCHEMA
$ENV:RED_META_DSN_ARCH=$ENV:WSL_META_DSN_ARCH
$ENV:RED_META_CON_STRING=$ENV:WSL_META_CONSTRING

$strCmds = @"
& cmd /k WslMetadataService.exe  --insecure --meta-dsn "WSENV~RED_META_DSN~" --meta-user "WSENV~RED_META_USER~" --meta-password "WSENV~RED_META_PWD~" --meta-schema "WSENV~RED_META_SCHEMA~" --meta-db-type 14 --ws-user "REST_API" --log-level 9 --meta-dsn-arch WSENV~RED_META_DSN_ARCH~ --meta-con-string "WSENV~RED_META_CON_STRING~"
"@

start-process powershell -ArgumentList "-noexit -command & Invoke-Command -ScriptBlock {$strCmds}"

Write-Output "1"
Write-Output "WslMetadataService started in separate window"
Write-Output "Use curl from a command window to get json data back from the service."
Write-Output "Examples (replace the 8080 port with the port returned by your service):"
Write-Output "curl http://localhost:8080/objectsById -o c:\temp\out_ALL_OBJECTS.json"
Write-Output "curl http://localhost:8080/objectsByName/load_customer -o c:\temp\out_LOAD_CUSTOMER.json"
Write-Output "curl http://localhost:8080/types -o c:\temp\out_types.json"





  • No labels