Tuesday, March 15, 2022

How to access OCI Object Storage Objetcs in OIC Integrations

OCI Object storage is high-performance storage platform that offers reliable and cost-efficient data   durability. The Object Storage service can store an unlimited amount of unstructured data of any content type.

There are different steps that need to be performed before using the Object storage in OIC integrations. 

1). Create an Object Storage Bucket

       Login to OCI console->Menu->Storage->Buckets

      Follow the below screenshots for reference:

 

 

 

Now select the Compartment:


 

Click on Create Bucket:


 

Enter the Bucket Name, leave others as default and click Create:

 


 

The Bucket will get created: 


        Bucket

        A logical container for storing objects

        Namespace

        A logical entity that serves as a top-level container for all buckets and objects, allowing you to control bucket naming within your tenancy. Each Oracle Cloud Infrastructure tenant is assigned one unique and uneditable Object Storage namespace that spans all compartments within a region

        Object

               Any type of data, regardless of content type, is stored as an object. The object is composed of the object itself and metadata about the object. Each object is stored in a bucket.

 

2). Ways of accessing object store bucket objetcs

      There are multiple ways we can access the objects in OIC integrations

  • Using Rest Service - Older way of doing available from Gen1
  • Using native connection  - New addition after Gen2 Upgrade

 

Using Rest Service 

This was is the older way of accessing objects used in Gen1.

We can access the OCI bucket object by creating rest connection with security policy as basic authentication: Use Auth Token instead of password

 

 

 

The connection URL will be of below format:

https://swiftobjectstorage.us-ashburn-1.oraclecloud.com/v1/{your namespace} 

eg.  https://swiftobjectstorage.us-ashburn-1.oraclecloud.com/v1/xyzcompany

Now let us see how we can use this connection in our integration to get an object from OCI bucket:

 

 Configure the rest adapter in integrations as below:

 

 

 

 

 Now in the mapper map the "RelativeURI" with the URI of object in OCI bucket we want to fetch.

 

 

Now let's save , activate and run the integration.

We can see in the activity stream the call to get the object from OCI has suceeded:

 

 

Now let's see the actual request and response payload  for this:

Request Payload:

 

The relative URI will be the full path in the OCI for the object.

/Bucket name/folder/sub folder.... if any/filename or object name

 

Response Payload:

 


Now lets see the file and Path which we have fetched , exists in OCI object storage:

For this login to OCI console->Storage-> Buckets

 


Select the compartment->select the Bucket Name 


 

Now traverse to the Object:

 

 

We can verify from the above screenshot that the file which we fetched is same as what we have  in OCI bucket.


Now let us see the second way/option of accessing the bucket:

 

Using native connection

This is more  reliable , faster and Safer.

This came after  Gen2  Upgrade.

For this we need to create API signing Key first and use the pem key to create native connection in OIC.

We can generate the API key for the OCI user.

NOTE: 

After generating the key from OCI we need to convert to RSA format before uploading in OIC connection.

Steps:

1. Download the Private key and convert it to RSA PEM. 2. Run the following command on the file. ssh-keygen -p -f svc_tfe_erp_dev-01-05-05-33.pem -N "" -t rsa -m pem

below are the screenshots of connection:

 

 

 

 

Now lets see an example how we can use this in an OIC integration:

For example configure the this rest adapter connection as below:

 

 


 


 

 Now in the Mapper map the "RelativeURI" with the object we want to access:


Now if we observe , in both the ways(using rest service connection and native connection) we are are accessing in the similar way in design time. There seems to be no difference.

 Lets Save, activate and run the integration. 



We can see in the above screenshot that the call to fetch the file has succeeded.

Since we created the connection differently for both,We can observe difference in the request to external call

            Also if we observe the Relative uri pattern, it is different for both- for native one it uses :

            /n- for namespace

            /b - for bucket

           /o - for object

However for first way it doesn't uses this pattern. There we use directly bucket and object.            

Now lets' see the request payload to get more clarity:

Request payload:

 

Now we can see one of the difference (Relative URI) in request payload.

Let's see the response payload:

 

Response Payload:

  We can see the difference between the two ways in response payload as well.

In  the pure rest service way of accessing we got only the file in response.But in case of native connection we got other details as well.

Let's verify this file in OCI bucket:

Again  For this login to OCI console->Storage-> Buckets->Select the compartment->select the Bucket Name ->Now traverse to the Object:

 

Note:- The user with which we will be creating connection in OIC  for OCI object storage, that user should be part the appropriate policy to access OCI object storage buckets.

 

So we have seen the two ways of accessing objects  from OCI buckets.

We can decide which one to use based on our need

No comments:

Post a Comment