How can I ignore bodies while recording in wiremock - wiremock

I would like to record requests in such a way that the mappings end up with no bodyPatterns tag. In other words I want recorded mappings to be matched only based on path and regardless of body. Is it possible?

Although not exactly the removal of the tag, the contents of it can be influenced by setting the extractBodyCriteria to 1 byte. In the documentation on Record and Playback there is also a java example:
"extractBodyCriteria" : {
"textSizeThreshold" : "1",
"binarySizeThreshold" : "1"
},

Related

Kafka Connect - json path - regex condition not working

I have an application where I use a connector to save data to a database.
I want to filter the messages saved by removing the ones that have a certain property very long.
My messages are like this :
{
field_a : value,
field_b : value,
field_c : possible very long value
}
So, I used in the kafka connector the Confluent Filter like this :
transforms: filterSpam
transforms.filterSpam.type: io.confluent.connect.transforms.Filter$Value
transforms.filterSpam.filter.condition: $[?(#.field_c =~ /^.{32000,}$/)]
transforms.filterSpam.filter.type: exclude
transforms.filterSpam.missing.or.null.behavior: include
For some reason the filter is not working. All messages pass through.
I tried also with the negation :
$[?(!(#.field_c =~ /^.{1,32000}$/))]
In this case, the very long were filtered out, but also some of the shorter ones were.
I do not understand where the issue is coming from. Any help ?
Actually, I needed to update my regex knowledge.
The issue was related to the fact that the string field on which I tried to apply the regex sometimes was multiline.
Thanks to this I managed to use a proper validation of the size of this field.
The final solution is :
transforms.filterSpam.filter.condition: $[?(#.field_c =~ /(\s)^.{32000,}$/)]

Google Analytics API - Sections returned in unwanted order

Using the GA API v4, I'm trying to retrieve data from multiple segments, that have been defined inside Google Analytics. My application does not know the names of these segments, but let's say they are called A, B, C and D inside GA. (Other users can rename the segments, so the names are really unpredictable.)
My application does have the ID's of these segments hardcoded. (Manually retrieved from https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/segments/list.)
Now it's determined the list of data should be presented in some predefined order of significance. (That is, NOT in alphabetical order.)
So, I send a query to GA API with the segments array in the required order:
reportRequests["0"].segments[
{ segmentId: <id-for-segment-C> },
{ segmentId: <id-for-segment-B> },
{ segmentId: <id-for-segment-D> },
{ segmentId: <id-for-segment-A> }
]
To my surprise, the returned dataset is ordered in alphabetical order of segment name!
reports["0"].data.rows[
{ dimensions: [ "A" ], ... },
{ dimensions: [ "B" ], ... },
{ dimensions: [ "C" ], ... },
{ dimensions: [ "D" ], ... }
]
To make things worse:
The returned data does not include the segment ID's, I can only correlate these by making a separate API call to retrieve information for which segment name corresponds with which ID.
The alphabetic sorting is done with English rules, not with regional rules. (The segment names include the "Å" character, which according to Norwegian rules should be at the end of the alphabet, but is in the beginning for English sorting.)
Am I just imagining things? Am I causing problems by not completely understanding how the API works? Is this a bug in the API? Or is this actually by design?
1) Are you using the v3 or v4 versions? If v3, give a try to v4 and see if it helps. An alternative would be to use dynamicSegments (which I always use) instead of segmentIds: these could be stored in your DB, solving the segment ID-name resolution problem, and would also avoid GA maintenance issues (whereby users modify segments which then breaks your app).
2) Yes, they probably transliterate (Å -> A) and sort only after. I really wouldn't waste time investigating this, I doubt Google will ever change it (it's not a bad behaviour per se, APIs are designed to support coding, not subtleties of the human language, most people, especially Google Engineers based in US, wouldn't care :))

Find and Delete documents in MongoDB using a Windows GUI tool

Okay, I'm a SQL Server based DBA, but there's a biz-critical app that uses MongoDB as a core component, and the problem is that it's grown too large. (The "large-ness" isn't critical yet, I'm trying to be proactive!)
Specifically, it has a "message log" collection which is over 400 GB, where the date-stamp is actually stored as a 2-element array [Int64, Int32], the 0th element being some measure of time (and the 1th element is just always '0').
So for example, a document:
{
"_id" : ObjectId("55ef63618c782e0afcf346cf"),
"CertNumber" : null,
"MachineName" : "WORKERBEE1",
"DateTime" : [
NumberLong(635773487051900000),
0
],
"Message" : "Waited 00:00:30.0013381 to get queue lock: Specs to verify",
"ScopeStart" : false
}
And just because 2 is better than 1, another example document:
{
"_id" : ObjectId("55ef63618c782e0afcf323be"),
"CertNumber" : null,
"MachineName" : "WORKERBEE2",
"DateTime" : [
NumberLong(635773487056430453),
0
],
"Message" : "Waited 00:00:30.0012345 to get queue lock: Specs to verify",
"ScopeStart" : false
}
I need to figure out two things:
What the heck does that "DateTime" really mean? It's not Unix Epoch time (seconds nor milliseconds); and even if I strip off the trailing 0's, it represents (in millis) 6/20/2171, so, unless we're building a time machine here, it makes no sense. If I strip off the last 6 digits, it means 2/23/1990, but even that doesn't seem likely, as this application has only existed since the early 2000's. (AFAIK)
Assuming we figure out #1, can we use some kind of command to remove (delete) all documents in the collection that are older than, say, 1/1/2016?
Again, I'm a SQL guy, so try to explain using analogs in that vein, e.g. "this is like your WHERE clause" and such.
PS: Yes, I read thru questions such as Find objects between two dates MongoDB and How do I convert a property in MongoDB from text to date type? , but so far nothing has jumped out at me.

How Can I parse a request uri containing specific word

I am trying to handle a request containing word "filter". For the time being, I am using the url as
http://localhost:9997/filter=....
and parsing by using pathPrefix(fiter)
But url will change and becomes like
http://localhost:9997/something../filter=
So here I can't take pathPrefix().
How can I handle this kind of path in routing so that any url containing "filter" keyword it can handle.
I am very much new to akka spray. Please let me know about your opinions. Thanks in advance
If the string you want to match will always be at the end you can use "pathSuffix" (it might be enough for what you want)
pathSuffix("filter") { ... }
But if it can be anywhere in the path, is not that straighforward. One way is using segments:
path( Segment / "filter" / Segment ){ (prefix, postfix) => {...} }
But it doesn't match if filter is at either end: "filter/blah/blah" nor "balh/blah/filter", but you can work around by matching with prefix and suffix. I suppose there's a better way, maybe with a custom directive.
Take a look at
http://spray.io/documentation/1.2.3/spray-routing/predefined-directives-alphabetically/#predefined-directives

How to suppress the Play framework's output of data types in forms

Using the helper functions of the Play framework to create form elements (particularly text inputs) results in inputs being labeled with "required", "numeric", "real", etc.
I want to suppress the output of all but "required". How can I do this? Is there a per-input way to modify this text?
To demonstrate, here's an example of the text, placed below the input:
Which are created with:
#inputText(
propertyForm("totalRooms"),
'_label -> Messages("properties.add.totalRooms"),
)
They can't trivially be removed with CSS, since the "required" and "numeric" (etc) labels all have the same class (and it'd be ideal to be able to specify what text goes there, rather than completely remove it).
I think you may use internationalization files (the "messages" file) to override them. You may be able to associate an empty String to the key. Some of the keys I use that come form Play are :
# --- Constraints
constraint.required=Obligatoire
constraint.min=Valeur minimum : {0}
constraint.max=Valeur maximum : {0}
constraint.minLength=Longueur minimum : {0}
constraint.maxLength=Longueur maximum : {0}
constraint.email=Email
# --- Formats
format.date=Date (''{0}'')
format.numeric=Numérique
format.real=Réel