Monday, January 8, 2024

#1003 - OIC - Create your own adapter with the Rapid Adapter Builder

In a recent post,  I discussed invoking RabbitMQ from OIC using the REST adapter. OIC doesn't have a dedicated RabbitMQ adapter, but RabbitMQ does have a rich REST api, hence my usage of that adapter.

A very BIG thank you to my colleague Madhav P. here.

So taking this example, let's use the OIC Rapid Adapter Toolkit to create a RabbitMQ adapter. This toolkit allows you to bundle REST api requests as a custom adapter, which can be then published to your OIC instance.


The input is a postman collection of the api calls I want to bundle with the adapter. The magic happens in VS Code. The result is a new adapter in my OIC adapter list.

Let's go through this step by step - 

Prepare Postman Collection

I set the authentication at Collection level - 


Note, I have executed the 2 calls and saved the results, by clicking Save as example.


Then export the collection - 













VS Code setup

Download VS Code, the version should be at least 1.8.x.

The Rapid Adapter Builder (RAB) extension will be available on the VS Code marketplace going forward - 
 

You download the extension and then import it into VS Code.

Creating your adapter project

Create a new folder on your file system and navigate to it in VS Code - 
Then click View --> Command Palette. Enter RAB: Initialize Workspace




Check out the directory structure - 























Essentially we're going to do the following - 

Import our Postman collection to the /api directory.
We will use this to generate an adapter definition file which will be stored in the /definitions directory. publisher.yaml contains details of my OIC instance and the security credentials to connect to it. This information will be used when publishing the adapter to OIC.

Import the postman collection  

You can export again from Postman and save directly to the /api directory.




Edit publisher.yaml

As you can see, you will require the following - 

  • active - name of active profile
  • profiles - 
  • name - profile name - identifies the OIC instance
  • publisher id - yourOwnId - I chose ncommisk
  • host - the OIC host
  • integration instance - OIC instance name
  • auth -
  • tokenUrl - IDCS token url
  • clientId - from IDCS app
  • clientSecret - from IDCS app
  • scope - from IDCS app
So the idea is I can have multiple Profiles, identifying multiple OIC instances, and then decide for each Publish run, which is active, i.e. publish the new adapter to test and then to prod.
  

So you may need to create an IDCS app to get the client id and secret. 

Note: only Client Credentials is required.

Add the scopes for your OIC instance.
Activate and note client id and secret.


Next step is to assign an OIC role to this app. This you do via the Oracle Cloud Service app, auto-crated for your OIC instance - 


Update publisher.yaml - 









Create the adapter definition file

Here we click RAB: Convert Document.








 


 


The following file is generated - 



















You will need to edit some of these values, at least the displayName, as this is what will appear in your OIC adapter list.


Also note the version value, this needs to be incremented when you are updating an adapter definition.


 Validate the adapter definition

Click RAB: Validate




Final step is to publish - 



Check out the new adapter in OIC



Note the default logo used. this is taken from the /resources directory - 

So, net, net, I can add my own logo, if required.

I create a new Connection - 


Note the only security available is basic auth - 

I could have edited the adapter definition file to specify more - 


I enter my credentials and test the connection - 


Now to a simple scheduled integration which will use this connection - 


Note, the 2 operations, GetMessage and PutMessage, are displayed. I select the former.


I just need to edit the Map and then I'm ready to go.
I set ala Postman payload.



I add a Log Action to log the payload -


I run and validate the result - 







No comments: