Rest polling service type

The restPollingServiceType is a service type of Polling Source mode. It can be used to poll REST endpoints and publish the obtained data into configured Diffusion topics.

There can be multiple instances of this service type added to the adapter, to consume data from different REST endpoints or APIs and publish them to different Diffusion topics, using different configurations.

Complete configuration for a service consists of the framework required configuration for polling source service and the service type specific configuration.

Example 1. Sample configuration for a service of type restPollingServiceType
{
  "serviceName": "rates-of-exchange",
  "serviceType": "restPollingServiceType",
  "description": "",
  "config": {
    "framework": {
      "pollIntervalMs": 15000,
      "pollTimeoutMs": 10000
    },
    "application": {
      "restApi": {
        "baseUrl": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service",
        "path": "/v1/accounting/od/rates_of_exchange"
      },
      "topic": {
        "path": "rates-of-exchange",
        "updateMode": "STREAMING"
      }
    }
  }
}

Polling service Framework configuration

Details about supported configuration parameters for framework configuration for the Polling service can be found here.

Application configuration

The supported application configuration parameters for this service are defined in the table below:

'restPollingServiceType' service application configuration
Property Description Default

restApi

REST API configuration

-

topic

Topic configuration

-

restApi JSON property

restApi JSON property
Property Description Default

baseUrl

The REST API base URL, for example: api.fiscaldata.treasury.gov/services/api/fiscal_service.

GET

path

The REST API path, for example: /v1/accounting/od/rates_of_exchange.
Note: Not all REST APIs expose a path

-

method

HTTP method. Options available, one of: GET, POST

-

basicAuth

Username and password for basic access authentication.

-

headers

HTTP headers as key/value pairs.

-

queryParameters

HTTP query parameters as key/value pairs.

-

postContent

A string value to be posted to a REST API.

-

topic JSON property

topic JSON property
Property Description Default

path

The Diffusion topic path.

-

updateMode

Update mode, can be one of: SIMPLE, STREAMING.

SIMPLE

Configuration of restSharedConfigType is the same as that of restPollingServiceType service type.

If a sharedConfig instance is defined in the configuration and is referred to in the service configuration, the overall configuration of the service is formed using a combination of configuration defined in the sharedConfig instance and the service instance. When a duplicate configuration is defined in the sharedConfig instance and in the service instance, the configuration in service configuration will take precedence.

In the overall configuration of the service, the mandatory configurations required are: restApi.baseUrl and topic.path.

Below is a sample configuration of a service for the application JSON property:

{
  "restApi": {
    "baseUrl": "service-base-url",
    "path": "service-path",
    "method": "post",
    "basicAuth": {
      "username": "username",
      "password": "password"
    },
    "headers": {
      "shk1": "shv1",
      "shk2": true
    },
    "queryParameters": {
      "sqk1": "sqv1",
      "sqk2": [
        1,
        2,
        3
      ]
    },
    "postContent": "post-content"
  },
  "topic": {
    "path": "topic-path",
    "updateMode": "STREAMING"
  }
}
A JSON schema is provided in the bundle to assist with validation of the restPollingServiceType service configuration.