Like what you see? Have a play with our trial version.

Error rendering macro 'rw-search'

null

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following extract from a YFExport.xml file shows in red where tokens could be replaced by an automated process for generating a datasource for use with client source substitution.

...

languagexml
<source>

   <id>132641</id>

   <sourceName>PostgreSQL Connection for [TENANT_NAME]</sourceName>

   <sourceDescription>PostgreSQL Connection for [TENANT_NAME]</sourceDescription>

   <databasePath>public</databasePath>

   <userName>[USERNAME]</userName>

   <password>[ENCRYPTED_PASSWORD]</password>

   <connectionTypeCode>GENERICUSER</connectionTypeCode>

   <connectionMethodCode>JDBC</connectionMethodCode>

   <connectionDriver>org.postgresql.Driver</connectionDriver>

   <databaseURL>jdbc:postgresql://[SERVER_ADDRESS]:5432/[DATABASE_NAME]></databaseURL>

   <databaseTypeCode>POSTGRESQL</databaseTypeCode>

   <minConnections>1</minConnections>

   <maxConnections>5</maxConnections>

   <connectionRefreshTime>180</connectionRefreshTime>

   <connectionTimeOut>180</connectionTimeOut>

   <accessCode>UNSECURE</accessCode>

   <maxRowCount>10000</maxRowCount>

   <maxAnalysisRowCount>0</maxAnalysisRowCount>

   <broadcastPermitted>true</broadcastPermitted>

   <subscribePermitted>true</subscribePermitted>

   <dataProfileEnabled>true</dataProfileEnabled>

   <localTimezoneCode>AUSTRALIA/LORD_HOWE</localTimezoneCode>

   <secondaryMinConnections>0</secondaryMinConnections>

   <secondaryMaxConnections>0</secondaryMaxConnections>

   <secondaryConnectionRefreshTime>0</secondaryConnectionRefreshTime>

   <secondaryConnectionTimeOut>0</secondaryConnectionTimeOut>

   <lastModifiedGMTDateTime>20240607025556.000000</lastModifiedGMTDateTime>

   <sourceUUID>7d7543c0-e9c7-4a80-ab14-73181e4d0694</sourceUUID>

   <filterList/>

   <sourceParameterList>

     <sourceParameter>

       <id>0</id>

       <parameterTypeCode>TEXT</parameterTypeCode>

       <parameterKey>DATABASE</parameterKey>

       <parameterIndex>0</parameterIndex>

       <parameterValue>[DATABASE_NAME]</parameterValue>

       <documentId>0</documentId>

       <userVisible>true</userVisible>

     </sourceParameter>

     <sourceParameter>

       <id>0</id>

       <parameterTypeCode>TEXT</parameterTypeCode>

       <parameterKey>HOSTNAME</parameterKey>

       <parameterIndex>0</parameterIndex>

       <parameterValue>[SERVER_ADDRESS]</parameterValue>

       <documentId>0</documentId>

       <userVisible>true</userVisible>

     </sourceParameter>


Once an export file has been automatically injected with tokens, it can be uploaded via the REST API using the POST /api/rpc/import-export/import-content end-point (https://developers.yellowfinbi.com/dev/api-docs/current/#operation/importContent ).

This particular endpoint uses a form based submission paradigm. Two form bodies are required - one named “contentToProcess” with the YFX/XML file contents and another named “importOptions”, which contains the rules on how the import is processed. For this example, assuming the XML file contains a single datasource, this importOptions payload can be used:

Code Block
[

...


  { "itemIndex": 0, "optionKey": "SKIP", "optionValue": false },

...


  { "itemIndex": 0, "optionKey": "OPTION\", "optionValue": "ADD" }

...


]

The following code examples take a pre-exported database XML template and inject replacement values for the database host, database name, database user and password into the file. It is then imported into a Tenant (specified by the Client Reference Id).

Java | C# | Go | JavaScript | PHP | Python

Code Block
languagejava
titleJava
collapsetrue
Code Block
languagec#
titleC#
collapsetrue
Code Block
titleGo
collapsetrue
Code Block
languagejs
titleJavaScript
collapsetrue
Code Block
languagephp
titlePHP
collapsetrue
Code Block
languagepy
titlePython
collapsetrue

Create a new datasource via the datasource service

A datasource can be created directly via the REST API using the POST /api/data-sources (https://developers.yellowfinbi.com/dev/api-docs/current/#operation/createDataSource ) sources end-point, Create Data Source.

This takes a datasource model of this format:

Code Block
{

...



   "sourceName": "Client Database",

...



   "sourceDescription": "",

...



   "sourceType": "POSTGRESQL",

...



   "connectionType": "JDBC",

...



   "connectionTypeCode": "GENERICUSER",

...



   "connectionDriver": "org.postgresql.Driver",

...



   "connectionString": "jdbc:postgresql://192.168.1.100:5432/testdata",

...



   "connectionTimeout": 180,

...



   "userName": "postgres",

...



   "minimumConnections": 1,

...



   "maximumConnections": 5,

...



   "refreshTime": 180,

...



   "timezone": "AUSTRALIA/SYDNEY",

...



   "accessLevelCode": "UNSECURE",

...



   "maxRows": 10000,

...



   "maxAnalysisRows": 0,

...



   "inheritChildSourceFilters": false,

...



   "sourceLogIndicator": false,

...



   "sourceOptions": [

...



{

...



"optionKey": "ISOLATIONLEVEL",

...



"optionValue": "1.0",

...



"valueDataType": "1"

...



},

...



{

...



"optionKey": "USESCHEMA",

...



"optionValue": "true",

...



"valueDataType": "6"

...



},

...



{

...



"optionKey": "HOSTNAME",

...



"optionValue": "192.168.1.100",

...



"valueDataType": "2"

...



},

...



{

...



"optionKey": "PORT",

...



"optionValue": "5432",

...



"valueDataType": "1"

...



},

...



{

...



"optionKey": "DATABASE",

...



"optionValue": "testdata",

...



"valueDataType": "2"

...



},

...



{

...



"optionKey": "YF_DRIVER_SELECTION",

...



"optionValue": "org.postgresql.Driver",

...



"valueDataType": "2"

...



}

...



    ]

...



}

The main body of the model is similar to the model returned by the GET /api/data-sources end-point. If creating a new source similar to the Primary Organization datasource, the data returned by GET /api/data-sources can be used as a template.

...

The following examples illustrate how to create a new datasource via the POST /api/data-sources end-point:

Code Block

...

languagejava
titleJava
collapsetrue
Code Block
languagec#
titleC#
collapsetrue
Code Block
titleGo
collapsetrue
Code Block
languagejs
titleJavaScript
collapsetrue
Code Block
languagephp
titlePHP
collapsetrue
Code Block
languagepy
titlePython
collapsetrue

List Data Sources

A list of datasources can be retrieved with the GET /api/data-sources end-point (https://developers.yellowfinbi.com/dev/api-docs/current/#operation/getAllDataSources ). This will return a datasource model of the following form:

...