In the first tutorial of this series, we demonstrated querying data from a single endpoint using the Autonomous REST Connector; however, REST services are typically comprised of multiple endpoints that return data. To configure the Autonomous REST Connector to connect to multiple endpoints, you must define your endpoints using a Model file. This tutorial will guide you through creating a model file with the included Autonomous REST Composer tool, connecting to your endpoints, and querying your data.
To generate your Model file:
java -jar autorest.jar --design
By default, the autorest.jar
file is stored in the following directory: C:\Program Files\Progress\DataDirect\JDBC\lib\60
.
Complete the following fields to create a new project; then, click OK:
Note: The Base URL field is optional. You can also specify the base URL in the Host Name field on the Connection tab. Specifying a value in either location pre-populates the base URL in the Endpoints field(s) of the Configure Endpoints tab.
Provide the minimum required information for an endpoint to which you want to issue requests:
https://api.yelp.com/v3/categories
categories
Request Type | Endpoint | TableName |
---|---|---|
GET | https://api.yelp.com/v3/events | events |
GET | https://api.yelp.com/v3/businesses/search?location=27617 | business |
businesses/search
) endpoint, I provided a default zip code value of 27617
for the location. This is because the endpoint requires query parameter in the form of a location to make sure that the connector can sample it and create a table with the correct metadata.
After creating your Model file, you are ready to configure and connect. You can edit your Model file later by selecting Import a Model on the welcome screen of the Autonomous REST Composer.
In an earlier section, we sampled a single endpoint by setting the Sample property to a single Yelp endpoint. The Sample property allows you to only sample one endpoint at a time, but, if you want to sample multiple endpoints, you need to set the Config property to specify the file path to the Model file that you have just created.
jdbc:datadirect:autorest:config=C:\
BearerToken
SELECT * FROM CATEGORIES WHERE alias LIKE '%food%'
SELECT C.ALIAS, C.TITLE, PA.PARENT_ALIASE, PA.POSITION FROM CATEGORIES C INNER JOIN PARENT_ALIASES PA ON PA.CATEGORIES_ALIAS = C.ALIAS
SELECT C.ALIAS, C.TITLE, CB.COUNTRY_BLACKLIST, CB."POSITION" FROM CATEGORIES C INNER JOIN COUNTRY_BLACKLIST CB ON CB.CATEGORIES_ALIAS = C.ALIAS
SELECT C.ALIAS, C.TITLE, CW.COUNTRY_WHITELIST, CW."POSITION" FROM CATEGORIES C INNER JOIN COUNTRY_WHITELIST CW ON CW.CATEGORIES_ALIAS = C.ALIAS
SELECT * FROM EVENTS
SELECT * FROM BUSINESS WHERE LOCATION='10001'
SELECT * FROM BUSINESS WHERE LOCATION='94016'
SELECT * FROM BUSINESSES B INNER JOIN CATEGORIES_1 C ON B."POSITION" = C.BUSINESSES_POSITION WHERE B.LOCATION='10001' AND C.LOCATION='10001'
SELECT * FROM BUSINESSES B INNER JOIN CATEGORIES_1 C ON B."POSITION" = C.BUSINESSES_POSITION WHERE B.LOCATION='10001' AND C.LOCATION='10001' AND c.ALIAS LIKE '%brunch%'
You have successfully connected to and queried multiple endpoints. Optionally, you can add additional endpoints to your Model file by repeating this process. Note that the tables mapped from new endpoints can only be queried after you reconnect using an updated model file.
In the next section, we will guide you through editing the auto-generated schema to change table names, primary keys, and more. If you have any questions or issues, feel free to contact us.
The Autonomous REST Connector provides JDBC and ODBC connectivity to Yelp, GitHub, JIra, and many other REST APIs.