Debezium outbox payload filtering - json

I have a Debezium connector correctly listening to an outbox table and providing a JSON object as the Kafka message value.
I have read the documentation and tried various things but can't find the second part of what I need.
If I have a json object as my message can the connector filter the message such that only a specific attribute or set of attributes are included.
For example
{
"FirstObject": {
"name": "an object name"
},
"SecondObject": {
"legs": 12
}
}
Currently I receive the complete json, is there a way to say only publish SecondObject in the kafka message?

Related

Azure Logic App - Parse JSON with dynamic key/name

just want to know if and how I can parse a HTTP response with a dynamic name in a JSON?
I used the Azure Management API to receive the managed identities (system- and user assigned managed identities) to receive all managed identities.
With a foreach I am iterating the results.
If a resource has a system assigned managed identity and user assigned managed identity, the response looks like this:
{
"principalId": "<principalId1>",
"tenantId": "<tenantId>",
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/<subscriptionId>/resourcegroups/<resourceGroupName>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<userAssignedIdentitiesName>": {
"principalId": "<principalId2>",
"clientId": "<clientId>"
}
}
}
Now, I would like to get the <principalId2>.
Unfortunately, the Name of the object is dynamic related to the scope of the resource /subscriptions/<subscriptionId>/resourcegroups/<resourceGroupName>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<userAssignedIdentitiesName>.
How can I parse the JSON to receive the needed <principalId2>?
For all other responses I can easily use the Data operations Parse JSON with the payload I inserted from the HTTP response.
Is there a way to use a wildcard? Otherwise, could I somehow just select the first object of userAssignedIdentities to receive the needed value?
Ok, this should work for you. This is the flow I tested with ...
Initialise JSON
Your JSON as a string, how you do that in your solution may differ slightly.
Initialize XPath Result
Defined as an Array and the expression is ...
xpath(xml(json(concat('{ root: ', replace(variables('JSON'), 'PrincipalId', 'principalId'), '}'))), '(//principalId)[2]')
Initialize Result
A bit more work again but defined as a String and the expression is ...
array(xpath(xml(base64ToString(variables('XPath Result')[0]?['$content'])), '//text()'))[0]
The end result should be your value ...

freeradius 3.0.17 rlm_rest parsing json response

I'm trying to authenticate RADIUS Requests against a RESTful API (provided by Customer) using rlm_rest.
The problem I am facing is that
response JSON format (of REST API provided by Customer), is different from rlm_rest default format (indicated in etc/raddb/mods-enabled/rest).
My Virtual Server configuration as below:
Default
authorize {
...
...
rest
if (ok) {
update control {
Auth-Type := rest
}
}
}
mods-enabled/rest
authorize {
uri = "https://3rd-party-API/auth"
method = 'post'
body = 'json'
chunk = 0
tls = ${..tls}
data = '{
"code": 1,
"identifier": %I,
"avps": {
"User-Name": ["%{User-Name}"],
"NAS-IP-Address": ["%{NAS-IP-Address}"],
"Called-Station-Id": ["%{Called-Station-Id}"],
"Calling-Station-Id": ["%{Calling-Station-Id}"],
"NAS-Identifier": ["%{NAS-Identifier}"]
}
}'
}
Result
/sbin/radiusd -Xxx
HTTP response code
200
JSON Body
{
"code": "2",
"identifier": "91",
"avps": {
"Customer-Attributes": "Hello"
...
...
"Acct-Interim-Interval": "300"
}
}
The JSON structure is different from the example, and xlat parse
"code"
"identifier"
"avps"
And, of course, xlat finds no attributes match with the dictionary, while it cannot find "avps" and won't dig deeper.
So I was wondering is there anyway to either
Define the response JSON structure for xlat to parsing
Insert a "is_json" or "do_xlat" flag into the JSON ("avps"), and hope xlat will then dig deeper
Save the JSON and parse with exec/rlm_exec (using JQ or any other bash/JSON tools)
Please advise if there is any workaround. Thanks!
In FreeRADIUS version 4, there's a rlm_json module, which implements a custom node query language based on xpath (jpath), it is extremely limited and only supports some very basic queries (feel free to enhance it via PR :) ).
Below is an example I pulled out of my library of customer configurations. You can see here it's pulling out two keys (externalID and macAddress) from the root level of the JSON doc and assigning them to a couple of custom attributes (Subscriber-ID and Provisioned-MAC).
map json "%{rest_api:https://${modules.rest[rest_api].server}/admin/api/${modules.rest[rest_api].api_key}/external/getDeviceBySerialNumber?certificateSerialNumber=%{lpad:&TLS-Client-Cert-Serial 40 0}}" {
&Subscriber-ID := '$.externalId'
&Provisioned-MAC := '$.macAddress'
}
The xlat expansion can also be modified to send HTTP body data. Just put a space after the URL and pass your custom JSON blob.

Is there an alternative to "type": "undefined" in JSON?

I'm working with Amazon API Gateway. I am creating a model for an REST API. The model gets hung up on:
"tiers": {
"type": "array",
"items": {
"type": "undefined"
}
}
The API data model uses JSON schema draft 4.
The error returned is:
Invalid model specified: Validation Result: warnings : [], errors :
[Invalid model schema specified]
Anyone run into this before?
Things I've tried:
Removing this property = script creates model
Changing "Undefined" to "null" = script creates model
The "null" seems like the right option but, I've not been able to back it up. Some guidance and/or clarification would be greatly appreciated.
Thanks,
Todd
You don't seem to be actually defining a schema for your data, refer to the API gateway docs to re-define your model.
undefined is not a valid json value, even though it is valid in javascript. From the official json standard (ECMA-404, Section 5):
A JSON value can be an object, array, number, string, true, false, or
null.
For json, use null instead of undefined: { "something": null }
Using null instead of undefined is definitely not ideal, but it's a standard you can count on when consuming third-party services.

Spring cloud stream not able to retrieve Array List instead String is being picked at listener

i am sending an Array list from Producer and i am expecting to read the same arraylist at the consumer and persist into Database.
Instead of me getting the the Object i am getting and json wrapped inside the Object,which i am not able to understand why.
Below is representation of different objects.
Expexcting:
user is [Users [id=1, name=Prashantrh, nm=com.example.demo.Name#2b65d9e7]]
Pickied up at consumer side as:
[
[
{
"dmetaD":{
"id":2315,
"embedded":true,
"size":123,
"comment":"raghu",
"name":"string",
"type":"pdf",
"creationTime":"2018-05-15T20:47:48.161",
"creatorId":15001,
"creator":{
"id":15001,
"shortId":"MARC6GR",
"firstName":"V15001",
"lastName":"N15001",
"emailPref":true,
"departmentName":"RD/FNT",
"inventoryType":"P",
"langPref":"DE",
"email":"V15001.N15001#d.com"
}
},
"dCont":{
"data":"abc"
}
},
{
"dmetaD":{
"id":2316,
"embedded":true,
"size":123,
"comment":"raghu",
"name":"string",
"type":"pdf",
"creationTime":"2018-05-15T20:47:48.163",
"creatorId":15001,
"creator":{
"id":15001,
"shortId":"MARC6GR",
"firstName":"V15001",
"lastName":"N15001",
"emailPref":true,
"departmentName":"RD/FNT",
"inventoryType":"P",
"langPref":"DE",
"email":"V15001.N15001#d.com"
}
},
"dCont":{
"data":"def"
}
}
]
]
First, please provide more details as to what version of Spring Cloud Stream you are using.
That said, I am going to assume for now that you are using 2.0.0.RELEASE which means the content type of the message defaults to application/json.

What is wrong with this Json array syntax?

I am sending a web request to Firebase Cloud Messaging to send a message. The raw data as sent with Content-Type:application/json" is:
{ "to":"ecO8y..._D", "data": [ {"msisdn":"+1111111" }, {"b":"c"} ] }
Firebase responds with this error message:
Field "data" must be a JSON array: [{"msisdn":"+1111111"},{"b":"c"}]
Is there something wrong with the text that I have entered for the data field?
I think the "JSON array" wording is confusing here. The data needs to be a JSON object with a single level of properties, so:
{
"to":"ecO8y..._D",
"data": {
"msisdn":"+1111111",
"b":"c"
}
}
When you try to send data from your application server to FCM, you will get 400 error, if data element contains hierarchical data or array of elements.
Data with one level of child element works.
{"message":{"topic":"users","data":{"name":"srao","pho":"38743"}}}
Data with array of element doesn't work.
{"message":{"topic":"users","data":[{"name":"grag","pho":"38743"},{"name":"boney","pho":"3899943"}]}}
Data with multiple levels or hierarchy doesn't work.
{"message":{"topic":"users","data": {"person" : {"name":"srao","pho":"38743"}}}}