Monday, 14 January 2019

Redaction policy in Oracle API Cloud Service

Oracle API CS offers an inbuilt feature to limit or remove the certain fields and headers which is the part of request and response payload. This policy is called Redaction policy. The policy can be used in both request and response pipeline.

In the request pipeline, headers, queries and payload content can be controlled before the backend service is invoked. Similarly, in the response pipeline, headers, queries and payload content can be controlled before the response sent to the consumer.

Let's see how to apply the redaction policy in request and response pipeline separately.

To complete this article, we'll assume one service is already configured in the Oracle API CS. If not, kindly follow the blog

Let suppose, one API configured is in the API CS with the below request and response:

Request URL:

https://189.11.11.13:8443/redact

HTTP Verb: GET

Parameter / Header

Parameter / Header
Description
empi
This is of query parameter of string type
key
This is custom request header of string type

Response:

{
    "Employee": {
        "Name": "Ankur",
        "EmployeeID": "122",
        "key": "12"
    }
}


For the particular API, We'll exclude the request header (key) and Employee.Name node from the response one by one using Redaction policy.

Configure the Redaction policy in the Request pipeline
  • Click the API implementation tab of the API
  • Move to the Request pipeline
  • In the Available Policies region, expand Interface Management, hover over Redaction, and then click Apply
  • Enter below information and click the Next button
    • Your Policy Name: Enter the policy name of your choice
    • Comments: Enter comment
    • Place after the following policy: Select the policy after which this policy is placed
  • Select Exclude from the Headers section and enter key in the Header name then click Apply button
  • Click Save to save the changes and redeploy the API
  • Hit the API, pass custom header(key) and see the response, key value will be blank in response as request key header is directly mapped with the key of the response payload

Configure the Redaction policy in the Response pipeline
  • Click the API implementation tab of the API
  • Move to the Response pipeline
  • In the Available Policies region, expand Interface Management, hover over Redaction, and then click Apply
  • Enter below information and click the Next button
    • Your Policy Name: Enter the policy name of your choice
    • Comments: Enter comment
    • Place after the following policy: Select the policy after which this policy is placed

  • Select Exclude from the Field section and enter Employee.Name in the Field name then click Apply button
  • Click Save to save the changes and redeploy the API
  • Hit the API and see the Employee.Name should not come as part of the response

Saturday, 5 January 2019

Oracle Integration Cloud REST API to get the Integration Statistics

Oracle Integration cloud provides a rich monitoring dashboard to see the Integration statistics. But there is a limitation that statistics can't be downloaded from the dashboard in any format (XLS, pdf etc.). To overcome this limitation Oracle Integration Cloud provides RESTFul APIs which provides the statistics of each and every running integration.


In this article, we'll demonstrate how to use Integration Cloud REST API to retrieve monitoring integrations as well as how to generate excel sheet using java code.

Below is the REST API details which is used to retrieve monitoring integrations:

URL:

For ICS:

/icsapis/v2/monitoring/integrations

For OIC / AIC

/ic/api/integration/v1/monitoring/integrations

HTTP Verb: GET

Authentication

Basic Authentication is required
Query Parameter

Parameter Name
Optional
Filter Parameters
q
Yes
timewindow: "1h","6h","1d","2d","3d","RETENTIONPERIOD" For examples: {timewindow: '3d'}

Response:

{
    "items": [
        {
            "code": "TEST_API",
            "id": "TESTP_API|01.00.0000",
            "links": [
                {
                    "href": "https://testinstance.integration.us2.oraclecloud.com:443/icsapis/v2/monitoring/integrations/TEST_API%7C01.00.0000",
                    "rel": "self"
                },
                {
                    "href": "https://testinstance.integration.us2.oraclecloud.com:443/icsapis/v2/monitoring/integrations/TEST_API%7C01.00.0000",
                    "rel": "canonical"
                },
                {
                    "href": "https://testinstance.integration.us2.oraclecloud.com:443/icsapis/v2/integrations/TEST_API%7C01.00.0000",
                    "rel": "integration"
                }
            ],
            "name": "TEST_API",
            "noOfErrors": 0,
            "noOfMsgsProcessed": 1,
            "noOfMsgsReceived": 1,
            "noOfSuccess": 1,
            "successRate": 100,
            "version": "01.00.0000"
        },
        {
            "code": "PRO_CREATION",
            "id": "PRO_CREATION|04.00.0000",
            "links": [
                {
                    "href": "https://testinstance.integration.us2.oraclecloud.com:443/icsapis/v2/monitoring/integrations/PRO_CREATION%7C04.00.0000",
                    "rel": "self"
                },
                {
                    "href": "https://testinstance.integration.us2.oraclecloud.com:443/icsapis/v2/monitoring/integrations/PRO_CREATION%7C04.00.0000",
                    "rel": "canonical"
                },
                {
                    "href": "https://testinstance.integration.us2.oraclecloud.com:443/icsapis/v2/integrations/PRO_CREATION%7C04.00.0000",
                    "rel": "integration"
                }
            ],
            "name": "PRO_Creation",
            "noOfErrors": 2,
            "noOfMsgsProcessed": 35,
            "noOfMsgsReceived": 35,
            "noOfSuccess": 33,
            "successRate": 94,
            "version": "04.00.0000"
        }
    ]
}

Below is the screenshot of POSTMAN where we executed the REST APIs to get data with and without query parameter. If the query parameter will not be passed then the data will come from the first day.



This is how the REST API can be used to get the monitoring instance. Let's come on how to generate excel sheet based on the data received from API using java code.

Below is the snapshot of the Excel sheet which will be generated using JAVA code


Below is the structure of JAVA code developed in JDeveloper


Download the JAVA code which is used to generate an Excel sheet. Import the code into JDeveloper, update the Constants.java file and run CreateReport.java file directly. An excel file will be generated in the configured folder.