Is there a way to put a conditional in an aws event bridge input transformer? - aws-event-bridge

Let's say something like:
{
"InputPathsMap": {"instance1": "$.detail.instance1","instance2": "$.detail.instance2"},
"InputTemplate": "<instance1 || instance2>"
}

Related

Issue with CRMContainer in Twilio Flex

I built a simple plugin that shows in the CRMContainer the url of my CRM given some attributes parameters (if they are passed by), during inbound tasks this works fine, but the problem is that during outbound calls the behaviour is not the one expected, this is the piece of code:
flex.CRMContainer.defaultProps.uriCallback = (task) => {
return task
? `https://mycrm.zzz/${task.attributes.clicar}/${task.attributes.contacth}/`
: 'https://mycrm.zzz/contacts/';
}
}
I would need an additional condition that tells the code, if this is an outbound voice call to always show a default url.
I tried adding an if/else that checks if task.attributes.direction is outbound, but Flex says this is undefined.
Any tip?
Thanks
Max
The problem is that you aren't checking for the existence of the task. Your original code had this:
flex.CRMContainer.defaultProps.uriCallback = (task) => {
return task
? `https://mycrm.zzz/${task.attributes.clicar}/${task.attributes.contacth}/`
: 'https://mycrm.zzz/contacts/';
}
}
Which returns the URL with the task attributes in it only if the task exists, because of the ternary conditional.
So, when you try to use the attributes you need to make sure the task exists. So taking your code from the last comment, it should look like this:
flex.CRMContainer.defaultProps.uriCallback = (task) => {
if (task) {
if (task.attributes.direction === 'outbound'){
return `https://mycrm.zzz/${task.attributes.clicar}/${task.attributes.contacth}/`;
} else {
return `https://mycrm.zzz/contacts/`
}
} else {
return 'https://mycrm.zzz/contacts/';
}
}

Applying filters in Sensu

I have tried applying a filter in Sensu, from referring Sensu document, for reducing our monitoring alerts. But problem is, this filter is sending email only when issue is in Resolved state, no critical or warning alerts. Filter looks like :
{
"filters": {
"state_change_only": {
"negate": false,
"attributes": {
"occurrences": "eval: value == 1 || ':::action:::' == 'resolve'"
}
}
}
}
Please help me in understanding this behaviour and what this eval: value == 1 actually means here.
Does it have to do anything with occurrences value? I have values like 2,3 etc. depending on the severity of the checks.

JsPdf Auto Table : Customize headers with colspan

I need to export a few tables to PDF format. I decided to use jspdf-autotable but I can't find a way to customize my header. I need to do this in the header style :
_________________________________________
|__________|______________|_____________|
|____|_____|___|__|___|___|___|___|__|__|
|____|_____| ... (content)
|____|_____| ... (content)
The first line is my problem, as headers are define differently, and I cant find a way to do this through the "drawHeaderCell" method.
Do u know a way to do this ?
Thank you
To get such a result you could implement the drawHeaderCell hook something like this:
drawHeaderCell: function(cell, data) {
if (data.column.dataKey === 'id' || data.column.dataKey === 'first_name' || data.column.dataKey === 'email') {
cell.width = data.table.width / 3;
} else {
return false;
}
}
Doing rowspans and colspans are quite complicated at this stage with jspdf-autotable. There is an example for how they could be implemented in the repo however.

Can I populate GET requests safely?

I am adding random get requests to URLs.
foo.com/?boofoo=foo
Can I do this safely? Or is is possible I might break a site by doing this?
You should be fine if you handle the input properly.
So for example with PHP:
<?php
if($_GET['booofooo'] == "value1") {
// do something
} elseif($_GET['booofooo'] == "value2") {
// do something
} elseif($_GET['booofooo'] == "value3") {
// do something
} else {
// error
}
?>
Also, make sure to use escape the data if you're going to put it in your database.

No such property: getFlatConfig when trying to access configuration

So have set up a couple of values in the groovy.config file which I want for my application.
Set them as follows:
environments {
development {
grails.logging.jul.usebridge = true
reslist = ['1400x1200','1200x1024','1024x800','800x600']
resdef = '1024x800'
mapregs = ['World', 'Europe', 'Asia', 'South America','Central America', 'Pacific','Africa']
mapdef = 'World'
Then I try to access them in a controller
if ( params.mapreq == null) {
mapreq = grailsApplication.config.grails.mapdef
} else {
mapreq = params.mapreq
}
It seems to work (kind a) I get something back, but looks like an object pointer in the format
groovy.util.ConfigObject#3764a904
Tried changing it to getFlatConfig
if ( params.mapreq == null) {
mapreq = grailsApplication.getFlatConfig.grails.mapdef
} else {
mapreq = params.mapreq
}
At which point I get a "No such property: getFlatConfig when trying to access configuration" instead
So any suggestions?
Also, would the same solution work for getting the lists (like the mapregs one)?
grailsApplication.config.grails.mapdef should be grailsApplication.config.mapdef since mapdef is at the top level of the config (within that environment block). Since there's nothing stored under grails.mapdef, the value will be a new ConfigObject. That's why config.a.b.c.d=1 works - each time you access a new level that doesn't exist, Groovy automatically creates a new ConfigObject to hold the value being set, but if you're getting and not setting, you end up with just the empty instance.
The 2nd one doesn't work because getFlatConfig should be getFlatConfig() or flatConfig. But you can't use the ConfigObject-style dots with the flat config because it's flattened. If mapdef was actually under grails you'd access it as grailsApplication.flatConfig.'grails.mapdef' or grailsApplication.flatConfig['grails.mapdef']. But like the other one it's not, so you'd use grailsApplication.flatConfig.mapdef.

Resources