Receiving multiple webhook notifications for every Office 365 event update - json

I'm working on a sync server that keeps the Office 365 events and my calendering app in sync
I subscribed to a push notification for user's event calendar that has the following custom single extended property.
Sample subscription request payload
{
"resource": "/me/events?$expand=singleValueExtendedProperties($filter=id%20eq%20'\''String%20{66f5a359-4659-4830-9070-00047ec6ac6e}%20Name%20CUSTOM'\'')",
"notificationUrl": "https://serverurl.xxxx.com/dev/notification",
"changeType": "updated,created",
"clientState": "123456-fad3-4191-9a66-123456789",
"expirationDateTime": "2018-03-17T11:00:00.0000000Z"
}
Then I do a single update of calendar event that has the above custom single extended property. On update, the sync server receives multiple notifications (2-3 notifications) for just updating the title of the event.
Notification 1:
{
"value": [{
"subscriptionId": "9645fed8-dc53-4955-b3a1-2d2b9ac5728f",
"subscriptionExpirationDateTime": "2018-03-17T11:00:00+00:00",
"changeType": "updated",
"resource": "<masked>",
"resourceData": {
"#odata.type": "#Microsoft.Graph.Event",
"#odata.id": "<masked>",
"#odata.etag": "W/\"+JK7q7qG1U+aBgDQ2ypjIQAAVnP6yQ==\"",
"id": "AAMkAGJmZjA5NzI0LWM5NTgtNGRhYy04MDExLTJmZTY4ZTJkNmVlYQBGAAAAAAC-F40EZzuzSqgA9N8VQW0zBwD4kruruobVT5oGANDbKmMhAAAAAAENAAD4kruruobVT5oGANDbKmMhAABV-OaMAAA=",
"createdDateTime": "2018-03-13T13:30:54.740501Z",
"lastModifiedDateTime": "2018-03-13T13:42:33.7107864Z",
"changeKey": "+JK7q7qG1U+aBgDQ2ypjIQAAVnP6yQ==",
"categories": [],
"originalStartTimeZone": "Pacific Standard Time",
"originalEndTimeZone": "Pacific Standard Time",
"iCalUId": "040000008200E00074C5B7101A82E0080000000006474883CFBAD30100000000000000001000000021D57F3032480543BE96AE56D8816FDF",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "Microsoft DEMO - 2 UPDATED",
"bodyPreview": "Let's get together!",
"importance": "Normal",
"sensitivity": "Normal",
"isAllDay": false,
"isCancelled": false,
"isOrganizer": true,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "Busy",
"type": "SingleInstance",
"webLink": "<masked>",
"onlineMeetingUrl": null,
"responseStatus": {
"Response": "Organizer",
"Time": "0001-01-01T00:00:00Z"
},
"body": {
"ContentType": "HTML",
"Content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nLet's get together!\r\n</body>\r\n</html>\r\n"
},
"start": {
"DateTime": "2018-03-29T01:00:00Z",
"TimeZone": "tzone://Microsoft/Utc"
},
"end": {
"DateTime": "2018-03-29T06:00:00Z",
"TimeZone": "tzone://Microsoft/Utc"
},
"location": {
"DisplayName": "",
"LocationType": "Default",
"UniqueIdType": "Unknown",
"Address": {
"Type": "Unknown"
},
"Coordinates": {}
},
"locations": [],
"recurrence": null,
"attendees": [{
"Type": "Required",
"Status": {
"Response": "None",
"Time": "0001-01-01T00:00:00Z"
},
"EmailAddress": {
"Name": "<masked>",
"Address": "<masked>"
}
}],
"organizer": {
"EmailAddress": {
"Name": "<masked>",
"Address": "<masked>"
}
}
},
"clientState": "123456-fad3-4191-9a66-123456789"
}]
}
Notification 2:
{
"value": [{
"subscriptionId": "9645fed8-dc53-4955-b3a1-2d2b9ac5728f",
"subscriptionExpirationDateTime": "2018-03-17T11:00:00+00:00",
"changeType": "updated",
"resource": "<masked>",
"resourceData": {
"#odata.type": "#Microsoft.Graph.Event",
"#odata.id": "<masked>",
"#odata.etag": "W/\"+JK7q7qG1U+aBgDQ2ypjIQAAVnP6yw==\"",
"id": "AAMkAGJmZjA5NzI0LWM5NTgtNGRhYy04MDExLTJmZTY4ZTJkNmVlYQBGAAAAAAC-F40EZzuzSqgA9N8VQW0zBwD4kruruobVT5oGANDbKmMhAAAAAAENAAD4kruruobVT5oGANDbKmMhAABV-OaMAAA=",
"createdDateTime": "2018-03-13T13:30:54.740501Z",
"lastModifiedDateTime": "2018-03-13T13:42:33.869926Z",
"changeKey": "+JK7q7qG1U+aBgDQ2ypjIQAAVnP6yw==",
"categories": [],
"originalStartTimeZone": "Pacific Standard Time",
"originalEndTimeZone": "Pacific Standard Time",
"iCalUId": "<masked>",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "Microsoft DEMO - 2 UPDATED",
"bodyPreview": "Let's get together!",
"importance": "Normal",
"sensitivity": "Normal",
"isAllDay": false,
"isCancelled": false,
"isOrganizer": true,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "Busy",
"type": "SingleInstance",
"webLink": "<masked>",
"onlineMeetingUrl": null,
"responseStatus": {
"Response": "Organizer",
"Time": "0001-01-01T00:00:00Z"
},
"body": {
"ContentType": "HTML",
"Content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nLet's get together!\r\n</body>\r\n</html>\r\n"
},
"start": {
"DateTime": "2018-03-29T01:00:00Z",
"TimeZone": "tzone://Microsoft/Utc"
},
"end": {
"DateTime": "2018-03-29T06:00:00Z",
"TimeZone": "tzone://Microsoft/Utc"
},
"location": {
"DisplayName": "",
"LocationType": "Default",
"UniqueIdType": "Unknown",
"Address": {
"Type": "Unknown"
},
"Coordinates": {}
},
"locations": [],
"recurrence": null,
"attendees": [{
"Type": "Required",
"Status": {
"Response": "None",
"Time": "0001-01-01T00:00:00Z"
},
"EmailAddress": {
"Name": "<masked>",
"Address": "<masked>"
}
}],
"organizer": {
"EmailAddress": {
"Name": "<masked>",
"Address": "<masked>"
}
}
},
"clientState": "123456-fad3-4191-9a66-123456789"
}]
}
Notification 3:
{
"value": [{
"subscriptionId": "9645fed8-dc53-4955-b3a1-2d2b9ac5728f",
"subscriptionExpirationDateTime": "2018-03-17T11:00:00+00:00",
"changeType": "updated",
"resource": "<masked>",
"resourceData": {
"#odata.type": "#Microsoft.Graph.Event",
"#odata.id": "<masked>",
"#odata.etag": "W/\"+JK7q7qG1U+aBgDQ2ypjIQAAVnP6yw==\"",
"id": "AAMkAGJmZjA5NzI0LWM5NTgtNGRhYy04MDExLTJmZTY4ZTJkNmVlYQBGAAAAAAC-F40EZzuzSqgA9N8VQW0zBwD4kruruobVT5oGANDbKmMhAAAAAAENAAD4kruruobVT5oGANDbKmMhAABV-OaMAAA=",
"createdDateTime": "2018-03-13T13:30:54.740501Z",
"lastModifiedDateTime": "2018-03-13T13:42:33.869926Z",
"changeKey": "+JK7q7qG1U+aBgDQ2ypjIQAAVnP6yw==",
"categories": [],
"originalStartTimeZone": "Pacific Standard Time",
"originalEndTimeZone": "Pacific Standard Time",
"iCalUId": "<masked>",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "Microsoft DEMO - 2 UPDATED",
"bodyPreview": "Let's get together!",
"importance": "Normal",
"sensitivity": "Normal",
"isAllDay": false,
"isCancelled": false,
"isOrganizer": true,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "Busy",
"type": "SingleInstance",
"webLink": "<masked>",
"onlineMeetingUrl": null,
"responseStatus": {
"Response": "Organizer",
"Time": "0001-01-01T00:00:00Z"
},
"body": {
"ContentType": "HTML",
"Content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nLet's get together!\r\n</body>\r\n</html>\r\n"
},
"start": {
"DateTime": "2018-03-29T01:00:00Z",
"TimeZone": "tzone://Microsoft/Utc"
},
"end": {
"DateTime": "2018-03-29T06:00:00Z",
"TimeZone": "tzone://Microsoft/Utc"
},
"location": {
"DisplayName": "",
"LocationType": "Default",
"UniqueIdType": "Unknown",
"Address": {
"Type": "Unknown"
},
"Coordinates": {}
},
"locations": [],
"recurrence": null,
"attendees": [{
"Type": "Required",
"Status": {
"Response": "None",
"Time": "0001-01-01T00:00:00Z"
},
"EmailAddress": {
"Name": "<masked>",
"Address": "<masked>"
}
}],
"organizer": {
"EmailAddress": {
"Name": "<masked>",
"Address": "<masked>"
}
}
},
"clientState": "123456-fad3-4191-9a66-123456789"
}]
}
I expected just one notification for every update (In my case I just did an update on event title), but the server is receiving multiple notifications with just #odata.etag different in the notifications. Is this expected?

When making a change to any item, the server may need to perform several modifications on the item, as well as other related items behind the scenes. Each of these modifications would result in a notification. There also could be other entities that are listening to changes, and reacting to them, potentially causing further changes and hence more notifications on the item. So in short, there is no guarantee regarding the number of notifications that you may receive as a result of a single API call. That is specially true for high-level calendaring operations, which often involve complex workflows on the server.
In this case you can see that in fact you have received three different change keys, indicating that the item has been modified multiple times.

Related

How to extract a specific value from JSON file?

I'm trying to extract a specific value from JSON file.
the key value is: "info": "this is an example" (The key is unique)
I want to extract only the value: "this is an example"
My code:
cat 9.json | jq '.info'
result:
null
JSON file example:
{
"Event": {
"id": "13",
"orgc_id": "1",
"org_id": "1",
"date": "2019-01-09",
"threat_level_id": "3",
"info": "test9",
"published": false,
"uuid": "5c35d180",
"attribute_count": "2",
"analysis": "0",
"timestamp": "1547044733",
"distribution": "1",
"proposal_email_lock": false,
"locked": false,
"publish_timestamp": "1547034089",
"sharing_group_id": "0",
"disable_correlation": false,
"extends_uuid": "",
"event_creator_email": "o#cyhgfnt.com",
"Org": {
"id": "1",
"name": "Cygfdgfdnt",
"uuid": "5b9f938d-e3a0-4ecb-83b3-0bdeac1b41bc"
},
"Orgc": {
"id": "1",
"name": "Cyhgfgft",
"uuid": "5b9f938d-e3a0-4ecb-83b3-0bdeac1b41bc"
},
"Attribute": [{
"id": "292630",
"type": "domain",
"category": "Network activity",
"to_ids": true,
"uuid": "5c35dd94-cccc-4086-b386-682823717aa5",
"event_id": "1357",
"distribution": "5",
"timestamp": "1547034584",
"comment": "This is a comment",
"sharing_group_id": "0",
"deleted": false,
"disable_correlation": false,
"object_id": "0",
"object_relation": null,
"value": "dodskj.com",
"Galaxy": [],
"ShadowAttribute": [],
"Tag": [{
"id": "223",
"name": "kill-chain:Exploitation",
"colour": "#a80079",
"exportable": true,
"user_id": "0",
"hide_tag": false,
"numerical_value": null
}]
}, {
"id": "292631",
"type": "ip-dst",
"category": "Network activity",
"to_ids": true,
"uuid": "5c35dd94-fe90-4ef6-b3a9-682823717aa5",
"event_id": "1357",
"distribution": "5",
"timestamp": "1547044733",
"comment": "comment example",
"sharing_group_id": "0",
"deleted": false,
"disable_correlation": false,
"object_id": "0",
"object_relation": null,
"value": "8.8.6.6",
"Galaxy": [],
"ShadowAttribute": [],
"Tag": [{
"id": "247",
"name": "maec-malware-capabilities:maec-malware-capability=\"anti-removal\"",
"colour": "#3f0004",
"exportable": true,
"user_id": "0",
"hide_tag": false,
"numerical_value": null
}, {
"id": "465",
"name": "osint:lifetime=\"perpetual\"",
"colour": "#006ebe",
"exportable": true,
"user_id": "0",
"hide_tag": false,
"numerical_value": null
}]
}],
"ShadowAttribute": [],
"RelatedEvent": [],
"Galaxy": [{
"id": "3",
"uuid": "698774c7-8022-42c4-917f-8d6e4f06ada3",
"name": "Threat Actor",
"type": "threat-actor",
"description": "Threat actors are characteristics of malicious actors (or adversaries) representing a cyber attack threat including presumed intent and historically observed behaviour.",
"version": "3",
"icon": "user-secret",
"namespace": "misp",
"GalaxyCluster": [{
"id": "6397",
"collection_uuid": "7cdff317-a673-4474-84ec-4f1754947823",
"type": "threat-actor",
"value": "Sofacy",
"tag_name": "misp-galaxy:threat-actor=\"Sofacy\"",
"description": "The Sofacy Group (also known as APT28, Pawn Storm, Fancy Bear and Sednit) is a cyber espionage group believed to have ties to the Russian government. Likely operating since 2007, the group is known to target government, military, and security organizations. It has been characterized as an advanced persistent threat.",
"galaxy_id": "3",
"source": "MISP Project",
"authors": ["Alexandre Dulaunoy", "Florian Roth", "Thomas Schreck", "Timo Steffens", "Various"],
"version": "82",
"uuid": "5b4ee3ea-eee3-4c8e-8323-85ae32658754",
"tag_id": "608",
"meta": {
"cfr-suspected-state-sponsor": ["Russian Federation"],
"cfr-suspected-victims": ["Georgia", "France", "Jordan", "United States", "Hungary", "World Anti-Doping Agency", "Armenia", "Tajikistan", "Japan", "NATO", "Ukraine", "Belgium", "Pakistan", "Asia Pacific Economic Cooperation", "International Association of Athletics Federations", "Turkey", "Mongolia", "OSCE", "United Kingdom", "Germany", "Poland", "European Commission", "Afghanistan", "Kazakhstan", "China"],
"cfr-target-category": ["Government", "Military"],
"cfr-type-of-incident": ["Espionage"],
"country": ["RU"],
"refs": ["https:\/\/en.wikipedia.org\/wiki\/Sofacy_Group", "https:\/\/aptnotes.malwareconfig.com\/web\/viewer.html?file=..\/APTnotes\/2014\/apt28.pdf", "http:\/\/www.trendmicro.com\/cloud-content\/us\/pdfs\/security-intelligence\/white-papers\/wp-operation-pawn-storm.pdf", "https:\/\/www2.fireeye.com\/rs\/848-DID-242\/images\/wp-mandiant-matryoshka-mining.pdf", "https:\/\/www.crowdstrike.com\/blog\/bears-midst-intrusion-democratic-national-committee\/", "http:\/\/researchcenter.paloaltonetworks.com\/2016\/06\/unit42-new-sofacy-attacks-against-us-government-agency\/", "https:\/\/www.cfr.org\/interactive\/cyber-operations\/apt-28", "https:\/\/blogs.microsoft.com\/on-the-issues\/2018\/08\/20\/we-are-taking-new-steps-against-broadening-threats-to-democracy\/", "https:\/\/www.bleepingcomputer.com\/news\/security\/microsoft-disrupts-apt28-hacking-campaign-aimed-at-us-midterm-elections\/", "https:\/\/www.bleepingcomputer.com\/news\/security\/apt28-uses-lojax-first-uefi-rootkit-seen-in-the-wild\/"],
"synonyms": ["APT 28", "APT28", "Pawn Storm", "PawnStorm", "Fancy Bear", "Sednit", "TsarTeam", "Tsar Team", "TG-4127", "Group-4127", "STRONTIUM", "TAG_0700", "Swallowtail", "IRON TWILIGHT", "Group 74"]
}
}]
}],
"Object": [],
"Tag": [{
"id": "608",
"name": "misp-galaxy:threat-actor=\"Sofacy\"",
"colour": "#12e000",
"exportable": true,
"user_id": "0",
"hide_tag": false,
"numerical_value": null
}, {
"id": "118",
"name": "gdpr:special-categories=\"health\"",
"colour": "#3ce600",
"exportable": true,
"user_id": "0",
"hide_tag": false,
"numerical_value": null
}]
}
}
I suppose you are trying to get the .info field inside .Event which should have been written as below. Use -r for without quotes
jq '.Event.info'

Extract some value from JSON using JsonPath with != condition in Jmeter

I have the following JSON and I need to get id values for instances which do not have type = Jenkins
{
"data": [
{
"id": "35002399-6fd7-40b7-b0d0-8be64e4ec09c",
"name": "94Jenkins",
"url": "http://127.0.0.1:8084",
"authProvider": false,
"siteId": "cce1b6e2-4b5d-4455-ac96-6b5d4c0d901d",
"status": {
"status": "ONLINE"
},
"instanceStateReady": true,
"instanceState": {
"#type": "InstanceStateDto",
"version": "2.60.3"
},
"adminUser": "admin1",
"hasDRConfig": false,
"managed": true,
"type": "JENKINS",
"siteName": "City",
"lastRefreshTime": "2018-04-24T09:43:01.694Z"
},
{
"id": "5cd3caf6-bac1-4f07-8793-5f124b90eaf5",
"name": "RJO",
"url": "http://test.com",
"authProvider": false,
"status": {
"status": "UNAUTHORIZED"
},
"instanceStateReady": true,
"instanceState": {
"#type": "numberOfArtifacts",
"version": "5.5.2-m002",
"licenses": {
"RJO : artrjo-m": {
"type": "ENTERPRISE",
"validThrough": "Jun 12, 2021",
"licensedTo": "Test",
"licenseHash": "asdadsdb612bda1aae745bd2a3",
"expired": false
},
"RJO : artrjo-s1": {
"type": "ENTERPRISE",
"validThrough": "Jun 12, 2021",
"licensedTo": "JFrog",
"licenseHash": "asaswca236350205a3798c0fa3",
"expired": false
}
}
},
"adminUser": "jfmc",
"hasDRConfig": false,
"managed": false,
"warnings": [
"Site is missing",
"Failed to connect to the service. Please verify that the service information provided is correct."
],
"type": "ARTIFACTORY"
},
{
"id": "0727a49a-6c95-433e-9fc5-7e5c760cc76f",
"name": "NinetyTwo",
"url": "http:127.0.0.1:8081",
"authProvider": true,
"siteId": "cce1b6e2-4b5d-4455-ac96-6b5d4c0d901d",
"status": {
"status": "ONLINE"
},
"instanceStateReady": true,
"instanceState": {
"#type": "numberOfArtifacts",
"version": "5.9.0",
"licenses": {
"NinetyTwo": {
"type": "ENTERPRISE",
"validThrough": "Dec 30, 2018",
"licensedTo": "Test",
"licenseHash": "qweqwed95f712dbabee98184da52443",
"expired": false
}
}
},
"adminUser": "admin",
"hasDRConfig": false,
"managed": true,
"type": "ARTIFACTORY",
"serviceId": "jfrt#01c7g4c7hq0dpd0qa71r8c09sj",
"siteName": "Test",
"lastRefreshTime": "2018-04-24T09:43:01.698Z"
}
]
}
And I use $..[?(#.type!='JENKINS')].id path to receive id-s which relate to the instances with type NOT JENKINS, however JSON Extractor returns me the Jenkins's id too. The question is how can I receive ids for non-jenkins instances only?
Replace your JSON path expression with the below and it should work:
$.data.[*][?(#.type != "JENKINS")].id

CEP 5.4.3, not triggering basic condition

using CEP i'm trying to make a basic example of communication between Proton and Orion.
I simply want Proton to receive a notification of temperature from Orion and send back a payload changing one boolean attribute if the temperature value is superior or equal to 20.
Here is the definition i'm using.
{
"epn":
{
"events":
[
{
"name": "TemperatureContextUpdate",
"attributes":
[
{
"dimension": 0,
"description": "The certainty that this event happen (value between 0 to 1)",
"name": "Certainty",
"defaultValue": "1",
"type": "Double"
},
{
"dimension": 0,
"description": "No value means it equals the event detection time, other option is to use one of the defined distribution functions with parameters",
"name": "OccurrenceTime",
"type": "Date"
},
{
"dimension": 0,
"name": "ExpirationTime",
"type": "Date"
},
{
"dimension": 0,
"description": "The cost of this event occurrence. Negative if this is an opportunity",
"name": "Cost",
"type": "Double"
},
{
"dimension": 0,
"description": "Used in case the this event occur within an interval",
"name": "Duration",
"defaultValue": "0",
"type": "Double"
},
{
"dimension": "0",
"name": "entityId",
"type": "String"
},
{
"dimension": "0",
"name": "entityType",
"type": "String"
},
{
"dimension": "0",
"name": "temperature",
"type": "Integer"
},
{
"dimension": "0",
"name": "chaud",
"type": "Boolean"
}
],
"createdDate": "Wed Feb 22 2017"
},
{
"name": "Out_TemperatureContextUpdate",
"attributes":
[
{
"dimension": 0,
"description": "The certainty that this event happen (value between 0 to 1)",
"name": "Certainty",
"defaultValue": "1",
"type": "Double"
},
{
"dimension": 0,
"description": "No value means it equals the event detection time, other option is to use one of the defined distribution functions with parameters",
"name": "OccurrenceTime",
"type": "Date"
},
{
"dimension": 0,
"name": "ExpirationTime",
"type": "Date"
},
{
"dimension": 0,
"description": "The cost of this event occurrence. Negative if this is an opportunity",
"name": "Cost",
"type": "Double"
},
{
"dimension": 0,
"description": "Used in case the this event occur within an interval",
"name": "Duration",
"defaultValue": "0",
"type": "Double"
},
{
"dimension": "0",
"name": "entityId",
"type": "String"
},
{
"dimension": "0",
"name": "entityType",
"type": "String"
},
{
"dimension": "0",
"name": "temperature",
"type": "Integer"
},
{
"dimension": "0",
"name": "chaud",
"type": "Boolean"
}
],
"createdDate": "Wed Feb 22 2017"
}
],
"name": "TemperatureDemo",
"consumers":
[
{
"events":
[
{
"name": "Out_TemperatureContextUpdate"
}
],
"name": "Consumer_Rest",
"properties":
[
{
"name": "URL",
"value": "http://172.17.0.3:1026/v2/entities"
},
{
"name": "contentType",
"value": "application/json"
},
{
"name": "formatter",
"value": "json_ngsi"
},
{
"name": "delimiter",
"value": ";"
},
{
"name": "tagDataSeparator",
"value": "="
},
{
"name": "dateFormat",
"value": "dd/MM/yyyy-HH:mm:ss"
}
],
"type": "Rest",
"createdDate": "Wed Feb 22 2017"
},
{
"events":
[
{
"name": "TemperatureContextUpdate"
}
],
"name": "Consumer_File",
"properties":
[
{
"name": "filename",
"value": "/home/work/Documents/test.txt"
},
{
"name": "formatter",
"value": "json"
},
{
"name": "delimiter",
"value": ";"
},
{
"name": "tagDataSeparator",
"value": "="
}
],
"type": "File",
"createdDate": "Wed Feb 22 2017"
}
],
"epas":
[
{
"inputEvents":
[
{
"instanceSelectionPolicy": "First",
"alias": "TemperatureContextUpdate",
"filterExpression": "TemperatureContextUpdate.temperature>=20",
"name": "TemperatureContextUpdate",
"consumptionPolicy": "Consume"
}
],
"derivedEvents":
[
{
"name": "Out_TemperatureContextUpdate",
"reportParticipants": false,
"expressions":
{
"Cost": "TemperatureContextUpdate.Cost",
"Certainty": "TemperatureContextUpdate.Certainty",
"OccurrenceTime": "TemperatureContextUpdate.OccurrenceTime",
"Duration": "TemperatureContextUpdate.Duration",
"entityId": "TemperatureContextUpdate.entityId",
"ExpirationTime": "TemperatureContextUpdate.ExpirationTime",
"chaud": "true",
"entityType": "TemperatureContextUpdate.entityType",
"temperature": "TemperatureContextUpdate.temperature"
}
}
],
"evaluationPolicy": "Immediate",
"name": "EPA_Change",
"internalSegmentation":
[
],
"context": "always",
"epaType": "Basic",
"cardinalityPolicy": "Single",
"localPlacement": true,
"createdDate": "Wed Feb 22 2017",
"computedVariables":
[
]
}
],
"optimization":
{
},
"contexts":
{
"temporal":
[
{
"terminators":
[
],
"neverEnding": true,
"atStartup": true,
"name": "always",
"type": "TemporalInterval",
"createdDate": "Wed Feb 22 2017",
"initiators":
[
]
}
],
"segmentation":
[
],
"composite":
[
]
},
"producers":
[
]
}
}
I try to create a file while first update is receive but this file is always empty, btw it is correctly create in my directory and change everytime I change definition. The rest payload is never send like the condition is never triggered.
The payload I send :
{
"subscriptionId": "51c04a21d714fb3b37d7d5a7",
"data":
[ {
"id": "temp1",
"type": "Temperature",
"temperature": {
"type":"integer",
"value": 28,
"metadata":{}
},
"chaud": {
"type":"boolean",
"value": false,
"metadata":{}
},
"Certainty": {
"value": "1",
"type": "Float"
},
"Cost": {
"value": "0",
"type": "Float"
},
"Name": {
"value": "",
"type": "String"
},
"EventSource": {
"value": "",
"type": "String"
},
"Duration": {
"value": "0",
"type": "Float"
}
}
]
}
The log catalina.out :
INFOS: started event message body reader
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader parseVTwoFormat
INFOS: Event: TemperatureContextUpdate
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom
INFOS: finished event message body reader
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom
INFOS: EventJSONNgsiMessageReader: read event TemperatureContextUpdate; entityId=temp1; EventId=ba868559-7589-4720-ab75-658b920a3f14; chaud=false; entityType=Temperature; Chronon=null; temperature=28; DetectionTime=1487845415319; Name=; Certainty=1; Cost=0; EventSource=; OccurrenceTime=null; Duration=0; Annotation=; ExpirationTime=null; from broker...
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent
INFOS: starting submitNewEvent
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent
INFOS: events sent to proton runtime...
So any idea where is my problem ?
Thanks.
your mistake is that you send an event with an empty name.
I am sorry the same information is duplicated in the input, however this steams from the integration between Proton and Orion, each of which requires the information in different form and the difference was not patched smoothly.
The input you should send should contain the input event name, like this :
{
"subscriptionId": "51c04a21d714fb3b37d7d5a7",
"data":
[ {
"id": "temp1",
"type": "Temperature",
"temperature": {
"type":"integer",
"value": "28",
"metadata":{}
},
"chaud": {
"type":"boolean",
"value": false,
"metadata":{}
},
"Certainty": {
"value": "1",
"type": "Float"
},
"Cost": {
"value": "0",
"type": "Float"
},
"Name": {
"value": "TemperatureContextUpdate",
"type": "String"
},
"EventSource": {
"value": "",
"type": "String"
},
"Duration": {
"value": "0",
"type": "Float"
}
}
]
}
Note that the name attribute now has value "TemperatureContextUpdate"

How to get all versions of Confluence page via REST API

I would like to retrieve all versions of a page in Confluence. There is a call in the REST API that claims to return the history, but I have little luck with it.
/rest/api/content/{id}/history
When I call this I get a response along these lines:
{"latest": true,
"createdBy": {
"type": "known",
"profilePicture": {
"path": "/confluence/s/en_GB/.../profilepics/Avatar-14.png",
"width": 48,
"height": 48,
"isDefault": false
},
"username": "first.last#abc123.com",
"displayName": "First Last",
"userKey": "userKey"
}, "createdDate": "2014-12-29T13:56:16.000+0100", "_links": {
"base": "https://host.abc123.net/confluence",
"context": "/confluence",
"self": "host.abc123.net/confluence/rest/api/content/12345678/history"
}, "_expandable": {
"lastUpdated": ""
}}
I know that this page has 17 versions in the history through the browser interface. I can't seem to get anywhere by adding any kind of expand= to the query either.
The documentation for Confluence REST API tells me that this call should:
Returns a full JSON representation of the content's history
If I turn to the "normal" REST API call to retrieve content, I can get some hint about the history in the version structure:
{"version": {
"by": {
"type": "known",
"profilePicture": {
"path": "/confluence/s/en_GB/5639/.../profilepics/default.png",
"width": 48,
"height": 48,
"isDefault": true
},
"username": "some.other#abc123",
"displayName": "Some Other",
"userKey": "userKeyGuidThingy"
},
"when": "2015-01-30T16:00:09.000+0100",
"message": "",
"number": 17,
"minorEdit": false
} }
I am very keen on retrieving the other versions, numbers 1 - 16, but I can't see how..
I'd be most grateful for any help to get me unstuck.. :)
Here is an example:
Request:
http://localhost:8090/rest/experimental/content/7965952/version?expand=content
Response:
{
"results": [
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:56:29.000+03:00",
"message": "more stuff",
"number": 6,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "current",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/display/S1/cla1",
"tinyui": "/x/AI15",
"self": "http://localhost:8090/rest/api/content/7965952"
},
"_expandable": {
"container": "/rest/api/space/S1",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/6"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:56:12.000+03:00",
"message": "stuff",
"number": 5,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965962",
"tinyui": "/x/Co15",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=5"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=5",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/5"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:39:28.000+03:00",
"message": "",
"number": 4,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965961",
"tinyui": "/x/CY15",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=4"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=4",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/4"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:39:12.000+03:00",
"message": "",
"number": 3,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965959",
"tinyui": "/x/B415",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=3"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=3",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/3"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:38:36.000+03:00",
"message": "",
"number": 2,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965957",
"tinyui": "/x/BY15",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=2"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=2",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/2"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:23:14.000+03:00",
"message": "",
"number": 1,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965955",
"tinyui": "/x/A415",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=1"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=1",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/1"
}
}
],
"start": 0,
"limit": 100,
"size": 6,
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version?expand=content",
"base": "http://localhost:8090",
"context": ""
}
}
this will get you all versions of a page with version messages
I found the way to get version number.
so If you go to https://confluence.yourdomain.com/rest/api/content/page_id(1234567)/history. You will get the following json response.
{
"previousVersion":{
"by":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"when":"date-time",
"message":"",
"number":1,
"minorEdit":false
},
"lastUpdated":{
"by":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"when":"date-time",
"message":"",
"number":2,
"minorEdit":false
},
"latest":true,
"createdBy":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"createdDate":"userkey",
"_links":{
"base":"https://confluence.yourdomain.com",
"context":"",
"self":"https://confluence.yourdomain.com/rest/api/content/page_id/history"
}
}
From that response json just fetch the version number depends on the scripting language that you are using. For Python following the piece of code will fetch the version number.
version=requests.get(https://confluence.yourdomain.com/rest/api/content/page_id(1234567)/history)
version= version.json()
print version['lastUpdated']['number']
This will give you latest version number of the page.

how to parse json body which is like a listed dictionary

i want to get access of "uuid" everytime,which is two times present in this code and also access to "cloud_uuid". the body is something like below:
{
"computes": [{
"uuid": "110c607a-231c-4724-be7f-db5ed388158",
"name": "9.4.98.33",
"description": null,
"version": "1.0",
"type": "compute",
"number_of_vms": 0,
"status": "ACTIVE",
"provisioning_status": {
"status": "COMPLETED",
"started_at": "",
"updated_at": "",
"status_data": null
},
"health_status": {
"status": "OK",
"alerts": [],
"updated_at": "2014-07-11T17:09:12.194000"
},
"compliance_status": {
"compliance_reasons": null,
"is_compliant": true,
"updated_at": null
},
"run_priority_order": null,
"created": "2014-07-11T16:01:32.837821",
"updated": "2014-07-11T17:08:16.031838",
"capability_categories": {
"v": [{
"name_key": "",
"description_key": "",
"version": "0",
"hidden": t,
"priority": 1,
"name_nls": "",
"description_nls": ""
}],
"monitoring": [{
"name_key": "m",
"description_key": null,
"version": "1.0",
"hidden": true,
"priority": 100,
"name_nls": "monitoring",
"description_nls": null
}],
"scheduler": [{
"name_key": "",
"description_key": null,
"version": "1.0",
"hidden": false,
"priority": 20,
"name_nls": "",
"description_nls": null
}],
"network": [{
"name_key": "",
"description_key": "",
"version": "1.0",
"hidden": false,
"priority": 10,
"name_nls": "",
"description_nls": ""
}]
},
"links": [{
"href": "",
"rel": "self"
}, {
"href": "",
"rel": "bookmark"
}],
"cloud_uuid": "b603e16e-38a6-435e-9359-79c27fee93a",
"operating_system_uuid": "70f605e7-6512-49b4-833c-b25d47823a4"
}, {
"uuid": "7383f4a5-dc0a-420b-806c-abbd49c1655a",
"name": "9.4.193.20",
"description": null,
"version": "1.0",
"type": "compute"
could you help with below,i tried the code as answered in comment:
suppose body is "clouds" instead of "computes"
i tried for getting cloud_uuid with something like:cloud_uuid = ((e['cloud_uuid'] for e in dict['clouds'] if e['name'] == name_to_find), None)
it throws error->
cloud_uuid = ((e['cloud_uuid'] for e in dict['clouds'] if e['name'] ==
name_to_find), None) TypeError: 'type' object is unsubscriptable
In python it is very simple:
[(e['uuid'], e['cloud_uuid']) for e in dict['computes']]
Edit:
It looks like I overlooked a pair square braces. Try:
[(_['computes'][0]['uuid'], _['cloud_uuid']) for _ in data]