Objective

  1. Provide faster rollout of new Firebolt API without a Ripple update.
  2.  Most of the existing Thunder APIs are Firebolt ready(FiRe) with some trivial JSON translation. The objective is to adopt a widely accepted JSON transformation language like jq, which allows operators to learn and configure rules without our support and training.
  3. Provide a migration plan to include new New Thunder Plugins(FiRe) that become available in open source.
  4. Should inherently support Firebolt Extension SDKs.


Overview

FiRe API

FiRE stands for Firebolt Ready API

What is a FiRe Thunder API?

  • A Thunder API method that has a direct mapping to one or more Firebolt APIs.
  • A Thunder API can map individual fields in a request, response, or event to a Firebolt API
  • A Thunder API message (request/response/event) can transform into a Firebolt API schema with a trivial JQ-based rule.


Rules Engine

What is jq programming language?

jq is a very high level, lexically scoped language used for json processing. There are many online tools available to test jq rules

Rule for Timezone API

Get Timezone

device.timezone: {alias: "org.rdk.System.getTimezoneDST",responseFilter: ".timezone"},


Set Timezone

device.setTimezone: {alias: "org.rdk.System.setTimezoneDST",requestFilter: "{ timezone : .value }",responseFilter: "if .success then null else {
code: -32100,
message: "couldnt set timezone" } end"}

Given Firebolt API allows error codes to be interpreted by the underlying implementation, operators can define their own errors and messages in the rule itself.

JQ support for Firebolt ready Plugin(s)

Existing Thunder to Firebolt JSON transformations performed by the Thunder extension for each API is captured in this worksheet

As part of the Ripple Gateway architecture, we are trying to leverage rules syntax like Jq to offer Firebolt translations.

The objective here is to make the Ripple rules engine more open-sourced and let operators configure their own rules for some of the adapters.

As part of the pre-request and post-result/event process, Ripple gateway will apply the rules defined in the filter to accomplish the support.


Here are examples of FiRe Thunder API





 localization.onCountryCodeChanged
{
        "oldTerritory": "GBR",
        "newTerritory": "USA",
        "oldRegion": "GB-ENG",
        "newRegion": "US-NY"
    }



US
 

if .newTerritory==\"ITA\" then \"IT\" else \"UK\" end

securestorage.get

Request

"params": {
"namespace": "appId",

"scope": "device",

"key": "someKey"

}

 

Request

"params": {

"scope": "device",

"key": "someKey"

}

{ namespace: \"$context.appId\", scope: .scope, key: .key, value: .value }

securestorage.set

Request

{
"namespace": "appId",

"scope": "device",

"key": "someKey",

"value": "someToken"

}

Response


{
"success": bool
}


Request

{


"scope": "device",

"key": "someKey",

"value": "someValue"

}



Response null


"transform": {
"request": "{ namespace: \"$context.appId\", scope: .scope, key: .key, value: .value }",
"response": "if .success then \"null\" else { code: -32100, message: \"couldnt set timezone\" } end"
}

 


Ripple would require a filter in the configuration to support such an initiative

"localization.onCountryCodeChanged": {
            "alias": "org.rdk.System.onTerritoryChanged",
            "transform": {
                "event": "if .newTerritory==\"ITA\" then \"IT\" else  \"UK\" end"
            }
        },
"securestorage.get": {
            "alias": "org.rdk.PersistentStore.1.getValue",
            "transform": {
                "request": "{ namespace: \"$context.appId\", scope: .scope, key: .key }",
                "response": ".value"
            }
        },
        "securestorage.set": {
            "alias": "org.rdk.PersistentStore.1.setValue",
            "transform": {
                "request": "{ namespace: \"$context.appId\", scope: .scope, key: .key, value: .value }",
                "response": "if .success then \"null\" else { code: -32100, message: \"couldnt set timezone\" } end"
            }
        }


Brokers

Ripple as a gateway will use Brokers to interface with the Firebolt Ready providers. Below is the list of current brokers

  1. Thunder (Default Broker)
  2. Websocket Broker 
  3. HTTP Broker

Thunder is the default broker for Ripple, it also supports other brokers. WS and HTTP Brokers would be supported based on their access and availability. If the Web-based broker is available internally within the device then tokens are not mandatory. All external endpoints would necessitate authentication mechanism preferably using tokens here are the list of supported tokens

Token Types


Token TypeContext Definition to be used in Rules
Account
$context.accountToken"
Platform$context.platformToken
Device

$context.deviceToken

Distributor

$context.distributorToken

Root

$context.rootToken



"endpoints": {
	"secureService": {
        "protocol": "http",
        "url": "https://secureservice.firebolt.com",
        "webContext": {
            "headers": {
			   "Authetication": "Bearer $context.accountToken",
               "OtherHeader": "Some Service specific headers"
            }
        }
    },
    "someOtherService": {
        "protocol": "http",
        "url": "https://secureservice.firebolt.com?token=$context.deviceToken"
    },
},
"rules {
	"securestorage.set": {
            "endpoint": "secureService",
            "alias": "/get",
            "transform": {
                "request": "{ namespace: \"$context.appId\", scope: .scope, key: .key, value: .value }",
                "response": "if .success then \"null\" else { code: -32100, message: \"couldnt set timezone\" } end"
            }
     }
}



  • No labels