Thursday, June 25, 2015

Key Property Store(KPS) in Oracle API Gateway

The views expressed on this blog post are my own and do not necessarily reflect the views of Oracle

The Key Property Store(KPS) in Oracle API Gateway is an amazing tool. The KPS allows the policy administrator to configure a table in a data store. This table can later be populated by a KPS administrator in the Web UI of Oracle API Gateway. This allows you to store arbitrary configuration data in OAG and, because it can be edited from the Web GUI, enables you to edit this data in runtime without deploying new policies.

In this post I will show a simple example of how to create and edit the a KPS table. I will also show how to access the data stored in the table. This example is based on version 11.1.2.3.0 of OAG.

Create a table

A KPS table is created using the OAG Policy Manager. A table is contained in a KPS collection, that is a collection of tables. Add a new collection by right-clicking the Key Property Store node in the gateway tree to the left and selecting Add KPS Collection




Type a name for your collection. A alias prefix can be be defined. If a prefix like below is used , the tables will be accessible using a prefixed name. A table named users in this collection would be accessed using the name my_tables_users. It is not a requirement to use an alias prefix but it can be useful to avoid conflict with other collections. The data source is the way the collection and tables are stored. The default is the embedded Cassandra database of OAG, but a SQL database or a file could also be used for storage.




To add a table in the collection right-click the collection under the Key Property Store node and select Add Table.




Add a name and aliases that is used to access the table. At least one alias must be added.




The table is now created. Next is to create the columns. Click the table in the gateway tree and select the tab Structure. Click the add button to add a column. One column must be defined as primary key.






Insert and edit data in table

The admin GUI for OAG is used to administer the data contained in the table. To access the data, browse to the admin GUI, eg. https://localhost:9080. Login with a user with the KPS Administrator role, eg. the default admin user.

The KPS GUI is located under the settings tab and then the Key Property Store tab. Once you selected you table you can add and edit data in the table.


Accessing data in KPS

The KPS tables can be accessed using selector expressions i OAG. The selector expression should start with kps and then the alias for the table, including any collection prefix alias. In the case of my example tables this would be used to lookup the age of the user with username Stefan.

${kps.my_tables_users['Stefan'].age}

The same is accomplished using this expression

${kps.my_tables_users.Stefan.age}

The expressions can be tested using a trace filter and will result in the string 28.

2 comments:

  1. Hey Stefan, I was breaking my head over reading table data using selector string. With your trick I was able to do that.Thanks a lot :)

    ReplyDelete