Version 4

    Micro Service based design strategy become the trends, which cause Rest Service became more and more important, Rest Service play a role as fundamental connective media between Micro Service and Micro Service. Teiid expose Rest Service on VDB which provide possibility to extract data from VDB and catch up the latest trends. In this article, we first give an example for exposing Rest Service through VDB, then talk the details of the usage of Rest Service API Doc Page.

    Example

    As Teiid Document REST Service Through VDB, this example demonstrates how to expose Rest Service with the following steps.

    Build Teiid Server From Source Code

    Start from Teiid Version 8.12.0.Beta2, a Rest Service API Doc Page be added, for demonstrating API Doc Page we build Teiid Server from latest souce code. With JDK 1.7, Maven 3 and Git Client installed, execute the following commands:

    $ git clone https://github.com/teiid/teiid.git

    $ cd teiid

    $ mvn clean install -P release -s settings.xml

    you can find teiid-8.12.0.Beta2-SNAPSHOT-server.zip in the "teiid/build/target" directory once the build is completed.

    Install and start Teiid Server

    teiid-standalone-mode-install.cli under "JBOSS_HOME/bin/scripts" critical for install Teiid Server, use the following commands to install and start Teiid Server:

    $ unzip build/target/teiid-8.12.0.Beta2-SNAPSHOT-server.zip

    $ cd teiid-8.12.0.Beta2-SNAPSHOT/

    $ ./bin/standalone.sh

    $ ./bin/jboss-cli.sh --connect --file=bin/scripts/teiid-standalone-mode-install.cli

    Restart Teiid Server is necessary to make sure installation take effect.

    Setup dynamicvdb-restservice quick start

    With the steps in dynamicvdb-restservice, execute the following commands:

    $ cd teiid-8.12.0.Beta2-SNAPSHOT/

    $ cp -r {path}/dynamicvdb-datafederation/src/teiidfiles/ ./

    $ ./bin/jboss-cli.sh --connect --file={path}/dynamicvdb-datafederation/src/scripts/setup.cli

    $ cp {path}/dynamicvdb-datafederation/src/vdb/portfolio-vdb.xml* teiid-8.12.0.Beta2-SNAPSHOT/standalone/deployments

    $ ./bin/add-user.sh -a -u testUser -p password1! -g rest

    $ cp {path}/dynamicvdb-restservice/src/vdb/portfolio-rest-vdb.xml* teiid-8.12.0.Beta2-SNAPSHOT/standalone/deployments

    Note that createApplication User under "rest" role and restart Teiid Server is necessary.

    Test Rest API

    The rest api path pattern like

    /{vdbName_vdbVersion}/{modelName}/{procedureName}/{path}
    
    
    

    For example, using a web browser test the following api:

    Screenshot-rest-1.png

    Screenshot-rest-2.png

    Screenshot-rest-3.png

    Screenshot-rest-4.png

    API Doc Page

    Teiid Rest Service API Doc Page are available under

    /{vdbName_vdbVersion}/api

    In the following section we will continue use above example to demonstrate Rest API page.

    Access API Doc Page

    Screenshot-rest-5.png

    Overview of API Doc Page

    Once you access API Doc page link(http://localhost:8080/PortfolioRest_1/api), the API Doc Page will pop up:

    Screenshot-rest-6.png

    As above picture, all api which used to extract data from VDB listed in the page.

    Test API in API Doc Page

    Click Get/POST button in API Doc page, a scroll down page will pop up:

    Screenshot-rest-7.png

    Enter a id, click "Try it out" Button will test the Rest API.

    Screenshot-rest-8.png